Added student type to component and page restrictions

This commit is contained in:
Keannu Bernasol 2023-12-14 18:08:27 +08:00
parent fce4725ff9
commit be6e1ba229
2 changed files with 18 additions and 0 deletions

View file

@ -33,6 +33,10 @@ export default function RestrictedComponent(props: props) {
if (user.data && user.data.is_technician) {
return <>{props.children}</>;
}
} else if (props.allow_only === "Student") {
if (user.data && !user.data.is_technician && !user.data.is_teacher) {
return <>{props.children}</>;
}
}
return <></>;
}

View file

@ -39,6 +39,20 @@ export default function RestrictedPage(props: props) {
theme: "light",
});
}
} else if (props.allow_only == "Student") {
if (user.data && (user.data.is_technician || user.data.is_teacher)) {
navigate("/");
toast("You are not a student!", {
position: "bottom-center",
autoClose: 2000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
theme: "light",
});
}
}
}, [navigate, props.allow_only, user.data]);