diff options
| author | Dhravya Shah <[email protected]> | 2024-07-20 20:52:19 -0500 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2024-07-20 20:52:19 -0500 |
| commit | 05ee3508bb8ef5007fb858d49f5f73073e3f572e (patch) | |
| tree | a7562736f23ca899d60df6d8f7e9ea35154625b8 /apps | |
| parent | changes in queryinput home layout (diff) | |
| download | supermemory-05ee3508bb8ef5007fb858d49f5f73073e3f572e.tar.xz supermemory-05ee3508bb8ef5007fb858d49f5f73073e3f572e.zip | |
wtf is going on
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/web/app/(dash)/home/page.tsx | 300 |
1 files changed, 150 insertions, 150 deletions
diff --git a/apps/web/app/(dash)/home/page.tsx b/apps/web/app/(dash)/home/page.tsx index 80dde7a4..74f6fdd8 100644 --- a/apps/web/app/(dash)/home/page.tsx +++ b/apps/web/app/(dash)/home/page.tsx @@ -1,160 +1,160 @@ -"use client"; - -import React, { useEffect, useState } from "react"; -import QueryInput from "./queryinput"; -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 { ChromeIcon, GithubIcon, TwitterIcon } from "lucide-react"; -import Image from "next/image"; -import Logo from "../../../public/logo.svg"; +'use client'; + +import React, { useEffect, useState } from 'react'; +import QueryInput from './queryinput'; +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 { ChromeIcon, GithubIcon, TwitterIcon } from 'lucide-react'; +import Image from 'next/image'; +import Logo from '../../../public/logo.svg'; const slap = { - initial: { - opacity: 0, - scale: 1.1, - }, - whileInView: { opacity: 1, scale: 1 }, - transition: { - duration: 0.5, - ease: "easeInOut", - }, - viewport: { once: true }, + initial: { + opacity: 0, + scale: 1.1, + }, + whileInView: { opacity: 1, scale: 1 }, + transition: { + duration: 0.5, + ease: 'easeInOut', + }, + viewport: { once: true }, }; function Page({ - searchParams, + searchParams, }: { - searchParams: Record<string, string | string[] | undefined>; + searchParams: Record<string, string | string[] | undefined>; }) { - // TODO: use this to show a welcome page/modal - // const { firstTime } = homeSearchParamsCache.parse(searchParams); - - const [queryPresent, setQueryPresent] = useState<boolean>(false); - - 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); - - useEffect(() => { - 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(); - } - - if (extensionInstalled) { - toast.success("Extension installed successfully"); - } - - getSpaces().then((res) => { - if (res.success && res.data) { - setSpaces(res.data); - return; - } - // TODO: HANDLE ERROR - }); - - 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" - > - <span>Ask your</span>{" "} - <span className="inline-flex items-center gap-2 bg-gradient-to-r to-blue-300 from-zinc-300 text-transparent bg-clip-text"> - supermemory - </span> - </motion.h1> - - <div className="w-full pb-20 mt-12"> - <QueryInput - setQueryPresent={setQueryPresent} - handleSubmit={async (q, spaces) => { - if (q.length === 0) { - toast.error("Query is required"); - return; - } - - const threadid = await createChatThread(q); - - if (!threadid.success || !threadid.data) { - toast.error("Failed to create chat thread"); - return; - } - - push( - `/chat/${threadid.data}?spaces=${JSON.stringify(spaces)}&q=${q}`, - ); - }} - initialSpaces={spaces} - /> - </div> - - <div className="w-full fixed bottom-0 left-0 p-4"> - <div className="flex items-center justify-center gap-8"> - <a - href="https://supermemory.ai/extension" - target="_blank" - rel="noreferrer" - className="flex items-center gap-2 text-muted-foreground" - > - <ChromeIcon className="w-4 h-4" /> - Install extension - </a> - <a - href="https://github.com/supermemoryai/supermemory/issues/new" - target="_blank" - rel="noreferrer" - className="flex items-center gap-2 text-muted-foreground" - > - <GithubIcon className="w-4 h-4" /> - Bug report - </a> - <a - href="https://x.com/supermemoryai" - target="_blank" - rel="noreferrer" - className="flex items-center gap-2 text-muted-foreground" - > - <TwitterIcon className="w-4 h-4" /> - Twitter - </a> - </div> - </div> - </div> - ); + // TODO: use this to show a welcome page/modal + // const { firstTime } = homeSearchParamsCache.parse(searchParams); + + const [queryPresent, setQueryPresent] = useState<boolean>(false); + + 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); + + useEffect(() => { + 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(); + } + + if (extensionInstalled) { + toast.success('Extension installed successfully'); + } + + getSpaces().then((res) => { + if (res.success && res.data) { + setSpaces(res.data); + return; + } + // TODO: HANDLE ERROR + }); + + 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" + > + <span>Ask your</span>{' '} + <span className="inline-flex items-center gap-2 bg-gradient-to-r to-blue-300 from-zinc-300 text-transparent bg-clip-text"> + supermemory + </span> + </motion.h1> + + <div className="w-full pb-20 mt-12"> + <QueryInput + setQueryPresent={setQueryPresent} + handleSubmit={async (q, spaces) => { + if (q.length === 0) { + toast.error('Query is required'); + return; + } + + const threadid = await createChatThread(q); + + if (!threadid.success || !threadid.data) { + toast.error('Failed to create chat thread'); + return; + } + + push( + `/chat/${threadid.data}?spaces=${JSON.stringify(spaces)}&q=${q}`, + ); + }} + initialSpaces={spaces} + /> + </div> + + <div className="w-full fixed bottom-0 left-0 p-4"> + <div className="flex items-center justify-center gap-8"> + <a + href="https://supermemory.ai/extension" + target="_blank" + rel="noreferrer" + className="flex items-center gap-2 text-muted-foreground" + > + <ChromeIcon className="w-4 h-4" /> + Install extension + </a> + <a + href="https://github.com/supermemoryai/supermemory/issues/new" + target="_blank" + rel="noreferrer" + className="flex items-center gap-2 text-muted-foreground" + > + <GithubIcon className="w-4 h-4" /> + Bug report + </a> + <a + href="https://x.com/supermemoryai" + target="_blank" + rel="noreferrer" + className="flex items-center gap-2 text-muted-foreground" + > + <TwitterIcon className="w-4 h-4" /> + Twitter + </a> + </div> + </div> + </div> + ); } export default Page; |