Added Tenant Filtering

This commit is contained in:
2025-03-14 18:32:36 +01:00
parent aa849f591b
commit b7d64b1f9e

View File

@@ -5,8 +5,10 @@ const profileStore = useProfileStore()
const router = useRouter()
const tickets = ref([])
const tenants = ref([])
const showClosedTickets = ref(false)
const selectedTenant = ref(null)
const setup = async () => {
if(profileStore.currentTenant === 5) {
@@ -14,18 +16,33 @@ const setup = async () => {
} else {
tickets.value = (await supabase.from("tickets").select("*,created_by(*), ticketmessages(*)").eq("tenant",profileStore.currentTenant).order("created_at", {ascending: false})).data
}
if(profileStore.currentTenant === 5) {
tenants.value = (await supabase.from("tenants").select().order("id")).data
}
}
setup()
const filteredRows = computed(() => {
let items = tickets.value
if(showClosedTickets.value) {
return tickets.value
} else {
return tickets.value.filter(i => i.status !== "Geschlossen")
if(!showClosedTickets.value) {
items = items.filter(i => i.status !== "Geschlossen")
}
if(selectedTenant.value) {
console.log(selectedTenant.value)
console.log(items)
console.log(items.filter(i => i.tenant.id === selectedTenant.value))
items = items.filter(i => i.tenant.id === selectedTenant.value)
}
return items
})
</script>
@@ -49,6 +66,18 @@ const filteredRows = computed(() => {
label="Geschlossene Tickets anzeigen"
v-model="showClosedTickets"
/>
<USelectMenu
v-if="profileStore.currentTenant === 5"
:ui-menu="{ width: 'min-w-max' }"
:options="tenants"
option-attribute="name"
value-attribute="id"
v-model="selectedTenant"
>
<template #label>
{{selectedTenant ? tenants.find(i => i.id === selectedTenant).name : "Nicht nach Tenant filtern"}}
</template>
</USelectMenu>
</template>
</UDashboardToolbar>
<UTable