mirror of
https://github.com/lemeow125/Borrowing-TrackerFrontend.git
synced 2024-11-17 06:19:27 +08:00
Added student type to component and page restrictions
This commit is contained in:
parent
fce4725ff9
commit
be6e1ba229
2 changed files with 18 additions and 0 deletions
|
@ -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 <></>;
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue