mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 19:49:16 +00:00
28 lines
686 B
React
28 lines
686 B
React
|
import React, { useContext, useState, useEffect, useRef } from 'react'
|
||
|
import { useNavigate } from "react-router-dom";
|
||
|
import { HashRouter as Router, Routes, Route } from "react-router-dom";
|
||
|
import { AppContext } from '../AppContext/AppContext';
|
||
|
|
||
|
export function Home() {
|
||
|
|
||
|
const navigate = useNavigate();
|
||
|
const app = useContext(AppContext);
|
||
|
|
||
|
useEffect(() => {
|
||
|
if (app) {
|
||
|
if (app.state == null) {
|
||
|
navigate('/login')
|
||
|
}
|
||
|
else if (app.state.access === 'user') {
|
||
|
navigate('/user')
|
||
|
}
|
||
|
else if (app.state.access === 'admin') {
|
||
|
navigate('/admin')
|
||
|
}
|
||
|
}
|
||
|
}, [])
|
||
|
|
||
|
return <></>
|
||
|
}
|
||
|
|