Version con fallas

This commit is contained in:
2026-02-12 14:00:04 -07:00
parent 96cd09476c
commit 2033a35a2b
44 changed files with 196 additions and 3723 deletions

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { auth } from '$lib/stores/auth.js';
;
export let toggleSidebar: () => void;

View File

@@ -1,6 +1,7 @@
<script>
import { createEventDispatcher, onMount, onDestroy } from 'svelte';
export let open = false;
export let title = '';
const dispatch = createEventDispatcher();
@@ -10,7 +11,7 @@
}
function handleKeydown(e) {
if (e.key === 'Escape') {
if (e.key === 'Escape' && open) {
close();
}
}
@@ -18,7 +19,8 @@
<svelte:window on:keydown={handleKeydown}/>
<div class="fixed inset-0 z-50 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">
{#if open}
<div class="fixed inset-0 z-50 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">
<div class="flex items-end justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity bg-gray-500 bg-opacity-75" aria-hidden="true" on:click={close}></div>
@@ -36,11 +38,7 @@
</div>
</div>
</div>
{#if $$slots.footer}
<div class="mt-5 sm:mt-6 sm:flex sm:flex-row-reverse">
<slot name="footer" />
</div>
{/if}
</div>
</div>
</div>
{/if}

View File

@@ -62,16 +62,7 @@
name: 'Auditoría',
href: '/audit',
icon: 'M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z'
}
);
}
return baseNavigation;
}
function isCurrentPage(href: string) {
return $page.url.pathname === href || ($page.url.pathname.startsWith(href) && href !== '/');
}
}
</script>
<!-- Mobile sidebar backdrop -->

View File

@@ -1,9 +1,6 @@
import { writable } from 'svelte/store';
import type { Writable } from 'svelte/store';
// API Configuration
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000';
// Types
export interface InternalUser {
id: string;
@@ -98,7 +95,7 @@ function createAuthStore() {
update(state => ({ ...state, isLoading: true }));
try {
const response = await fetch(`${API_URL}/v1/auth/login`, {
const response = await fetch('/api/v1/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -150,7 +147,7 @@ function createAuthStore() {
update (state => ({ ...state, isLoading: true }));
try {
const response = await fetch(`${API_URL}/v1/auth/refresh`, {
const response = await fetch('/api/v1/auth/refresh', {
method: 'POST',
headers: {
'Content-Type': 'application/json',

View File

@@ -25,15 +25,11 @@ async function request<T>(endpoint: string, options: RequestOptions = {}): Promi
const authState = get(auth);
const token = authState.token || (typeof window !== 'undefined' ? localStorage.getItem('internal_auth_token') : null);
const user = authState.user || (typeof window !== 'undefined' ? JSON.parse(localStorage.getItem('internal_auth_user') || 'null') : null);
const headers = new Headers(init.headers);
if (token) {
headers.set('Authorization', `Bearer ${token}`);
}
if (user && user.tenant_id) {
headers.set('X-Tenant-ID', user.tenant_id);
}
if (!headers.has('Content-Type')) {
headers.set('Content-Type', 'application/json');
}
@@ -69,15 +65,11 @@ async function request<T>(endpoint: string, options: RequestOptions = {}): Promi
async function downloadFile(endpoint: string, filename: string): Promise<void> {
const authState = get(auth);
const token = authState.token || (typeof window !== 'undefined' ? localStorage.getItem('internal_auth_token') : null);
const user = authState.user || (typeof window !== 'undefined' ? JSON.parse(localStorage.getItem('internal_auth_user') || 'null') : null);
const headers = new Headers();
if (token) {
headers.set('Authorization', `Bearer ${token}`);
}
if (user && user.tenant_id) {
headers.set('X-Tenant-ID', user.tenant_id);
}
const response = await fetch(`${API_BASE}${endpoint}`, {
method: 'GET',