feat(sidebar): enhance sidebar with additional navigation items and translations
feat(translations): update English and Spanish message files with new keys refactor(layout): simplify layout component by removing loading state logic refactor(page.server): adjust authentication flow to return public page for unauthenticated users
This commit is contained in:
@@ -1,4 +1,36 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"hello_world": "Hello, {name} from en!"
|
||||
"hello_world": "Hello, {name} from en!",
|
||||
"sidebar": {
|
||||
"catalogos_fijos": "Fixed Catalogs",
|
||||
"codigos_pedimento_regimen": "Pedimento and Regime Codes",
|
||||
"contenedores": "Containers",
|
||||
"paises": "Countries",
|
||||
"tipos_moneda": "Currency Types",
|
||||
"secciones_aduanas": "Customs Sections",
|
||||
"recintos": "Customs Warehouses",
|
||||
"incoterms": "Incoterms",
|
||||
"tipos_factura": "Invoice Types",
|
||||
"tipos_material": "Material Types",
|
||||
"metodos_pago": "Payment Methods",
|
||||
"codigos_pedimento": "Pedimento Codes",
|
||||
"regimenes_pedimentos": "Pedimento Regimes",
|
||||
"sectores": "Sectors",
|
||||
"estados": "States",
|
||||
"metodos_transporte": "Transportation Modes",
|
||||
"tipos_transporte": "Transportation Types",
|
||||
"metodos_valoracion": "Valuation Methods",
|
||||
"inventarios": "Inventories",
|
||||
"gestionar_inventarios": "Manage Inventories",
|
||||
"reportes": "Reports",
|
||||
"pedimentos": "Pedimentos",
|
||||
"nuevo_pedimento": "New Pedimento",
|
||||
"consultar": "Search",
|
||||
"historial": "History",
|
||||
"configuracion": "Settings",
|
||||
"general": "General",
|
||||
"licencia": "License",
|
||||
"usuarios": "Users",
|
||||
"ayuda": "Help"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,36 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"hello_world": "Hello, {name} from es!"
|
||||
"hello_world": "Hello, {name} from es!",
|
||||
"sidebar": {
|
||||
"catalogos_fijos": "Catálogos Fijos",
|
||||
"codigos_pedimento_regimen": "Códigos de Pedimento y Régimen",
|
||||
"contenedores": "Contenedores",
|
||||
"paises": "Países",
|
||||
"tipos_moneda": "Tipos de moneda",
|
||||
"secciones_aduanas": "Secciones de aduanas",
|
||||
"recintos": "Recintos",
|
||||
"incoterms": "Incoterms",
|
||||
"tipos_factura": "Tipos de factura",
|
||||
"tipos_material": "Tipos de material",
|
||||
"metodos_pago": "Métodos de pago",
|
||||
"codigos_pedimento": "Códigos de pedimento",
|
||||
"regimenes_pedimentos": "Regímenes de pedimentos",
|
||||
"sectores": "Sectores",
|
||||
"estados": "Estados",
|
||||
"metodos_transporte": "Métodos de transporte",
|
||||
"tipos_transporte": "Tipos de transporte",
|
||||
"metodos_valoracion": "Métodos de valoración",
|
||||
"inventarios": "Inventarios",
|
||||
"gestionar_inventarios": "Gestionar Inventarios",
|
||||
"reportes": "Reportes",
|
||||
"pedimentos": "Pedimentos",
|
||||
"nuevo_pedimento": "Nuevo Pedimento",
|
||||
"consultar": "Consultar",
|
||||
"historial": "Historial",
|
||||
"configuracion": "Configuración",
|
||||
"general": "General",
|
||||
"licencia": "Licencia",
|
||||
"usuarios": "Usuarios",
|
||||
"ayuda": "Ayuda"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from "svelte";
|
||||
import { sidebarData } from "$lib/components/sidebar/modules";
|
||||
import { getSidebarData } from "$lib/components/sidebar/modules";
|
||||
import NavMain from "./nav-main.svelte";
|
||||
import NavProjects from "./nav-projects.svelte";
|
||||
import NavUser from "./nav-user.svelte";
|
||||
@@ -17,6 +17,9 @@
|
||||
// Obtener datos del usuario desde el contexto (viene de Keycloak vía +layout.server.ts)
|
||||
const userData = getContext<any>('user');
|
||||
|
||||
// Obtener datos del sidebar con traducciones
|
||||
const sidebarData = getSidebarData();
|
||||
|
||||
// Combinar los datos estáticos del sidebar con los datos del usuario de Keycloak
|
||||
const data = $derived({
|
||||
...sidebarData,
|
||||
|
||||
@@ -8,6 +8,7 @@ import GalleryVerticalEndIcon from "@lucide/svelte/icons/gallery-vertical-end";
|
||||
import MapIcon from "@lucide/svelte/icons/map";
|
||||
import Settings2Icon from "@lucide/svelte/icons/settings-2";
|
||||
import SquareTerminalIcon from "@lucide/svelte/icons/square-terminal";
|
||||
import * as m from "$lib/paraglide/messages.js";
|
||||
|
||||
export interface NavItem {
|
||||
title: string;
|
||||
@@ -47,101 +48,166 @@ export interface SidebarData {
|
||||
projects: Project[];
|
||||
}
|
||||
|
||||
// Datos estáticos del sidebar (los datos de usuario vienen de Keycloak)
|
||||
export const sidebarData: SidebarData = {
|
||||
user: {
|
||||
name: "", // Se llena dinámicamente desde Keycloak
|
||||
email: "", // Se llena dinámicamente desde Keycloak
|
||||
avatar: "/avatars/default.jpg", // Avatar por defecto
|
||||
},
|
||||
teams: [
|
||||
{
|
||||
name: "Anexo76",
|
||||
logo: GalleryVerticalEndIcon,
|
||||
plan: "Enterprise",
|
||||
// Función que retorna los datos del sidebar con traducciones
|
||||
export function getSidebarData(): SidebarData {
|
||||
return {
|
||||
user: {
|
||||
name: "", // Se llena dinámicamente desde Keycloak
|
||||
email: "", // Se llena dinámicamente desde Keycloak
|
||||
avatar: "/avatars/default.jpg", // Avatar por defecto
|
||||
},
|
||||
],
|
||||
navMain: [
|
||||
{
|
||||
title: "Catalogos Fijos",
|
||||
url: "/dashboard",
|
||||
icon: SquareTerminalIcon,
|
||||
items: [
|
||||
{
|
||||
title: "Codigos de Pedimento y Régimen",
|
||||
url: "/dashboard/reference_data/code_pedimento_regimens",
|
||||
},
|
||||
{
|
||||
title: "Contenedores",
|
||||
url: "/dashboard/reference_data/containers",
|
||||
},
|
||||
],
|
||||
isActive: true,
|
||||
},
|
||||
{
|
||||
title: "Inventarios",
|
||||
url: "#",
|
||||
icon: BotIcon,
|
||||
items: [
|
||||
{
|
||||
title: "Gestionar Inventarios",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: "Reportes",
|
||||
url: "#",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Pedimentos",
|
||||
url: "#",
|
||||
icon: BookOpenIcon,
|
||||
items: [
|
||||
{
|
||||
title: "Nuevo Pedimento",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: "Consultar",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: "Historial",
|
||||
url: "#",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Configuración",
|
||||
url: "#",
|
||||
icon: Settings2Icon,
|
||||
items: [
|
||||
{
|
||||
title: "General",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: "Licencia",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: "Usuarios",
|
||||
url: "#",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
projects: [
|
||||
{
|
||||
name: "Reportes",
|
||||
url: "#",
|
||||
icon: ChartPieIcon,
|
||||
},
|
||||
{
|
||||
name: "Ayuda",
|
||||
url: "#",
|
||||
icon: FrameIcon,
|
||||
},
|
||||
],
|
||||
};
|
||||
teams: [
|
||||
{
|
||||
name: "Anexo76",
|
||||
logo: GalleryVerticalEndIcon,
|
||||
plan: "Enterprise",
|
||||
},
|
||||
],
|
||||
navMain: [
|
||||
{
|
||||
title: m["sidebar.catalogos_fijos"](),
|
||||
url: "/dashboard",
|
||||
icon: SquareTerminalIcon,
|
||||
items: [
|
||||
{
|
||||
title: m["sidebar.codigos_pedimento_regimen"](),
|
||||
url: "/dashboard/reference_data/code_pedimento_regimens",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.contenedores"](),
|
||||
url: "/dashboard/reference_data/containers",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.paises"](),
|
||||
url: "/dashboard/reference_data/countries",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.tipos_moneda"](),
|
||||
url: "/dashboard/reference_data/currency_types",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.secciones_aduanas"](),
|
||||
url: "/dashboard/reference_data/customs_sections",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.recintos"](),
|
||||
url: "/dashboard/reference_data/customs_warehouses",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.incoterms"](),
|
||||
url: "/dashboard/reference_data/incoterms",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.tipos_factura"](),
|
||||
url: "/dashboard/reference_data/invoice_types",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.tipos_material"](),
|
||||
url: "/dashboard/reference_data/material_types",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.metodos_pago"](),
|
||||
url: "/dashboard/reference_data/payment_methods",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.codigos_pedimento"](),
|
||||
url: "/dashboard/reference_data/pedimento_codes",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.regimenes_pedimentos"](),
|
||||
url: "/dashboard/reference_data/pedimento_regimens",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.sectores"](),
|
||||
url: "/dashboard/reference_data/sectors",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.estados"](),
|
||||
url: "/dashboard/reference_data/states",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.metodos_transporte"](),
|
||||
url: "/dashboard/reference_data/transportation_modes",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.tipos_transporte"](),
|
||||
url: "/dashboard/reference_data/transportation_types",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.metodos_valoracion"](),
|
||||
url: "/dashboard/reference_data/valuation_methods",
|
||||
},
|
||||
],
|
||||
isActive: true,
|
||||
},
|
||||
{
|
||||
title: m["sidebar.inventarios"](),
|
||||
url: "#",
|
||||
icon: BotIcon,
|
||||
items: [
|
||||
{
|
||||
title: m["sidebar.gestionar_inventarios"](),
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.reportes"](),
|
||||
url: "#",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: m["sidebar.pedimentos"](),
|
||||
url: "#",
|
||||
icon: BookOpenIcon,
|
||||
items: [
|
||||
{
|
||||
title: m["sidebar.nuevo_pedimento"](),
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.consultar"](),
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.historial"](),
|
||||
url: "#",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: m["sidebar.configuracion"](),
|
||||
url: "#",
|
||||
icon: Settings2Icon,
|
||||
items: [
|
||||
{
|
||||
title: m["sidebar.general"](),
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.licencia"](),
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: m["sidebar.usuarios"](),
|
||||
url: "#",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
projects: [
|
||||
{
|
||||
name: m["sidebar.reportes"](),
|
||||
url: "#",
|
||||
icon: ChartPieIcon,
|
||||
},
|
||||
{
|
||||
name: m["sidebar.ayuda"](),
|
||||
url: "#",
|
||||
icon: FrameIcon,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
// Exportar también como constante para compatibilidad (deprecado)
|
||||
export const sidebarData: SidebarData = getSidebarData();
|
||||
|
||||
@@ -1,30 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import '../app.css';
|
||||
import favicon from '$lib/assets/favicon.svg';
|
||||
|
||||
let { children } = $props();
|
||||
let initialized = $state(false);
|
||||
|
||||
onMount(async () => {
|
||||
// Usar auth-custom que es instantáneo (sin peticiones de red)
|
||||
initialized = true;
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<link rel="icon" href={favicon} />
|
||||
</svelte:head>
|
||||
|
||||
{#if initialized}
|
||||
{@render children?.()}
|
||||
{:else}
|
||||
<div class="flex min-h-screen items-center justify-center bg-gray-50">
|
||||
<div class="text-center">
|
||||
<div
|
||||
class="mb-4 inline-block h-12 w-12 animate-spin rounded-full border-4 border-solid border-blue-600 border-r-transparent"
|
||||
></div>
|
||||
<p class="text-gray-600">Cargando Anexo76...</p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{@render children?.()}
|
||||
|
||||
@@ -9,6 +9,8 @@ export const load: PageServerLoad = async ({ cookies }) => {
|
||||
throw redirect(303, '/dashboard');
|
||||
}
|
||||
|
||||
// Si no está autenticado, redirigir al login
|
||||
throw redirect(303, '/login');
|
||||
// Si no está autenticado, mostrar la página principal pública
|
||||
return {
|
||||
isAuthenticated: false
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user