Initial commit v1.1
This commit is contained in:
+8
-12
@@ -1,23 +1,19 @@
|
||||
import { redirect } from 'next/navigation'
|
||||
import { createClient } from '@/lib/supabase/server'
|
||||
import { auth } from '@/lib/auth'
|
||||
import { headers } from 'next/headers'
|
||||
import { BottomNav } from '@/components/bottom-nav'
|
||||
import { isAdminEmail } from '@/lib/admin'
|
||||
|
||||
export default async function AppLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const supabase = await createClient()
|
||||
const {
|
||||
data: { user },
|
||||
} = await supabase.auth.getUser()
|
||||
export default async function AppLayout({ children }: { children: React.ReactNode }) {
|
||||
const session = await auth.api.getSession({ headers: await headers() })
|
||||
if (!session) redirect('/login')
|
||||
|
||||
if (!user) redirect('/login')
|
||||
const isAdmin = isAdminEmail(session.user.email)
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen flex-col">
|
||||
<main className="flex-1 pb-20">{children}</main>
|
||||
<BottomNav />
|
||||
<BottomNav isAdmin={isAdmin} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user