From 2c907044a368b56d933db0c51e073ac10d10dcd1 Mon Sep 17 00:00:00 2001
From: gabdevele
Date: Thu, 18 Jun 2026 17:52:57 +0200
Subject: [PATCH] feat: refactor operator dashboard and report handling, add
public intervention page
---
app/components/ReportTable.vue | 6 +-
.../dashboard/OperatorDashboard.vue | 27 +--
app/composables/useOperator.ts | 4 +
app/pages/admin/moderation.vue | 25 ++-
app/pages/interventions/[token].vue | 117 ++++++++++
app/pages/operator/assigned.vue | 2 +-
app/pages/operator/index.vue | 23 +-
app/pages/operator/others.vue | 2 +-
app/pages/operator/reports/[id].vue | 203 +++++++++++++++---
9 files changed, 335 insertions(+), 74 deletions(-)
create mode 100644 app/pages/interventions/[token].vue
diff --git a/app/components/ReportTable.vue b/app/components/ReportTable.vue
index 9cb8a58..fc6db7c 100644
--- a/app/components/ReportTable.vue
+++ b/app/components/ReportTable.vue
@@ -80,15 +80,15 @@ const reportHref = (report: Report) => `${props.detailBasePath}/${report.id}`
-
+ {{ actionLabel }}
-
\ No newline at end of file
+
diff --git a/app/components/dashboard/OperatorDashboard.vue b/app/components/dashboard/OperatorDashboard.vue
index 3ea9c2a..3f569fb 100644
--- a/app/components/dashboard/OperatorDashboard.vue
+++ b/app/components/dashboard/OperatorDashboard.vue
@@ -1,22 +1,8 @@
@@ -25,8 +11,8 @@ const handleTakeReport = async (id: number) => {
-
Da prendere in carico
- Apri coda
+ Segnalazioni disponibili
+ Apri elenco
Nessuna nuova segnalazione in ingresso.
@@ -34,9 +20,8 @@ const handleTakeReport = async (id: number) => {
diff --git a/app/composables/useOperator.ts b/app/composables/useOperator.ts
index 600eae2..6645487 100644
--- a/app/composables/useOperator.ts
+++ b/app/composables/useOperator.ts
@@ -39,6 +39,9 @@ export const useOperator = () => {
const revokeInterventionLink = (id: number) =>
useApiFetch
(`/api/v1/reports/${id}/intervention-link`, { method: 'DELETE' })
+ const getPublicIntervention = (token: string) =>
+ useApiFetch(`/api/v1/interventions/${token}`, { method: 'GET' })
+
return {
getOpenReports,
getAssignedReports,
@@ -50,5 +53,6 @@ export const useOperator = () => {
getInterventionSummary,
createInterventionLink,
revokeInterventionLink,
+ getPublicIntervention,
}
}
diff --git a/app/pages/admin/moderation.vue b/app/pages/admin/moderation.vue
index bd051e1..1211c11 100644
--- a/app/pages/admin/moderation.vue
+++ b/app/pages/admin/moderation.vue
@@ -106,6 +106,19 @@ const formatDate = (dateStr: string) => {
hour: '2-digit', minute: '2-digit'
})
}
+
+const formatFlagStatus = (status: string) => {
+ const map: Record = {
+ OPEN: 'Aperto',
+ RESOLVED: 'Risolto',
+ DISMISSED: 'Ignorato'
+ }
+
+ return map[status] || status
+}
+
+const contentTypeLabel = (type: string) => type === 'REPORT' ? 'Segnalazione' : 'Messaggio'
+const canRejectReport = (flag: any) => flag.content_type === 'REPORT'
@@ -153,7 +166,7 @@ const formatDate = (dateStr: string) => {
'bg-warning': flag.status === 'OPEN',
'bg-success': flag.status === 'RESOLVED',
'bg-secondary': flag.status === 'DISMISSED'
- }">{{ flag.status }}
+ }">{{ formatFlagStatus(flag.status) }}
{{ formatDate(flag.created_at) }}
@@ -166,7 +179,7 @@ const formatDate = (dateStr: string) => {
-
{{ flag.content_type }}
+
{{ contentTypeLabel(flag.content_type) }}
Rif:
@@ -190,11 +203,11 @@ const formatDate = (dateStr: string) => {
-
diff --git a/app/pages/operator/index.vue b/app/pages/operator/index.vue
index 4a6c627..b9a39bf 100644
--- a/app/pages/operator/index.vue
+++ b/app/pages/operator/index.vue
@@ -6,34 +6,22 @@ definePageMeta({
useHead({ title: 'Segnalazioni Aperte - Operatore' })
-const { getOpenReports, takeReport } = useOperator()
+const { getOpenReports } = useOperator()
const page = ref(1)
const perPage = ref(10)
-const { data: reportsRes, pending, refresh } = useAsyncData(
+const { data: reportsRes, pending } = useAsyncData(
'operator-open-reports',
() => getOpenReports({ page: page.value, per_page: perPage.value }),
{ watch: [page] }
)
-
-const handleTakeReport = async (id: number) => {
- try {
- const res = await takeReport(id)
- if (res.ok) {
- await refresh()
- }
- } catch (err) {
- console.error('Failed to take report', err)
- }
-}
-
-
Segnalazioni da prendere in carico (OPEN)
+
Segnalazioni da valutare
Dashboard
Le mie assegnazioni
@@ -45,15 +33,14 @@ const handleTakeReport = async (id: number) => {
- Non ci sono segnalazioni aperte in questo momento.
+ Non ci sono segnalazioni disponibili in questo momento.
Gestite da altri Operatori
Dashboard
- Coda Open
+ Segnalazioni disponibili
diff --git a/app/pages/operator/reports/[id].vue b/app/pages/operator/reports/[id].vue
index 0293c0a..979dc3c 100644
--- a/app/pages/operator/reports/[id].vue
+++ b/app/pages/operator/reports/[id].vue
@@ -1,5 +1,5 @@