databag/net/web/src/Home/Home.jsx

27 lines
607 B
React
Raw Normal View History

2022-03-16 18:43:27 +00:00
import React, { useContext, useEffect } from 'react'
2022-03-16 07:21:53 +00:00
import { useNavigate } from "react-router-dom";
2022-04-26 05:25:03 +00:00
import { AppContext } from 'context/AppContext';
2022-03-16 07:21:53 +00:00
export function Home() {
const navigate = useNavigate();
const app = useContext(AppContext);
useEffect(() => {
2022-04-27 06:48:56 +00:00
if (app?.state) {
if (app.state.access == null) {
2022-03-16 07:21:53 +00:00
navigate('/login')
}
else if (app.state.access === 'user') {
navigate('/user')
}
else if (app.state.access === 'admin') {
navigate('/admin')
}
}
2022-04-27 17:33:51 +00:00
}, [app])
2022-03-16 07:21:53 +00:00
return <></>
}