Disabled TIckets

This commit is contained in:
2025-09-28 17:46:55 +02:00
parent bae41efdf5
commit 6d0f83fab1
4 changed files with 31 additions and 142 deletions

View File

@@ -18,11 +18,11 @@ const links = [{
onClick: () => {
shortcuts.value = true
}
}, {
},/* {
label: 'Tickets',
icon: 'i-heroicons-clipboard-document',
to: '/support',
}, {
},*/ {
label: 'Webseite',
icon: 'i-heroicons-globe-europe-africa',
to: 'https://fedeo.de',

View File

@@ -6,12 +6,13 @@ import dayjs from "dayjs";
const supabase = useSupabaseClient()
const profileStore = useProfileStore()
const toast = useToast()
const auth = useAuthStore()
const itemInfo = ref({})
const loaded = ref(false)
const setup = async () => {
itemInfo.value = (await supabase.from("tickets").select("*, ticketmessages(*, profile(fullName, tenant, id)), created_by(*)").eq("id",useRoute().params.id).single()).data
itemInfo.value = await useEntities("tickets").selectSingle(useRoute().params.id,"*, ticketmessages(*), created_by(*)")
loaded.value = true
}
@@ -20,85 +21,16 @@ setup()
const messageContent = ref("")
const addMessage = async () => {
const {data,error} = await supabase.from("ticketmessages").insert({
profile: profileStore.activeProfile.id,
const res = await useEntities("ticketmessages").create({
auth_user: auth.user.user_id,
content: messageContent.value,
ticket: itemInfo.value.id,
internal: false,
type: "Nachricht"
}).select().single()
if(error) {
toast.add({title: "Erstellen fehlgeschlagen", color: "rose"})
} else {
toast.add({title: "Erstellen erfolgreich"})
messageContent.value=""
setup()
if(profileStore.currentTenant !== 5) {
await useFunctions().useSendTelegramNotification(`Neue Nachricht im Ticket ${useRoute().params.id} von ${profileStore.activeProfile.fullName}: ${data.content}`)
} else if(profileStore.activeProfile.id !== itemInfo.value.created_by) {
let notification = {
tenant: itemInfo.value.tenant,
profile: itemInfo.value.created_by.id,
initiatingProfile: profileStore.activeProfile.id,
title: `Sie haben eine neue Nachricht von ${profileStore.activeProfile.fullName} im Ticket ${itemInfo.value.title}`,
link: `/support/${itemInfo.value.id}`,
message: data.content
}
console.log(notification)
const {error} = await supabase.from("notifications").insert(notification)
}
}
})
}
const showAddEntryModal = ref(false)
const addEntryData = ref({})
const addEntry = async () => {
const {data,error} = await supabase.from("ticketmessages").insert({
profile: profileStore.activeProfile.id,
content: addEntryData.value.content,
ticket: itemInfo.value.id,
internal: addEntryData.value.internal,
type: addEntryData.value.type
}).select().single()
if(error) {
toast.add({title: "Erstellen fehlgeschlagen", color: "rose"})
} else {
toast.add({title: "Erstellen erfolgreich"})
addEntryData.value = {}
setup()
showAddEntryModal.value = false
}
}
const closeTicket = async () => {
const {data, error} = await supabase.from("tickets").update({status: "Geschlossen"}).eq("id",useRoute().params.id).single()
if(error) {
console.log(error)
} else {
console.log(data)
addEntryData.value.type = "Notiz"
addEntryData.value.internal = false
addEntryData.value.content = `Ticket durch ${profileStore.activeProfile.fullName} geschlossen`
addEntry()
}
setup()
}
</script>
@@ -120,7 +52,7 @@ const closeTicket = async () => {
{{itemInfo.title}}
</template>
<template #right>
<UButton
<!-- <UButton
v-if="profileStore.currentTenant === 5"
variant="outline"
@click="closeTicket"
@@ -171,45 +103,14 @@ const closeTicket = async () => {
</UButton>
</template>
</UCard>
</UModal>
</UModal>-->
</template>
</UDashboardNavbar>
<UDashboardPanelContent v-if="loaded">
<div
v-if="profileStore.currentTenant === 5"
v-for="item in itemInfo.ticketmessages"
class="mb-3 flex flex-row p-5"
:style="item.internal ? 'border: 1px solid red; border-radius: 15px' : item.profile.tenant === 5 ? 'border: 1px solid #69c350; border-radius: 15px' : 'border: 1px solid #fff; border-radius: 15px'"
>
<UAvatar :alt="item.profile.fullName" class="mr-3"/>
<div>
<p class="text-xl">{{item.type}} - {{item.profile.fullName}}</p>
<p v-html="item.content"></p>
<p class="mt-1 text-gray-600 dark:text-gray-400">{{dayjs(item.created_at).format("DD.MM.YYYY HH:mm")}}</p>
</div>
</div>
<!-- <UAlert
v-if="profileStore.currentTenant === 5"
v-for="item in itemInfo.ticketmessages"
:avatar="{ alt: item.profile.fullName}"
:title="`${item.type} - ${item.profile.fullName}`"
class="mb-3"
:color="item.internal ? 'rose' : item.profile.tenant === 5 ? 'primary' : 'white'"
variant="outline"
>
<template #description>
<span v-html="item.content"></span>
<p class="mt-1 text-gray-600 dark:text-gray-400">{{dayjs(item.created_at).format("DD.MM.YYYY HH:mm")}}</p>
</template>
</UAlert>-->
<UAlert
v-else
v-for="item in itemInfo.ticketmessages.filter(i => !i.internal)"
:avatar="{ alt: item.profile.fullName}"
:title="`${item.type} - ${item.profile.fullName}`"
:title="`${item.type}`"
class="mb-3"
:color="item.profile.tenant === 5 ? 'primary' : 'white'"
variant="outline"

View File

@@ -1,42 +1,30 @@
<script setup>
import {useFunctions} from "~/composables/useFunctions.js";
const supabase = useSupabaseClient()
const profileStore = useProfileStore()
const router = useRouter()
const itemInfo = ref({})
const auth = useAuthStore()
const createTicket = async () => {
const {data:ticketData,error:ticketError} = await supabase.from("tickets").insert({
const ticketRes = await useEntities("tickets").create({
title: itemInfo.value.title,
created_by: profileStore.activeProfile.id,
tenant: profileStore.currentTenant
}).select().single()
})
if(ticketError) {
console.error(ticketError)
} else {
console.log(ticketData)
const {data:messageData,error:messageError} = await supabase.from("ticketmessages").insert({
ticket: ticketData.id,
profile: profileStore.activeProfile.id,
console.log(ticketRes)
const ticketMsgRes = await useEntities("ticketmessages").create({
ticket: ticketRes.id,
created_by: auth.user.user_id,
content: itemInfo.value.content,
internal: false
})
if(messageError) {
console.log(messageError)
} else {
console.log(ticketData)
//useFunctions().useSendTelegramNotification(`Ticket von ${profileStore.activeProfile.fullName} erstellt : ${itemInfo.value.content}`)
router.push(`/support/${ticketData.id}`)
}
}
await router.push(`/support/${ticketRes.id}`)
}
</script>

View File

@@ -1,6 +1,5 @@
<script setup>
import dayjs from "dayjs";
const supabase = useSupabaseClient()
const profileStore = useProfileStore()
const router = useRouter()
@@ -11,7 +10,7 @@ const showClosedTickets = ref(false)
const selectedTenant = ref(null)
const setup = async () => {
if(profileStore.currentTenant === 5) {
/*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
@@ -19,7 +18,8 @@ const setup = async () => {
if(profileStore.currentTenant === 5) {
tenants.value = (await supabase.from("tenants").select().order("id")).data
}
}*/
tickets.value = await useEntities("tickets").select("*,created_by(*), ticketmessages(*)", "created_at", false)