import { LegacyRef, useEffect, useRef, useState } from "react" import classNames from…
- User
import { LegacyRef, useEffect, useRef, useState } from "react" import classNames from "classnames" import ReactMarkdown from "react-markdown" import remarkGfm from "remark-gfm" import { Prism as SyntaxHighlighter } from "react-syntax-highlighter" import { prism } from "react-syntax-highlighter/dist/esm/styles/prism"
import useWindowDimensions from "../../../../../../hooks/window-dimensions.hook" import { Config } from "../../../../../../utils/config" import { CreateJournaleType } from "../../../../../../types/journal.type" import { Button } from "../../../../../../ui-component/button/button.component" import { useAccountUser } from "../../../../../../hooks/user.hook" import { Icon } from "../../../../../../ui-component/icon/icon.component" import { Placeholder } from "../../../../../../ui-component/placeholder/placeholder.component" import { DashboardInput } from "../../../../dashboard-input/dashboard-input.component" import { TokenUtils } from "../../../../../../utils/token.utils"
import step2 from "../../../../../../assets/images/step2.png" import rotate from "../../../../../../assets/images/rotate.png" import botLogo from "../../../../../../assets/images/bot-logo.svg"
import styles from "./step2.module.css"
export function Step2({ journal, setJournal, onClick, }: { journal: CreateJournaleType setJournal: React.Dispatch<React.SetStateAction> onClick: () => void }) { // --------------------------------------------------------------------------- // variables // ---------------------------------------------------------------------------
const accountUser = useAccountUser() const { width: screenWidth } = useWindowDimensions()
const textareaGptRef = useRef(null) const messagesEndRef = useRef<HTMLDivElement | null>(null)
const [data, setData] = useState<{ title: string description: string }>({ title: journal.firstEventTitle, description: "", }) const [chatHistory, setChatHistory] = useState< Array<{ role: "user" | "bot"; content: string }>
([]) const [userInput, setUserInput] = useState("")
const [isFocus, setIsFocus] = useState(false) const [loading, setLoading] = useState(false)
// --------------------------------------------------------------------------- // effects // ---------------------------------------------------------------------------
useEffect(() => { calculateGptHeight() }, [data.description, screenWidth])
useEffect(() => { if (messagesEndRef.current) { messagesEndRef.current.scrollIntoView({ behavior: "instant" }) } }, [chatHistory])
// --------------------------------------------------------------------------- // functions // ---------------------------------------------------------------------------
function calculateGptHeight() { if (textareaGptRef.current) { textareaGptRef.current.style.height = "auto" textareaGptRef.current.style.height =
${Math.min(textareaGptRef.current.scrollHeight, 260)}px} } - Assistant