From 107cb61ea43ca9941796fc27ada21adf5481caa6 Mon Sep 17 00:00:00 2001 From: ReLoia Date: Mon, 15 Jun 2026 23:12:40 +0200 Subject: [PATCH] feat(dashboard): add loading state for report assignment and truncate addresses --- app/components/ReportTable.vue | 75 ++++++++++--------- .../dashboard/OperatorDashboard.vue | 13 +++- 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/app/components/ReportTable.vue b/app/components/ReportTable.vue index 236c1be..3c5e41d 100644 --- a/app/components/ReportTable.vue +++ b/app/components/ReportTable.vue @@ -9,6 +9,7 @@ interface Props { actionVariant?: ActionVariant actionLabel?: string showAssignee?: boolean + processingIds?: number[] } const props = withDefaults(defineProps(), { @@ -16,6 +17,7 @@ const props = withDefaults(defineProps(), { actionVariant: 'open', actionLabel: 'Open report', showAssignee: false, + processingIds: () => [], }) const emit = defineEmits<{ @@ -38,53 +40,56 @@ const reportHref = (report: Report) => `${props.detailBasePath}/${report.id}`
- - - - - - - - - + + + + + + + + + - - - - + + + - - - - + + + - + > + + + +
IDCategoriaIndirizzoStatoOperatoreCreazioneAzioni
IDCategoriaIndirizzoStatoOperatoreCreazioneAzioni
#{{ report.id }}{{ report.category_name || '-' }} - +
#{{ report.id }}{{ report.category_name || '-' }} + + {{ report.address || '-' }} - - - - {{ report.assigned_operator_id ? `#${report.assigned_operator_id}` : '-' }} - {{ formatDate(report.created_at) }} - + + + {{ report.assigned_operator_id ? `#${report.assigned_operator_id}` : '-' }} + {{ formatDate(report.created_at) }} + - + + Prendi in carico + + - - -
- + \ No newline at end of file diff --git a/app/components/dashboard/OperatorDashboard.vue b/app/components/dashboard/OperatorDashboard.vue index 020ce89..3ea9c2a 100644 --- a/app/components/dashboard/OperatorDashboard.vue +++ b/app/components/dashboard/OperatorDashboard.vue @@ -4,10 +4,17 @@ const { getOpenReports, getAssignedReports, takeReport } = useOperator() const { data: openReportsRes, refresh: refreshOpen } = useAsyncData('open-reports', () => getOpenReports({ per_page: 5 })) const { data: assignedReportsRes, refresh: refreshAssigned } = useAsyncData('assigned-reports', () => getAssignedReports({ per_page: 5 })) +const processingIds = ref([]) + const handleTakeReport = async (id: number) => { - const res = await takeReport(id) - if (res.ok) { - await Promise.all([refreshOpen(), refreshAssigned()]) + processingIds.value.push(id) + try { + const res = await takeReport(id) + if (res.ok) { + await Promise.all([refreshOpen(), refreshAssigned()]) + } + } finally { + processingIds.value = processingIds.value.filter(pid => pid !== id) } }