databag/net/web/src/Home/Home.jsx
2022-04-27 10:33:51 -07:00

27 lines
607 B
JavaScript

import React, { useContext, useEffect } from 'react'
import { useNavigate } from "react-router-dom";
import { AppContext } from 'context/AppContext';
export function Home() {
const navigate = useNavigate();
const app = useContext(AppContext);
useEffect(() => {
if (app?.state) {
if (app.state.access == null) {
navigate('/login')
}
else if (app.state.access === 'user') {
navigate('/user')
}
else if (app.state.access === 'admin') {
navigate('/admin')
}
}
}, [app])
return <></>
}