Release version 1.3.1: Updated backend models and endpoints

This commit is contained in:
2026-02-03 13:54:05 -07:00
parent 0d7cdf51ca
commit 2125504831
13 changed files with 1650 additions and 18 deletions

View File

@@ -23,12 +23,13 @@ export interface Ticket {
export interface TicketComment {
id: string;
ticket_id: string;
user_id: string;
user_name: string;
user_role: string;
author_id: string;
author_name: string;
author_role: string;
content: string;
is_internal: boolean;
created_at: string;
updated_at: string;
}
export interface TicketAttachment {
@@ -160,6 +161,17 @@ function createTicketsStore() {
}));
}
},
// Reload only comments silently (for polling)
reloadComments: async (ticketId: string) => {
try {
const comments = await apiCall(`/tickets/${ticketId}/comments`);
update((state: TicketsState) => ({ ...state, comments }));
} catch (error) {
// Silent fail - no mostrar error en polling
console.error('Error reloading comments:', error);
}
},
// Create new ticket
createTicket: async (ticket: CreateTicketRequest) => {

View File

@@ -14,7 +14,17 @@
let closeResolution = '';
let fileInput: HTMLInputElement;
let isUploading = false;
let pollingInterval: any = null;
async function loadComments() {
try {
await tickets.reloadComments(ticketId);
} catch (error) {
// No mostrar error en polling silencioso
console.error('Error recargando comentarios:', error);
}
}
onMount(() => {
// Redirect if not authenticated
if (!$auth.isAuthenticated) {
@@ -25,8 +35,20 @@
ticketId = $page.params.id;
if (ticketId) {
tickets.loadTicket(ticketId);
// Polling cada 3 segundos
pollingInterval = setInterval(() => {
loadComments();
}, 3000);
}
// Cleanup cuando se desmonte el componente
return () => {
if (pollingInterval) {
clearInterval(pollingInterval);
}
});
};
});
// Format date
function formatDate(dateString: string): string {
@@ -287,16 +309,17 @@
{:else}
<div class="space-y-4">
{#each $tickets.comments as comment}
{console.log('Comment:', comment)}
<div class="flex space-x-3">
<div class="w-8 h-8 bg-primary-100 rounded-full flex items-center justify-center flex-shrink-0">
<span class="text-primary-600 text-xs font-medium">
{comment.user_name.split(' ').map(n => n[0]).join('')}
{comment.author_name ? comment.author_name.split(' ').map(n => n[0]).join('') : '??'}
</span>
</div>
<div class="flex-1 min-w-0">
<div class="flex items-center space-x-2 mb-1">
<span class="text-sm font-medium text-gray-900">
{comment.user_name}
{comment.author_name}
</span>
<span class="text-xs text-gray-500">
{formatDate(comment.created_at)}