diff options
Diffstat (limited to 'apps/web/app/(dash)/home/page.tsx')
| -rw-r--r-- | apps/web/app/(dash)/home/page.tsx | 97 |
1 files changed, 27 insertions, 70 deletions
diff --git a/apps/web/app/(dash)/home/page.tsx b/apps/web/app/(dash)/home/page.tsx index 378acdf8..630c4306 100644 --- a/apps/web/app/(dash)/home/page.tsx +++ b/apps/web/app/(dash)/home/page.tsx @@ -6,21 +6,18 @@ import { getSessionAuthToken, getSpaces } from "@/app/actions/fetchers"; import { useRouter } from "next/navigation"; import { createChatThread, linkTelegramToUser } from "@/app/actions/doers"; import { toast } from "sonner"; -import { motion } from "framer-motion"; -import { variants } from "./homeVariants"; +import { Heading } from "./heading"; +import History from "./history"; import { ChromeIcon, GithubIcon, TwitterIcon } from "lucide-react"; -const slap = { - initial: { - opacity: 0, - scale: 1.1, - }, - whileInView: { opacity: 1, scale: 1 }, - transition: { - duration: 0.5, - ease: "easeInOut", - }, - viewport: { once: true }, +const linkTelegram = async (telegramUser: string) => { + const response = await linkTelegramToUser(telegramUser); + + if (response.success) { + toast.success("Your telegram has been linked successfully."); + } else { + toast.error("Failed to link telegram. Please try again."); + } }; function Page({ @@ -28,41 +25,24 @@ function Page({ }: { searchParams: Record<string, string | string[] | undefined>; }) { - // TODO: use this to show a welcome page/modal - // const { firstTime } = homeSearchParamsCache.parse(searchParams); - - const [telegramUser, setTelegramUser] = useState<string | undefined>( - searchParams.telegramUser as string, - ); - const [extensionInstalled, setExtensionInstalled] = useState< - string | undefined - >(searchParams.extension as string); - const { push } = useRouter(); const [spaces, setSpaces] = useState<{ id: number; name: string }[]>([]); - const [showVariant, setShowVariant] = useState<number>(0); + const [queryPresent, setQueryPresent] = useState<boolean>(false); useEffect(() => { + // telegram bot + const telegramUser = searchParams.extension as string; if (telegramUser) { - const linkTelegram = async () => { - const response = await linkTelegramToUser(telegramUser); - - if (response.success) { - toast.success("Your telegram has been linked successfully."); - } else { - toast.error("Failed to link telegram. Please try again."); - } - }; - - linkTelegram(); + linkTelegram(telegramUser); } - if (extensionInstalled) { + if (searchParams.extension as string) { toast.success("Extension installed successfully"); } + // fetch spaces getSpaces().then((res) => { if (res.success && res.data) { setSpaces(res.data); @@ -71,44 +51,18 @@ function Page({ // TODO: HANDLE ERROR }); - setShowVariant(Math.floor(Math.random() * variants.length)); - getSessionAuthToken().then((token) => { if (typeof window === "undefined") return; window.postMessage({ token: token.data }, "*"); }); - }, [telegramUser]); + }, []); return ( - <div className="max-w-3xl h-full justify-center flex mx-auto w-full flex-col px-2 md:px-0"> - {/* all content goes here */} - {/* <div className="">hi {firstTime ? 'first time' : ''}</div> */} - - <motion.h1 - {...{ - ...slap, - transition: { ...slap.transition, delay: 0.2 }, - }} - className="text-center mx-auto bg-[linear-gradient(180deg,_#FFF_0%,_rgba(255,_255,_255,_0.00)_202.08%)] bg-clip-text text-4xl tracking-tighter text-transparent md:text-5xl" - > - {variants[showVariant]!.map((v, i) => { - return ( - <span - key={i} - className={ - v.type === "highlighted" - ? "bg-gradient-to-r to-blue-200 from-zinc-300 text-transparent bg-clip-text" - : "" - } - > - {v.content} - </span> - ); - })} - </motion.h1> - - <div className="w-full pb-20 mt-12"> + <div className="max-w-3xl mt-[18vh] mx-auto w-full px-2 md:px-0"> + <Heading queryPresent={queryPresent} /> + <div className="w-full py-12"> <QueryInput + setQueryPresent={(t: boolean) => setQueryPresent(t)} handleSubmit={async (q, spaces) => { if (q.length === 0) { toast.error("Query is required"); @@ -127,9 +81,12 @@ function Page({ ); }} initialSpaces={spaces} - setInitialSpaces={setSpaces} /> </div> + <div className="space-y-5"> + <h3 className="text-lg">Recent Searches</h3> + <History /> + </div> <div className="w-full fixed bottom-0 left-0 p-4"> <div className="flex items-center justify-center gap-8"> @@ -143,7 +100,7 @@ function Page({ Install extension </a> <a - href="https://github.com/supermemoryai/supermemory/issues/new" + href="https://github.com/Dhravya/supermemory/issues/new" target="_blank" rel="noreferrer" className="flex items-center gap-2 text-muted-foreground" @@ -152,7 +109,7 @@ function Page({ Bug report </a> <a - href="https://x.com/supermemoryai" + href="https://x.com/supermemory.ai" target="_blank" rel="noreferrer" className="flex items-center gap-2 text-muted-foreground" |