Se hicieron cabios en el diseño
This commit is contained in:
+15
-19
@@ -1,17 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import "./landing/globals.css";
|
||||
|
||||
import Header from "./landing/new_header";
|
||||
import Footer from "@/components/layout/footer";
|
||||
import LandingBody from "./landing/landing_body";
|
||||
import { useEffect, useState } from "react";
|
||||
import Dashboard from "./carga/page";
|
||||
import Consulta from "./visualizacion/page";
|
||||
import LoginPage from "@/containers/LoginPage";
|
||||
import { useSession } from "@/hooks/use-session";
|
||||
import FormularioCargaIndividual from "./alta/alta";
|
||||
import { getUserFromToken } from "@/components/Hook";
|
||||
import { useSession } from "@/hooks/use-session";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export type PageKey = "landing" | "login" | "carga" | "consulta" | "carga individual";
|
||||
|
||||
@@ -23,30 +21,28 @@ export interface HeaderItem {
|
||||
|
||||
const Home = () => {
|
||||
const [page, setPage] = useState<PageKey>("landing");
|
||||
const { loading, error, data } = useSession();
|
||||
const { data: user, loading } = useSession(); // El usuario tiene campos como tipo y email
|
||||
const [isCarga, setIsCarga] = useState("Carga");
|
||||
|
||||
useEffect(() => {
|
||||
if (user?.tipo === "LOAD") {
|
||||
setIsCarga("Carga");
|
||||
} else {
|
||||
setIsCarga("Descarga");
|
||||
}
|
||||
}, [user]);
|
||||
|
||||
const handleLogout = () => {
|
||||
localStorage.removeItem("token");
|
||||
location.reload();
|
||||
};
|
||||
|
||||
const [isCarga, setIsCarga] = useState<string>("Carga");
|
||||
|
||||
useEffect(() => {
|
||||
const user = getUserFromToken();
|
||||
if (user?.tipo === "LOAD") {
|
||||
setIsCarga("Carga");
|
||||
} else {
|
||||
setIsCarga("Descarga");
|
||||
}
|
||||
}, []);
|
||||
|
||||
const items: HeaderItem[] = data?.id
|
||||
const items: HeaderItem[] = user
|
||||
? [
|
||||
{ label: "Inicio", page: "landing" },
|
||||
{ label: "Consulta", page: "consulta" },
|
||||
{ label: isCarga, page: "carga" as PageKey },
|
||||
...(getUserFromToken()?.tipo === "LOAD"
|
||||
...(user.tipo === "LOAD"
|
||||
? [{ label: "Carga individual", page: "carga individual" as PageKey }]
|
||||
: []),
|
||||
{ label: "Cerrar sesión", onClick: handleLogout },
|
||||
@@ -66,7 +62,7 @@ const Home = () => {
|
||||
{page === "login" && <LoginPage />}
|
||||
{page === "consulta" && <Consulta />}
|
||||
{page === "carga" && <Dashboard />}
|
||||
{page === "carga individual" && getUserFromToken()?.tipo === "LOAD" && (
|
||||
{page === "carga individual" && user?.tipo === "LOAD" && (
|
||||
<FormularioCargaIndividual />
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user