From 05ee3508bb8ef5007fb858d49f5f73073e3f572e Mon Sep 17 00:00:00 2001 From: Dhravya Shah Date: Sat, 20 Jul 2024 20:52:19 -0500 Subject: [PATCH] wtf is going on --- apps/web/app/(dash)/home/page.tsx | 262 +++++++++++++++--------------- package.json | 2 +- 2 files changed, 132 insertions(+), 132 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"; +'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"; +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; + searchParams: Record; }) { - // TODO: use this to show a welcome page/modal - // const { firstTime } = homeSearchParamsCache.parse(searchParams); + // TODO: use this to show a welcome page/modal + // const { firstTime } = homeSearchParamsCache.parse(searchParams); - const [queryPresent, setQueryPresent] = useState(false); + const [queryPresent, setQueryPresent] = useState(false); - const [telegramUser, setTelegramUser] = useState( - searchParams.telegramUser as string, - ); - const [extensionInstalled, setExtensionInstalled] = useState< - string | undefined - >(searchParams.extension as string); + const [telegramUser, setTelegramUser] = useState( + searchParams.telegramUser as string, + ); + const [extensionInstalled, setExtensionInstalled] = useState< + string | undefined + >(searchParams.extension as string); - const { push } = useRouter(); + const { push } = useRouter(); - const [spaces, setSpaces] = useState<{ id: number; name: string }[]>([]); + const [spaces, setSpaces] = useState<{ id: number; name: string }[]>([]); - const [showVariant, setShowVariant] = useState(0); + const [showVariant, setShowVariant] = useState(0); - useEffect(() => { - if (telegramUser) { - const linkTelegram = async () => { - const response = await linkTelegramToUser(telegramUser); + 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."); - } - }; + if (response.success) { + toast.success('Your telegram has been linked successfully.'); + } else { + toast.error('Failed to link telegram. Please try again.'); + } + }; - linkTelegram(); - } + linkTelegram(); + } - if (extensionInstalled) { - toast.success("Extension installed successfully"); - } + if (extensionInstalled) { + toast.success('Extension installed successfully'); + } - getSpaces().then((res) => { - if (res.success && res.data) { - setSpaces(res.data); - return; - } - // TODO: HANDLE ERROR - }); + 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]); + getSessionAuthToken().then((token) => { + if (typeof window === 'undefined') return; + window.postMessage({ token: token.data }, '*'); + }); + }, [telegramUser]); - return ( -
- {/* all content goes here */} - {/*
hi {firstTime ? 'first time' : ''}
*/} + return ( +
+ {/* all content goes here */} + {/*
hi {firstTime ? 'first time' : ''}
*/} - - Ask your{" "} - - supermemory - - + + Ask your{' '} + + supermemory + + -
- { - if (q.length === 0) { - toast.error("Query is required"); - return; - } +
+ { + if (q.length === 0) { + toast.error('Query is required'); + return; + } - const threadid = await createChatThread(q); + const threadid = await createChatThread(q); - if (!threadid.success || !threadid.data) { - toast.error("Failed to create chat thread"); - return; - } + 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} - /> -
+ push( + `/chat/${threadid.data}?spaces=${JSON.stringify(spaces)}&q=${q}`, + ); + }} + initialSpaces={spaces} + /> +
- -
- ); + +
+ ); } export default Page; diff --git a/package.json b/package.json index 5a11d364..5ef3aa3f 100644 --- a/package.json +++ b/package.json @@ -121,6 +121,6 @@ "es5-ext" ], "lint-staged": { - "**/*": "prettier --write --ignore-unknown" + "**/*": "prettier --write --ignore-unknown --allow-empty" } }