From 6379bdf52f4842ad0742d035b40d0d6c35140661 Mon Sep 17 00:00:00 2001 From: Sir Blob <76974209+GamerBoss101@users.noreply.github.com> Date: Sun, 26 Jan 2025 03:15:22 -0500 Subject: [PATCH] somemore logic --- src/app/(panels)/suite/layout.jsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/(panels)/suite/layout.jsx b/src/app/(panels)/suite/layout.jsx index 29948bc..7913eb4 100644 --- a/src/app/(panels)/suite/layout.jsx +++ b/src/app/(panels)/suite/layout.jsx @@ -23,16 +23,19 @@ export default function RootLayout({ if (userData) { console.log(userData); - if (userData.role === "caregiver" && router.pathname.startsWith("/suite/patient/")) { + // make sure user only has access to one suite depending on their role + // if a user has a role of "caregiver" they should only have access to /suite/doctor/* + + if (userData.role === "patient" && !router.pathname.startsWith("/suite/patient")) { + router.push("/suite/patient/dashboard"); + } else if (userData.role === "doctor" && !router.pathname.startsWith("/suite/doctor")) { router.push("/suite/doctor/dashboard"); } - if (userData.role === "patient" && router.pathname.startsWith("/suite/doctor/")) { - router.push("/suite/patient/dashboard"); - } + } else { + router.push("/"); } - return (
{children}