80 lines
2.3 KiB
Vue
80 lines
2.3 KiB
Vue
<script setup>
|
|
import dayjs from "dayjs";
|
|
const supabase = useSupabaseClient()
|
|
const profileStore = useProfileStore()
|
|
const router = useRouter()
|
|
|
|
const tickets = ref([])
|
|
|
|
const showClosedTickets = ref(false)
|
|
|
|
const setup = async () => {
|
|
if(profileStore.currentTenant === 5) {
|
|
tickets.value = (await supabase.from("tickets").select("*,created_by(*), ticketmessages(*), tenant(*)").order("created_at", {ascending: false})).data
|
|
} else {
|
|
tickets.value = (await supabase.from("tickets").select("*,created_by(*), ticketmessages(*)").eq("tenant",profileStore.currentTenant).order("created_at", {ascending: false})).data
|
|
}
|
|
}
|
|
|
|
setup()
|
|
|
|
const filteredRows = computed(() => {
|
|
|
|
if(showClosedTickets.value) {
|
|
return tickets.value
|
|
} else {
|
|
return tickets.value.filter(i => i.status !== "Geschlossen")
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
<template>
|
|
<UDashboardNavbar
|
|
title="Support Tickets"
|
|
>
|
|
<template #right>
|
|
<UButton
|
|
@click="router.push('/support/create')"
|
|
>
|
|
+ Ticket
|
|
</UButton>
|
|
</template>
|
|
</UDashboardNavbar>
|
|
<UDashboardToolbar>
|
|
<template #left>
|
|
<UCheckbox
|
|
label="Geschlossene Tickets anzeigen"
|
|
v-model="showClosedTickets"
|
|
/>
|
|
</template>
|
|
</UDashboardToolbar>
|
|
<UTable
|
|
:rows="filteredRows"
|
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: `Keine Tickets anzuzeigen` }"
|
|
@select="(i) => router.push(`/support/${i.id}`)"
|
|
:columns="[{key:'created_at',label:'Datum'}, ...profileStore.currentTenant === 5 ? [{key:'tenant',label:'Tenant'}] : [],{key:'status',label:'Status'},{key:'title',label:'Titel'},{key:'created_by',label:'Ersteller'},{key:'ticketmessages',label:'Nachrichten'}]"
|
|
>
|
|
<template #tenant-data="{ row }">
|
|
{{row.tenant.name}}
|
|
</template>
|
|
<template #status-data="{ row }">
|
|
<span v-if="row.status === 'Offen'" class="text-yellow-500">Offen</span>
|
|
<span v-else-if="row.status === 'Geschlossen'" class="text-primary">Geschlossen</span>
|
|
</template>
|
|
<template #created_by-data="{ row }">
|
|
{{row.created_by.fullName}}
|
|
</template>
|
|
<template #created_at-data="{ row }">
|
|
{{dayjs(row.created_at).format('DD.MM.YYYY HH:mm')}}
|
|
</template>
|
|
<template #ticketmessages-data="{ row }">
|
|
{{row.ticketmessages.length}}
|
|
</template>
|
|
</UTable>
|
|
</template>
|
|
|
|
<style scoped>
|
|
|
|
</style> |