Disabled TIckets
This commit is contained in:
@@ -18,11 +18,11 @@ const links = [{
|
|||||||
onClick: () => {
|
onClick: () => {
|
||||||
shortcuts.value = true
|
shortcuts.value = true
|
||||||
}
|
}
|
||||||
}, {
|
},/* {
|
||||||
label: 'Tickets',
|
label: 'Tickets',
|
||||||
icon: 'i-heroicons-clipboard-document',
|
icon: 'i-heroicons-clipboard-document',
|
||||||
to: '/support',
|
to: '/support',
|
||||||
}, {
|
},*/ {
|
||||||
label: 'Webseite',
|
label: 'Webseite',
|
||||||
icon: 'i-heroicons-globe-europe-africa',
|
icon: 'i-heroicons-globe-europe-africa',
|
||||||
to: 'https://fedeo.de',
|
to: 'https://fedeo.de',
|
||||||
|
|||||||
@@ -6,12 +6,13 @@ import dayjs from "dayjs";
|
|||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const profileStore = useProfileStore()
|
const profileStore = useProfileStore()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
const auth = useAuthStore()
|
||||||
|
|
||||||
const itemInfo = ref({})
|
const itemInfo = ref({})
|
||||||
const loaded = ref(false)
|
const loaded = ref(false)
|
||||||
|
|
||||||
const setup = async () => {
|
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
|
loaded.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,85 +21,16 @@ setup()
|
|||||||
const messageContent = ref("")
|
const messageContent = ref("")
|
||||||
|
|
||||||
const addMessage = async () => {
|
const addMessage = async () => {
|
||||||
const {data,error} = await supabase.from("ticketmessages").insert({
|
const res = await useEntities("ticketmessages").create({
|
||||||
profile: profileStore.activeProfile.id,
|
auth_user: auth.user.user_id,
|
||||||
content: messageContent.value,
|
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,
|
ticket: itemInfo.value.id,
|
||||||
internal: addEntryData.value.internal,
|
internal: false,
|
||||||
type: addEntryData.value.type
|
type: "Nachricht"
|
||||||
}).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>
|
</script>
|
||||||
|
|
||||||
@@ -120,7 +52,7 @@ const closeTicket = async () => {
|
|||||||
{{itemInfo.title}}
|
{{itemInfo.title}}
|
||||||
</template>
|
</template>
|
||||||
<template #right>
|
<template #right>
|
||||||
<UButton
|
<!-- <UButton
|
||||||
v-if="profileStore.currentTenant === 5"
|
v-if="profileStore.currentTenant === 5"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
@click="closeTicket"
|
@click="closeTicket"
|
||||||
@@ -171,45 +103,14 @@ const closeTicket = async () => {
|
|||||||
</UButton>
|
</UButton>
|
||||||
</template>
|
</template>
|
||||||
</UCard>
|
</UCard>
|
||||||
</UModal>
|
</UModal>-->
|
||||||
</template>
|
</template>
|
||||||
</UDashboardNavbar>
|
</UDashboardNavbar>
|
||||||
<UDashboardPanelContent v-if="loaded">
|
<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
|
<UAlert
|
||||||
v-else
|
|
||||||
v-for="item in itemInfo.ticketmessages.filter(i => !i.internal)"
|
v-for="item in itemInfo.ticketmessages.filter(i => !i.internal)"
|
||||||
:avatar="{ alt: item.profile.fullName}"
|
:title="`${item.type}`"
|
||||||
:title="`${item.type} - ${item.profile.fullName}`"
|
|
||||||
class="mb-3"
|
class="mb-3"
|
||||||
:color="item.profile.tenant === 5 ? 'primary' : 'white'"
|
:color="item.profile.tenant === 5 ? 'primary' : 'white'"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
@@ -1,42 +1,30 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
import {useFunctions} from "~/composables/useFunctions.js";
|
|
||||||
|
|
||||||
const supabase = useSupabaseClient()
|
|
||||||
const profileStore = useProfileStore()
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const itemInfo = ref({})
|
const itemInfo = ref({})
|
||||||
|
const auth = useAuthStore()
|
||||||
|
|
||||||
|
|
||||||
const createTicket = async () => {
|
const createTicket = async () => {
|
||||||
|
|
||||||
const {data:ticketData,error:ticketError} = await supabase.from("tickets").insert({
|
const ticketRes = await useEntities("tickets").create({
|
||||||
title: itemInfo.value.title,
|
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}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
const supabase = useSupabaseClient()
|
|
||||||
const profileStore = useProfileStore()
|
const profileStore = useProfileStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
@@ -11,7 +10,7 @@ const showClosedTickets = ref(false)
|
|||||||
const selectedTenant = ref(null)
|
const selectedTenant = ref(null)
|
||||||
|
|
||||||
const setup = async () => {
|
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
|
tickets.value = (await supabase.from("tickets").select("*,created_by(*), ticketmessages(*), tenant(*)").order("created_at", {ascending: false})).data
|
||||||
} else {
|
} else {
|
||||||
tickets.value = (await supabase.from("tickets").select("*,created_by(*), ticketmessages(*)").eq("tenant",profileStore.currentTenant).order("created_at", {ascending: false})).data
|
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) {
|
if(profileStore.currentTenant === 5) {
|
||||||
tenants.value = (await supabase.from("tenants").select().order("id")).data
|
tenants.value = (await supabase.from("tenants").select().order("id")).data
|
||||||
}
|
}*/
|
||||||
|
tickets.value = await useEntities("tickets").select("*,created_by(*), ticketmessages(*)", "created_at", false)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user