blob: 8391f9078117562ed8ea89790f35920413330f65 [file] [log] [blame]
import { Navigate, Outlet } from 'react-router-dom'
import React from 'react'
interface PrivateRouteProps {
isAllowed: boolean
redirectPath?: string
children?: React.ReactNode
}
const PrivateRoute = ({
isAllowed,
redirectPath = '/login',
children
}: PrivateRouteProps) => {
if (!isAllowed) {
return <Navigate to={redirectPath} replace />
}
return children ? children : <Outlet />
}
export default PrivateRoute