Phase 2
Base app architecture:
Route groups for customer, staff and owner.
* Reusable design system with around 20 UI components.
* Complete Prisma schema.
* Authentication with email/password and Google.
* Role and permission model.
* Protected routes.
* Clean separation between features, services, components and shared utilities.
This commit is contained in:
201 files changed
+31984
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { auth } from "@/auth";
|
||||
import { BottomNav } from "@/components/navigation/bottom-nav";
|
||||
import { STAFF_NAV_ITEMS } from "@/lib/navigation/staff-nav-items";
|
||||
import { prisma } from "@/lib/db/prisma";
|
||||
|
||||
export default async function StaffLayout({ children }: { children: React.ReactNode }) {
|
||||
const session = await auth();
|
||||
if (!session?.user) {
|
||||
redirect("/sign-in?callbackUrl=/staff");
|
||||
}
|
||||
|
||||
// Real role gating, not just "is signed in" — a registered customer with
|
||||
// no StaffProfile is bounced back to their own home rather than seeing
|
||||
// an empty staff shell. See docs/implementation-plan.md §3 (role
|
||||
// conflicts) and §11 (permission enforcement).
|
||||
const staffProfile = await prisma.staffProfile.findUnique({ where: { userId: session.user.id } });
|
||||
if (!staffProfile) {
|
||||
redirect("/home");
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-stone pb-24">
|
||||
{children}
|
||||
<BottomNav items={STAFF_NAV_ITEMS} variant="staff" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user