created different file for the routes, and changes all the import
This commit is contained in:
parent
73b31778db
commit
45444ba8bd
@ -20,6 +20,7 @@ import {
|
||||
XCircle,
|
||||
Wallet,
|
||||
} from "lucide-react";
|
||||
import { ROUTES } from "@/lib/routes";
|
||||
|
||||
export default function EmployeePage() {
|
||||
const { user, logout, isLoading } = useAuth();
|
||||
@ -41,8 +42,10 @@ export default function EmployeePage() {
|
||||
}, [user]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLoading && !user) router.replace("/");
|
||||
else if (!isLoading && user?.role === "manager") router.replace("/manager");
|
||||
// if (!isLoading && !user) router.replace("/");
|
||||
// else if (!isLoading && user?.role === "manager") router.replace("/manager");
|
||||
if (!isLoading && !user) router.replace(ROUTES.home);
|
||||
else if (!isLoading && user?.role === "manager") router.replace(ROUTES.manager);
|
||||
else if (!isLoading && user) loadData();
|
||||
}, [user, isLoading, router, loadData]);
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ import {
|
||||
XCircle,
|
||||
LayoutDashboard,
|
||||
} from "lucide-react";
|
||||
import { ROUTES } from "@/lib/routes";
|
||||
|
||||
type FilterStatus = "All" | "Pending" | "Approved" | "Rejected";
|
||||
|
||||
@ -32,8 +33,10 @@ export default function ManagerPage() {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLoading && !user) router.replace("/");
|
||||
else if (!isLoading && user?.role === "employee") router.replace("/employee");
|
||||
// if (!isLoading && !user) router.replace("/");
|
||||
// else if (!isLoading && user?.role === "employee") router.replace("/employee");
|
||||
if (!isLoading && !user) router.replace(ROUTES.home);
|
||||
else if (!isLoading && user?.role === "employee") router.replace(ROUTES.employee);
|
||||
else if (!isLoading && user) loadData();
|
||||
}, [user, isLoading, router, loadData]);
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import { Label } from "@/components/ui/label";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { CalendarDays, AlertCircle, Loader2 } from "lucide-react";
|
||||
import { ROUTES } from "@/lib/routes";
|
||||
|
||||
export default function LoginPage() {
|
||||
const { login, user, isLoading } = useAuth();
|
||||
@ -20,7 +21,8 @@ export default function LoginPage() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLoading && user) {
|
||||
router.replace(user.role === "manager" ? "/manager" : "/employee");
|
||||
// router.replace(user.role === "manager" ? "/manager" : "/employee");
|
||||
router.replace(user.role === "manager" ? ROUTES.manager : ROUTES.employee);
|
||||
}
|
||||
}, [user, isLoading, router]);
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
"use client";
|
||||
import { ROUTES } from "@/lib/routes";
|
||||
|
||||
import React, {
|
||||
createContext,
|
||||
@ -61,7 +62,8 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
const logout = () => {
|
||||
setUser(null);
|
||||
localStorage.removeItem("lms_user");
|
||||
router.push("/");
|
||||
// router.push("/");
|
||||
router.push(ROUTES.home);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user