diff options
| author | Dhravya <[email protected]> | 2024-06-02 12:12:38 -0500 |
|---|---|---|
| committer | Dhravya <[email protected]> | 2024-06-02 12:12:38 -0500 |
| commit | 5fe0caabf8e650aa221ef0faccf4520b0e1cbee2 (patch) | |
| tree | cfba72d2cbacd070eb6c7891c2c1fd36f32aac26 /apps/web/app/(dash)/chat | |
| parent | fixed some import bugs (diff) | |
| download | supermemory-5fe0caabf8e650aa221ef0faccf4520b0e1cbee2.tar.xz supermemory-5fe0caabf8e650aa221ef0faccf4520b0e1cbee2.zip | |
improvements in dash + chatUI
Diffstat (limited to 'apps/web/app/(dash)/chat')
| -rw-r--r-- | apps/web/app/(dash)/chat/actions.ts | 1 | ||||
| -rw-r--r-- | apps/web/app/(dash)/chat/chatWindow.tsx | 60 | ||||
| -rw-r--r-- | apps/web/app/(dash)/chat/page.tsx | 14 |
3 files changed, 75 insertions, 0 deletions
diff --git a/apps/web/app/(dash)/chat/actions.ts b/apps/web/app/(dash)/chat/actions.ts new file mode 100644 index 00000000..908fe79e --- /dev/null +++ b/apps/web/app/(dash)/chat/actions.ts @@ -0,0 +1 @@ +"use server"; diff --git a/apps/web/app/(dash)/chat/chatWindow.tsx b/apps/web/app/(dash)/chat/chatWindow.tsx new file mode 100644 index 00000000..8361bbf8 --- /dev/null +++ b/apps/web/app/(dash)/chat/chatWindow.tsx @@ -0,0 +1,60 @@ +"use client"; + +import { AnimatePresence } from "framer-motion"; +import React, { useEffect, useState } from "react"; +import QueryInput from "../home/queryinput"; +import { cn } from "@repo/ui/lib/utils"; +import { motion } from "framer-motion"; +import { useRouter } from "next/navigation"; + +function ChatWindow({ q, spaces }: { q: string; spaces: number[] }) { + const [layout, setLayout] = useState<"chat" | "initial">("initial"); + + const router = useRouter(); + + useEffect(() => { + if (q !== "") { + setTimeout(() => { + setLayout("chat"); + }, 300); + } else { + router.push("/home"); + } + }, [q]); + return ( + <div> + <AnimatePresence mode="popLayout"> + {layout === "initial" ? ( + <motion.div + exit={{ opacity: 0 }} + key="initial" + className="max-w-3xl flex mx-auto w-full flex-col" + > + <div className="w-full h-96"> + <QueryInput + initialQuery={q} + initialSpaces={spaces ?? []} + disabled + /> + </div> + </motion.div> + ) : ( + <div + className="max-w-3xl flex mx-auto w-full flex-col mt-8" + key="chat" + > + <h2 + className={cn( + "transition-all transform translate-y-0 opacity-100 duration-500 ease-in-out font-semibold text-2xl", + )} + > + {q} + </h2> + </div> + )} + </AnimatePresence> + </div> + ); +} + +export default ChatWindow; diff --git a/apps/web/app/(dash)/chat/page.tsx b/apps/web/app/(dash)/chat/page.tsx new file mode 100644 index 00000000..4ad4d468 --- /dev/null +++ b/apps/web/app/(dash)/chat/page.tsx @@ -0,0 +1,14 @@ +import { chatSearchParamsCache } from "../../helpers/lib/searchParams"; +import ChatWindow from "./chatWindow"; + +function Page({ + searchParams, +}: { + searchParams: Record<string, string | string[] | undefined>; +}) { + const { firstTime, q, spaces } = chatSearchParamsCache.parse(searchParams); + + return <ChatWindow q={q} spaces={spaces ?? []} />; +} + +export default Page; |