feat: refactor operator dashboard and report handling, add public intervention page
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="container my-5">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h3 font-weight-bold mb-0">Segnalazioni da prendere in carico (OPEN)</h1>
|
||||
<h1 class="h3 font-weight-bold mb-0">Segnalazioni da valutare</h1>
|
||||
<div>
|
||||
<NuxtLink to="/dashboard" class="btn btn-outline-secondary btn-sm me-2">Dashboard</NuxtLink>
|
||||
<NuxtLink to="/operator/assigned" class="btn btn-outline-primary btn-sm">Le mie assegnazioni</NuxtLink>
|
||||
@@ -45,15 +33,14 @@ const handleTakeReport = async (id: number) => {
|
||||
</div>
|
||||
|
||||
<div v-else-if="!reportsRes?.reports || reportsRes.reports.length === 0" class="alert alert-info">
|
||||
Non ci sono segnalazioni aperte in questo momento.
|
||||
Non ci sono segnalazioni disponibili in questo momento.
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<ReportTable
|
||||
:reports="reportsRes.reports"
|
||||
action-variant="manage"
|
||||
detail-base-path="/operator/reports"
|
||||
@take="handleTakeReport"
|
||||
action-label="Visualizza"
|
||||
/>
|
||||
|
||||
<Pagination
|
||||
|
||||
Reference in New Issue
Block a user