From c9f628391a14056763120f003b7f8feb0448381d Mon Sep 17 00:00:00 2001 From: ReLoia Date: Mon, 15 Jun 2026 23:12:41 +0200 Subject: [PATCH] style(reports): simplify timeline ui and update composer integration --- app/pages/reports/[id].vue | 134 ++++++++++++++++++++----------------- 1 file changed, 73 insertions(+), 61 deletions(-) diff --git a/app/pages/reports/[id].vue b/app/pages/reports/[id].vue index e9e18cc..5bb6a42 100644 --- a/app/pages/reports/[id].vue +++ b/app/pages/reports/[id].vue @@ -17,12 +17,12 @@ if (!reportId) { } // Fetch dati -const { data: reportData, refresh: refreshReport } = await useAsyncData(`report-${reportId}`, () => - getReportDetail(reportId) +const { data: reportData, refresh: refreshReport } = await useAsyncData(`report-${reportId}`, () => + getReportDetail(reportId) ) const { data: messagesData, refresh: refreshMessages } = await useAsyncData(`messages-${reportId}`, () => - getMessages(reportId) + getMessages(reportId) ) const report = computed(() => (reportData.value as any)?.report) @@ -31,7 +31,10 @@ const statusHistory = computed(() => (reportData.value as any)?.history || []) const messages = computed(() => (messagesData.value as any)?.messages || []) const newMessage = ref('') +const fileInput = ref(null) +const selectedFiles = ref([]) const isSubmittingMessage = ref(false) + const isFeedbackOpen = ref(false) const feedbackRating = ref(5) const feedbackComment = ref('') @@ -39,14 +42,28 @@ const isSubmittingFeedback = ref(false) const selectedMediaIndex = ref(0) const isGalleryOpen = ref(false) +// Gestione selezione file +const handleFileSelect = (event: Event) => { + const target = event.target as HTMLInputElement + if (target.files) { + selectedFiles.value = Array.from(target.files) + } +} + // Invia messaggio -const handleSendMessage = async (msgText: string, files: File[]) => { - if (!msgText.trim() && files.length === 0) return +const handleSendMessage = async () => { + if (!newMessage.value.trim() && selectedFiles.value.length === 0) return isSubmittingMessage.value = true try { - // Gestione mock di file, nella realtà si usa FormData o simle - await addMessage(reportId, { body: msgText }) + // Gestione mock di file, nella realtà si usa FormData o simile + await addMessage(reportId, { body: newMessage.value }) + + // Pulisci i campi + newMessage.value = '' + selectedFiles.value = [] + if (fileInput.value) fileInput.value.value = '' + await refreshMessages() } catch (error) { console.error('Error sending message:', error) @@ -75,7 +92,10 @@ const handleSubmitFeedback = async () => { } const isOwner = computed(() => report.value?.user_id === user.value?.id) -const canFeedback = computed(() => report.value?.status === 'RESOLVED' || report.value?.status === 'CLOSED') + +// Valutazione solo se lo stato è specificamente "RESOLVED" +const canFeedback = computed(() => report.value?.status === 'RESOLVED') + const statusMeta: Record = { OPEN: { label: 'Aperta', tone: 'info' }, UNDER_REVIEW: { label: 'In revisione', tone: 'warning' }, @@ -180,30 +200,21 @@ const formatDate = (dateString: string): string => { -
+
-
- -

Cronologia

-
-
-
-
-
-
-
-
- {{ formatDate(item.created_at) }} -
- - - -
- {{ item.note }} -
+

Cronologia eventi

+
Nessun evento registrato.
+
    +
  • + {{ formatDate(item.created_at) }} +
    + + +
    -
-
+
{{ item.note }}
+ +
@@ -219,8 +230,10 @@ const formatDate = (dateString: string): string => {
{{ messages.length }} messaggi
+ - + + @@ -252,10 +265,10 @@ const formatDate = (dateString: string): string => {

Valuta intervento

Lascia valutazione finale quando intervento è concluso.

@@ -267,9 +280,9 @@ const formatDate = (dateString: string): string => { @@ -277,10 +290,10 @@ const formatDate = (dateString: string): string => {