Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
| /* eslint-disable @typescript-eslint/no-explicit-any */ | |
| import type { Metadata, Viewport } from "next"; | |
| import { Inter, PT_Sans } from "next/font/google"; | |
| import { cookies } from "next/headers"; | |
| import TanstackProvider from "@/components/providers/tanstack-query-provider"; | |
| import "@/assets/globals.css"; | |
| import { Toaster } from "@/components/ui/sonner"; | |
| import MY_TOKEN_KEY from "@/lib/get-cookie-name"; | |
| import { apiServer } from "@/lib/api"; | |
| import AppContext from "@/components/contexts/app-context"; | |
| import Script from "next/script"; | |
| import IframeDetector from "@/components/iframe-detector"; | |
| const inter = Inter({ | |
| variable: "--font-inter-sans", | |
| subsets: ["latin"], | |
| }); | |
| const ptSans = PT_Sans({ | |
| variable: "--font-ptSans-mono", | |
| subsets: ["latin"], | |
| weight: ["400", "700"], | |
| }); | |
| export const metadata: Metadata = { | |
| title: "KAICoder | Future of Work", | |
| }; | |
| export const viewport: Viewport = { | |
| initialScale: 1, | |
| maximumScale: 1, | |
| themeColor: "#000000", | |
| }; | |
| async function getMe() { | |
| const cookieStore = await cookies(); | |
| const token = cookieStore.get(MY_TOKEN_KEY())?.value; | |
| if (!token) return { user: null, errCode: null }; | |
| try { | |
| const res = await apiServer.get("/me", { | |
| headers: { | |
| Authorization: `Bearer ${token}`, | |
| }, | |
| }); | |
| return { user: res.data.user, errCode: null }; | |
| } catch (err: any) { | |
| return { user: null, errCode: err.status }; | |
| } | |
| } | |
| // if domain isn't deepsite.hf.co or enzostvs-deepsite.hf.space redirect to deepsite.hf.co | |
| export default async function RootLayout({ | |
| children, | |
| }: Readonly<{ | |
| children: React.ReactNode; | |
| }>) { | |
| const data = await getMe(); | |
| return ( | |
| <html lang="en"> | |
| <Script | |
| defer | |
| data-domain="deepsite.hf.co" | |
| src="https://plausible.io/js/script.js" | |
| ></Script> | |
| <body | |
| className={`${inter.variable} ${ptSans.variable} antialiased bg-black dark h-[100dvh] overflow-hidden`} | |
| > | |
| <IframeDetector /> | |
| <Toaster richColors position="bottom-center" /> | |
| <TanstackProvider> | |
| <AppContext me={data}>{children}</AppContext> | |
| </TanstackProvider> | |
| </body> | |
| </html> | |
| ); | |
| } | |