somemore logic
This commit is contained in:
@@ -23,16 +23,19 @@ export default function RootLayout({
|
|||||||
|
|
||||||
if (userData) {
|
if (userData) {
|
||||||
console.log(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");
|
router.push("/suite/doctor/dashboard");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userData.role === "patient" && router.pathname.startsWith("/suite/doctor/")) {
|
} else {
|
||||||
router.push("/suite/patient/dashboard");
|
router.push("/");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Reference in New Issue
Block a user