2024-11-17 19:13:51 +01:00
|
|
|
import React from "react";
|
|
|
|
|
|
2024-11-03 21:12:40 +01:00
|
|
|
import {LayoutAdmin} from "@/components/layout";
|
2024-11-13 19:45:22 +01:00
|
|
|
import {currentUser} from "@/auth/current-user";
|
2024-11-09 21:38:18 +01:00
|
|
|
import {redirect} from "next/navigation";
|
2024-11-13 19:45:22 +01:00
|
|
|
import {prisma} from "@/prisma";
|
2024-11-03 21:12:40 +01:00
|
|
|
|
2024-11-09 21:38:18 +01:00
|
|
|
export default async function Layout({children}: { children: React.ReactNode }) {
|
|
|
|
|
|
|
|
|
|
const user = await currentUser()
|
2024-11-16 17:05:55 +01:00
|
|
|
if(user){
|
2024-11-16 22:00:22 +01:00
|
|
|
const userInfo = await prisma.user.findUnique({
|
|
|
|
|
where: {
|
|
|
|
|
email: user?.email
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-11-17 16:31:34 +01:00
|
|
|
if(userInfo && userInfo.authMethod){
|
2025-01-01 20:00:11 +01:00
|
|
|
redirect('/')
|
|
|
|
|
// redirect('/dashboard')
|
2024-11-16 22:00:22 +01:00
|
|
|
}
|
2024-11-09 21:38:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2024-11-03 21:12:40 +01:00
|
|
|
<LayoutAdmin>
|
2024-11-09 21:38:18 +01:00
|
|
|
<div
|
|
|
|
|
className="w-full h-full grid "
|
|
|
|
|
>
|
2024-11-03 21:12:40 +01:00
|
|
|
<div className="flex items-center justify-center py-12">
|
|
|
|
|
{children}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</LayoutAdmin>
|
|
|
|
|
)
|
|
|
|
|
}
|