From f983a7e0a91b1c4e4d43a371f3236f6843e01b43 Mon Sep 17 00:00:00 2001 From: Thaarak <91105460+Thaarak@users.noreply.github.com> Date: Tue, 3 Feb 2026 18:14:51 -0800 Subject: [PATCH] Add role-based UI visibility with mock auth system. Buttons on the home page conditionally render based on the currentUserRole constant (admin/user/guest) --- app/page.tsx | 27 ++++++++++++++++++++++++++- lib/mock-auth.ts | 12 ++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 lib/mock-auth.ts diff --git a/app/page.tsx b/app/page.tsx index 7e27f92..86a005c 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,5 +1,30 @@ import PublicLayout from "@/components/layout/PublicLayout"; +import { currentUserRole, isAdmin, isAuthenticated } from "@/lib/mock-auth"; export default function Page() { - return Home page content; + return ( + +
+

Home Page

+

+ Current role: {currentUserRole} +

+
+ {isAuthenticated() && ( + + )} + {isAdmin() && ( + + )} + +
+
+
+ ); } diff --git a/lib/mock-auth.ts b/lib/mock-auth.ts new file mode 100644 index 0000000..6c5f9d4 --- /dev/null +++ b/lib/mock-auth.ts @@ -0,0 +1,12 @@ +export type Role = "admin" | "user" | "guest"; + +// Change this value to test different UI states +export const currentUserRole: Role = "guest"; + +export function isAdmin(): boolean { + return currentUserRole === "admin"; +} + +export function isAuthenticated(): boolean { + return currentUserRole !== "guest"; +}