Task: Add auth context and provider and add routes and route wrapper and more configs and utils

This commit is contained in:
2021-06-12 19:22:48 +07:00
parent 26451a4291
commit 85c81f5e2a
16 changed files with 289 additions and 50 deletions

21
src/routes/AuthRoute.tsx Normal file
View File

@@ -0,0 +1,21 @@
import { useAuthContext } from '@/context/AuthContext'
import AccessDenied from '@/pages/Error/403'
import { Route } from 'react-router-dom'
const AuthRoute = (props: any) => {
const { component, ...rest } = props
const { isLogin } = useAuthContext()
if (!isLogin()) {
return (<AccessDenied />)
}
return (
<Route
{...rest}
render={component}
/>
)
}
export default AuthRoute