2024-11-10 23:12:38 +01:00
|
|
|
import React from "react";
|
|
|
|
|
import {redirect} from "next/navigation";
|
|
|
|
|
|
|
|
|
|
import {SidebarInset, SidebarProvider} from "@/components/ui/sidebar"
|
2024-11-10 09:34:27 +01:00
|
|
|
import {AppSidebar} from "@/components/wrappers/Dashboard/SideBar/app-sidebar";
|
2024-11-09 21:38:18 +01:00
|
|
|
import {currentUser} from "@/auth/current-user";
|
2024-11-10 11:01:59 +01:00
|
|
|
import {Header} from "@/features/layout/Header";
|
2024-11-13 19:45:22 +01:00
|
|
|
import {prisma} from "@/prisma";
|
2024-11-09 21:38:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
export default async function Layout({children}: { children: React.ReactNode }) {
|
|
|
|
|
|
|
|
|
|
const user = await currentUser()
|
2024-11-13 19:45:22 +01:00
|
|
|
|
|
|
|
|
const userInfo = await prisma.user.findUnique({
|
|
|
|
|
where: {
|
|
|
|
|
email: user.email
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (!userInfo) redirect('/login')
|
2024-11-10 23:12:38 +01:00
|
|
|
|
2024-11-03 15:29:30 +01:00
|
|
|
return (
|
|
|
|
|
<SidebarProvider>
|
2024-11-10 23:12:38 +01:00
|
|
|
<AppSidebar/>
|
2024-11-10 11:01:59 +01:00
|
|
|
<SidebarInset>
|
|
|
|
|
<Header/>
|
2024-11-11 19:12:34 +01:00
|
|
|
<main className="h-full">
|
2024-11-10 23:12:38 +01:00
|
|
|
{children}
|
|
|
|
|
</main>
|
2024-11-10 11:01:59 +01:00
|
|
|
</SidebarInset>
|
2024-11-03 15:29:30 +01:00
|
|
|
</SidebarProvider>
|
|
|
|
|
)
|
|
|
|
|
}
|