From e15ef3edb50630319b83374c56d896ca02812c32 Mon Sep 17 00:00:00 2001 From: Gabo Esquivel Date: Mon, 8 Apr 2024 10:47:41 -0600 Subject: [PATCH] chore: disable getUserProfile --- apps/masterbots.ai/app/layout.tsx | 11 +++++- .../services/supabase/supa-server.service.ts | 37 ++++++++++--------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/apps/masterbots.ai/app/layout.tsx b/apps/masterbots.ai/app/layout.tsx index e3441711..6040683b 100644 --- a/apps/masterbots.ai/app/layout.tsx +++ b/apps/masterbots.ai/app/layout.tsx @@ -9,9 +9,18 @@ import { Providers } from '@/components/layout/providers' import { cn } from '@/lib/utils' import { GlobalStoreProvider } from '@/hooks/use-global-store' -export default async function RootLayout({ children }: RootLayoutProps) { +async function getCookieData(): Promise<{ hasuraJwt; userProfile }> { const hasuraJwt = cookies().get('hasuraJwt')?.value || '' const userProfile = cookies().get('userProfile')?.value || null + return new Promise(resolve => + setTimeout(() => { + resolve({ hasuraJwt, userProfile }) + }, 1000) + ) +} + +export default async function RootLayout({ children }: RootLayoutProps) { + const { hasuraJwt, userProfile } = await getCookieData() return ( diff --git a/apps/masterbots.ai/services/supabase/supa-server.service.ts b/apps/masterbots.ai/services/supabase/supa-server.service.ts index 4c61d863..b154df97 100644 --- a/apps/masterbots.ai/services/supabase/supa-server.service.ts +++ b/apps/masterbots.ai/services/supabase/supa-server.service.ts @@ -4,26 +4,27 @@ import { createSupabaseServerClient } from './supa-server-client' export async function getUserProfile(): Promise { try { - const supabase = await createSupabaseServerClient() - const { - data: { user } - } = await supabase.auth.getUser() - if (!user || !user.email) throw new Error('user not found') + return null + // const supabase = await createSupabaseServerClient() + // const { + // data: { user } + // } = await supabase.auth.getUser() + // if (!user || !user.email) throw new Error('user not found') - // TODO: use supabase - const userProfile = await getUser({ - email: user.email, - adminSecret: process.env.HASURA_GRAPHQL_ADMIN_SECRET || '' - }) + // // TODO: use supabase + // const userProfile = await getUser({ + // email: user.email, + // adminSecret: process.env.HASURA_GRAPHQL_ADMIN_SECRET || '' + // }) - if (!userProfile) throw new Error('user not found') - return { - userId: userProfile.userId, - username: userProfile.username, - name: '', - email: userProfile.email, - image: userProfile.profilePicture || '' - } + // if (!userProfile) throw new Error('user not found') + // return { + // userId: userProfile.userId, + // username: userProfile.username, + // name: '', + // email: userProfile.email, + // image: userProfile.profilePicture || '' + // } } catch (error) { console.log('GET USER PROFILE ERROR', error) return null