import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import AccessForbidden from "../components/pages/StatusPages/403"; import { Button, Page } from "../components/ui"; import { useAuthContext } from "../context/AuthContext"; import API from "./API"; import { ProtectPortal } from "./types"; const Protect: ProtectPortal = ({ children, redirect = '', accessRules = null }) => { const { user, token } = useAuthContext(); const navigate = useNavigate(); if (!user || !token) { return ( <>

Hi there! You don't look too familiar.

To view the content on this page, please log in below:

) } if (accessRules !== null) { if (accessRules.mustBeRecipinAdmin && !(user?.isadmin)) { return ( <>

This page requires administrator access.

If you believe you are receiving this message in error, please contact Recipin support.

) } } return ( { children } ) } export default Protect;