Full project added

This commit is contained in:
Marcelo Dares
2025-12-17 20:24:06 +00:00
parent fc2e4fd15a
commit 0e9b2dd72d
36 changed files with 2050 additions and 84 deletions

33
app/(app)/layout.tsx Normal file
View File

@@ -0,0 +1,33 @@
import { Sidebar } from "@/components/layout/Sidebar";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import { prisma } from "@/lib/prisma";
const COOKIE_NAME = "mis_session";
export default async function AppLayout({ children }: { children: React.ReactNode }) {
const sessionId = (await cookies()).get(COOKIE_NAME)?.value;
if (!sessionId) redirect("/login?next=/machines");
// validate session in DB (dont trust cookie existence)
const session = await prisma.session.findFirst({
where: {
id: sessionId,
revokedAt: null,
expiresAt: { gt: new Date() },
},
include: { user: true, org: true },
});
if (!session) redirect("/login?next=/machines");
return (
<div className="min-h-screen bg-black text-white">
<div className="flex">
<Sidebar />
<main className="flex-1 min-h-screen">{children}</main>
</div>
</div>
);
}