Auditoria funcionando

This commit is contained in:
2026-02-12 12:23:11 -07:00
parent 96084b89c0
commit 96cd09476c
24 changed files with 2363 additions and 37 deletions

View File

@@ -3,6 +3,9 @@ import { auth } from './auth.js';
import { get } 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 Category {
id: string;
@@ -30,7 +33,7 @@ const initialState: AppState = {
async function apiCall(endpoint: string, options: RequestInit = {}) {
const authState = get(auth);
const response = await fetch(`/api/v1${endpoint}`, {
const response = await fetch(`${API_URL}/v1${endpoint}`, {
...options,
headers: {
'Content-Type': 'application/json',

View File

@@ -1,6 +1,9 @@
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 User {
id: string;
@@ -79,7 +82,7 @@ function createAuthStore() {
update(state => ({ ...state, isLoading: true }));
try {
const response = await fetch('/api/v1/auth/login', {
const response = await fetch(`${API_URL}/v1/auth/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',

View File

@@ -2,6 +2,9 @@ import type { Writable } from 'svelte/store';
import { get, writable } from 'svelte/store';
import { auth } from './auth';
// API Configuration
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000';
// Types
interface FastAPIValidationError {
loc: (string | number)[];
@@ -84,7 +87,7 @@ async function apiCall(endpoint: string, options: RequestInit = {}) {
throw new Error('Not authenticated');
}
const response = await fetch(`/api/v1${endpoint}`, {
const response = await fetch(`${API_URL}/v1${endpoint}`, {
...options,
headers: {
'Content-Type': 'application/json',
@@ -259,7 +262,7 @@ function createTicketsStore() {
throw new Error('Not authenticated');
}
const response = await fetch(`/api/v1/tickets/${ticketId}/attachments`, {
const response = await fetch(`${API_URL}/v1/tickets/${ticketId}/attachments`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${authState.token}`,
@@ -338,7 +341,7 @@ function createTicketsStore() {
throw new Error('Not authenticated');
}
const response = await fetch(`/api/v1/tickets/${ticketId}/attachments/${attachmentId}/download`, {
const response = await fetch(`${API_URL}/v1/tickets/${ticketId}/attachments/${attachmentId}/download`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${authState.token}`,

View File

@@ -4,6 +4,9 @@
import { toast } from '$lib/stores/toast.js';
import { onMount } from 'svelte';
// API Configuration
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000';
let currentPassword = '';
let newPassword = '';
let confirmPassword = '';
@@ -82,7 +85,7 @@
return;
}
const response = await fetch('/api/v1/client-profile/', {
const response = await fetch(`${API_URL}/v1/client-profile/`, {
headers: {
Authorization: `Bearer ${$auth.token}`,
'X-Tenant-ID': $auth.user.tenant_id
@@ -185,7 +188,7 @@
isUpdatingProfile = true;
try {
const response = await fetch('/api/v1/auth/profile', {
const response = await fetch(`${API_URL}/v1/auth/profile`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
@@ -218,7 +221,7 @@
isChangingPassword = true;
try {
const response = await fetch('/api/v1/auth/change-password', {
const response = await fetch(`${API_URL}/v1/auth/change-password`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -269,7 +272,7 @@
profileData.credit_limit = parseFloat(profileData.credit_limit);
}
const response = await fetch('/api/v1/client-profile/', {
const response = await fetch(`${API_URL}/v1/client-profile/`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',