completionId: cgen-09daffde5f524ffd87bc71303ec04f5a
cgen-09daffde5f524ffd87bc71303ec04f5a
This commit is contained in:
parent
a51bf07e17
commit
7f92392a1f
1 changed files with 10 additions and 0 deletions
|
|
@ -18,14 +18,24 @@ import {
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useEffect, useState, useRef } from "react";
|
import { useEffect, useState, useRef } from "react";
|
||||||
|
import { useAuth } from "@/contexts/AuthContext";
|
||||||
import LoadingScreen from "@/components/LoadingScreen";
|
import LoadingScreen from "@/components/LoadingScreen";
|
||||||
import { aethexToast } from "@/lib/aethex-toast";
|
import { aethexToast } from "@/lib/aethex-toast";
|
||||||
|
|
||||||
export default function Staff() {
|
export default function Staff() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { user, loading } = useAuth();
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const toastShownRef = useRef(false);
|
const toastShownRef = useRef(false);
|
||||||
|
|
||||||
|
// Redirect unauthenticated users to login
|
||||||
|
useEffect(() => {
|
||||||
|
if (!loading && !user) {
|
||||||
|
navigate("/staff/login", { replace: true });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}, [user, loading, navigate]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue