mtg-lets-trade

Website/webapp to facilitate trading between players of Magic: The Gathering
git clone https://kevincorvisier.fr/git/mtg-lets-trade.git
Log | Files | Refs

ProtectedRoute.tsx (380B)


      1 import { Navigate, Outlet } from "react-router";
      2 
      3 type ProtectedRouteProps = {
      4 	children?: React.ReactNode,
      5 	isAllowed: boolean,
      6 	redirectPath?: string,
      7 };
      8 
      9 export default function ProtectedRoute({ children, isAllowed, redirectPath = "/" }: Readonly<ProtectedRouteProps>) {
     10 	if (!isAllowed) {
     11 		return <Navigate to={redirectPath} replace />;
     12 	}
     13 
     14 	return children || <Outlet />;
     15 };