Nuevos cambios en el servidor
This commit is contained in:
3946
frontend-client/package-lock.json
generated
Normal file
3946
frontend-client/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -59,6 +59,9 @@
|
||||
<button
|
||||
on:click={toggleMenu}
|
||||
class="flex items-center space-x-2 text-gray-700 hover:text-primary-600 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 rounded-md p-2"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
on:keydown={(e) => e.key === 'Enter' && toggleMenu()}
|
||||
>
|
||||
<div class="w-8 h-8 bg-primary-100 rounded-full flex items-center justify-center">
|
||||
<span class="text-primary-600 text-sm font-medium">
|
||||
@@ -87,6 +90,9 @@
|
||||
<button
|
||||
on:click={handleLogout}
|
||||
class="block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
on:keydown={(e) => e.key === 'Enter' && handleLogout()}
|
||||
>
|
||||
Cerrar Sesión
|
||||
</button>
|
||||
|
||||
15
frontend-client/src/lib/stores/tickets.js
Normal file
15
frontend-client/src/lib/stores/tickets.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { api } from '$utils/api';
|
||||
|
||||
export const tickets = writable({
|
||||
tickets: [],
|
||||
|
||||
async loadTickets() {
|
||||
try {
|
||||
const data = await api.get('/tickets');
|
||||
this.update((state) => ({ ...state, tickets: data }));
|
||||
} catch (error) {
|
||||
console.error('Error al cargar los tickets:', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { auth } from './auth.js';
|
||||
import { get } from 'svelte/store';
|
||||
import { writable, get } from 'svelte/store';
|
||||
import type { Writable } from 'svelte/store';
|
||||
import { auth } from './auth';
|
||||
|
||||
// Types
|
||||
export interface Ticket {
|
||||
@@ -121,13 +120,13 @@ function createTicketsStore() {
|
||||
|
||||
// Load user's tickets
|
||||
loadTickets: async () => {
|
||||
update(state => ({ ...state, isLoading: true, error: null }));
|
||||
update((state: TicketsState) => ({ ...state, isLoading: true, error: null }));
|
||||
|
||||
try {
|
||||
const tickets = await apiCall('/tickets/');
|
||||
update(state => ({ ...state, tickets, isLoading: false }));
|
||||
update((state: TicketsState) => ({ ...state, tickets, isLoading: false }));
|
||||
} catch (error) {
|
||||
update(state => ({
|
||||
update((state: TicketsState) => ({
|
||||
...state,
|
||||
isLoading: false,
|
||||
error: error instanceof Error ? error.message : 'Failed to load tickets'
|
||||
@@ -137,7 +136,7 @@ function createTicketsStore() {
|
||||
|
||||
// Load specific ticket with details
|
||||
loadTicket: async (ticketId: string) => {
|
||||
update(state => ({ ...state, isLoading: true, error: null }));
|
||||
update((state: TicketsState) => ({ ...state, isLoading: true, error: null }));
|
||||
|
||||
try {
|
||||
const [ticket, comments, attachments] = await Promise.all([
|
||||
@@ -146,7 +145,7 @@ function createTicketsStore() {
|
||||
apiCall(`/tickets/${ticketId}/attachments`)
|
||||
]);
|
||||
|
||||
update(state => ({
|
||||
update((state: TicketsState) => ({
|
||||
...state,
|
||||
currentTicket: ticket,
|
||||
comments,
|
||||
@@ -154,7 +153,7 @@ function createTicketsStore() {
|
||||
isLoading: false
|
||||
}));
|
||||
} catch (error) {
|
||||
update(state => ({
|
||||
update((state: TicketsState) => ({
|
||||
...state,
|
||||
isLoading: false,
|
||||
error: error instanceof Error ? error.message : 'Failed to load ticket'
|
||||
@@ -164,7 +163,7 @@ function createTicketsStore() {
|
||||
|
||||
// Create new ticket
|
||||
createTicket: async (ticket: CreateTicketRequest) => {
|
||||
update(state => ({ ...state, isLoading: true, error: null }));
|
||||
update((state: TicketsState) => ({ ...state, isLoading: true, error: null }));
|
||||
|
||||
try {
|
||||
// Mapear campos del frontend al formato del backend
|
||||
@@ -184,7 +183,7 @@ function createTicketsStore() {
|
||||
body: JSON.stringify(ticketData)
|
||||
});
|
||||
|
||||
update(state => ({
|
||||
update((state: TicketsState) => ({
|
||||
...state,
|
||||
tickets: [newTicket, ...state.tickets],
|
||||
isLoading: false
|
||||
@@ -193,7 +192,7 @@ function createTicketsStore() {
|
||||
return newTicket;
|
||||
} catch (error) {
|
||||
console.error('Create ticket error:', error);
|
||||
update(state => ({
|
||||
update((state: TicketsState) => ({
|
||||
...state,
|
||||
isLoading: false,
|
||||
error: error instanceof Error ? error.message : 'Failed to create ticket'
|
||||
@@ -210,14 +209,14 @@ function createTicketsStore() {
|
||||
body: JSON.stringify({ content })
|
||||
});
|
||||
|
||||
update(state => ({
|
||||
update((state: TicketsState) => ({
|
||||
...state,
|
||||
comments: [...state.comments, comment]
|
||||
}));
|
||||
|
||||
return comment;
|
||||
} catch (error) {
|
||||
update(state => ({
|
||||
update((state: TicketsState) => ({
|
||||
...state,
|
||||
error: error instanceof Error ? error.message : 'Failed to add comment'
|
||||
}));
|
||||
@@ -247,14 +246,14 @@ function createTicketsStore() {
|
||||
|
||||
const attachment = await response.json();
|
||||
|
||||
update(state => ({
|
||||
update((state: TicketsState) => ({
|
||||
...state,
|
||||
attachments: [...state.attachments, attachment]
|
||||
}));
|
||||
|
||||
return attachment;
|
||||
} catch (error) {
|
||||
update(state => ({
|
||||
update((state: TicketsState) => ({
|
||||
...state,
|
||||
error: error instanceof Error ? error.message : 'Failed to upload attachment'
|
||||
}));
|
||||
@@ -270,15 +269,15 @@ function createTicketsStore() {
|
||||
body: JSON.stringify({ resolution })
|
||||
});
|
||||
|
||||
update(state => ({
|
||||
update((state: TicketsState) => ({
|
||||
...state,
|
||||
currentTicket: state.currentTicket?.id === ticketId ? updatedTicket : state.currentTicket,
|
||||
tickets: state.tickets.map(t => t.id === ticketId ? updatedTicket : t)
|
||||
tickets: state.tickets.map((t: Ticket) => t.id === ticketId ? updatedTicket : t)
|
||||
}));
|
||||
|
||||
return updatedTicket;
|
||||
} catch (error) {
|
||||
update(state => ({
|
||||
update((state: TicketsState) => ({
|
||||
...state,
|
||||
error: error instanceof Error ? error.message : 'Failed to close ticket'
|
||||
}));
|
||||
@@ -288,12 +287,12 @@ function createTicketsStore() {
|
||||
|
||||
// Clear error
|
||||
clearError: () => {
|
||||
update(state => ({ ...state, error: null }));
|
||||
update((state: TicketsState) => ({ ...state, error: null }));
|
||||
},
|
||||
|
||||
// Clear current ticket
|
||||
clearCurrentTicket: () => {
|
||||
update(state => ({
|
||||
update((state: TicketsState) => ({
|
||||
...state,
|
||||
currentTicket: null,
|
||||
comments: [],
|
||||
|
||||
0
frontend-client/src/lib/utils/api.ts
Normal file
0
frontend-client/src/lib/utils/api.ts
Normal file
Reference in New Issue
Block a user