From 6d0f83fab1db486d3083354f9169b50f76da450d Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Sun, 28 Sep 2025 17:46:55 +0200 Subject: [PATCH] Disabled TIckets --- components/HelpSlideover.vue | 4 +- pages/support/[id].vue | 121 ++++------------------------------- pages/support/create.vue | 42 +++++------- pages/support/index.vue | 6 +- 4 files changed, 31 insertions(+), 142 deletions(-) diff --git a/components/HelpSlideover.vue b/components/HelpSlideover.vue index 094e1da..36cdd08 100644 --- a/components/HelpSlideover.vue +++ b/components/HelpSlideover.vue @@ -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', diff --git a/pages/support/[id].vue b/pages/support/[id].vue index 54f98b8..4d8941e 100644 --- a/pages/support/[id].vue +++ b/pages/support/[id].vue @@ -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, - 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, + const res = await useEntities("ticketmessages").create({ + auth_user: auth.user.user_id, + content: messageContent.value, 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 - - } + internal: false, + type: "Nachricht" + }) } -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() -} @@ -120,7 +52,7 @@ const closeTicket = async () => { {{itemInfo.title}} - + --> -
- -
-

{{item.type}} - {{item.profile.fullName}}

-

-

{{dayjs(item.created_at).format("DD.MM.YYYY HH:mm")}}

-
-
- - - -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() + }) + + console.log(ticketRes) + + const ticketMsgRes = await useEntities("ticketmessages").create({ + ticket: ticketRes.id, + created_by: auth.user.user_id, + content: itemInfo.value.content, + internal: false + }) + + await router.push(`/support/${ticketRes.id}`) + - 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, - 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}`) - } - } } diff --git a/pages/support/index.vue b/pages/support/index.vue index ba014b4..d5671c5 100644 --- a/pages/support/index.vue +++ b/pages/support/index.vue @@ -1,6 +1,5 @@