diff --git a/src/Components/RestrictedComponent/RestrictedComponent.tsx b/src/Components/RestrictedComponent/RestrictedComponent.tsx index 8539599..8517d54 100644 --- a/src/Components/RestrictedComponent/RestrictedComponent.tsx +++ b/src/Components/RestrictedComponent/RestrictedComponent.tsx @@ -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 <>; } diff --git a/src/Components/RestrictedPage/RestrictedPage.tsx b/src/Components/RestrictedPage/RestrictedPage.tsx index f8cf63f..8e9f6a0 100644 --- a/src/Components/RestrictedPage/RestrictedPage.tsx +++ b/src/Components/RestrictedPage/RestrictedPage.tsx @@ -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]);