Bump version to 1.2.0

This commit is contained in:
arielit3
2026-01-19 14:04:55 -07:00
parent de5b6feef4
commit 6215fc40a7
3 changed files with 472 additions and 4 deletions

View File

@@ -84,8 +84,29 @@ async function apiCall(endpoint: string, options: RequestInit = {}) {
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.detail || 'Request failed');
let errorMessage = 'Request failed';
try {
const error = await response.json();
console.error('❌ API Error Response:', error);
// Manejar diferentes formatos de error de FastAPI
if (error.detail) {
if (Array.isArray(error.detail)) {
// Errores de validación de FastAPI
errorMessage = error.detail.map(e => `${e.loc.join('.')}: ${e.msg}`).join(', ');
} else if (typeof error.detail === 'string') {
errorMessage = error.detail;
} else {
errorMessage = JSON.stringify(error.detail);
}
} else {
errorMessage = JSON.stringify(error);
}
} catch (e) {
errorMessage = `HTTP ${response.status}: ${response.statusText}`;
}
throw new Error(errorMessage);
}
return response.json();
@@ -146,9 +167,21 @@ function createTicketsStore() {
update(state => ({ ...state, isLoading: true, error: null }));
try {
// Mapear campos del frontend al formato del backend
const ticketData = {
subject: ticket.title, // ← Backend espera "subject" no "title"
description: ticket.description,
category_id: ticket.category_id,
priority: ticket.priority,
system_id: null // ← Opcional
};
console.log('Sending ticket data:', ticketData);
const newTicket = await apiCall('/tickets/', {
method: 'POST',
body: JSON.stringify(ticket)
body: JSON.stringify(ticketData)
});
update(state => ({
@@ -159,6 +192,7 @@ function createTicketsStore() {
return newTicket;
} catch (error) {
console.error('Create ticket error:', error);
update(state => ({
...state,
isLoading: false,