fix: ticket

This commit is contained in:
sajjadtalkhabi
2026-06-05 18:43:02 +03:30
parent 1c665830b0
commit ea562aeefa
53 changed files with 2475 additions and 859 deletions
@@ -52,6 +52,7 @@
text="ارسال"
custom-class="send-message__submit"
:disabled="!canSubmit"
:loading="sendMutation.isPending.value"
>
<template #appendIcon>
<SvgIcon name="arrow-left" :size="18" color="#fff" />
@@ -66,19 +67,34 @@
<script setup>
import { computed, ref } from 'vue'
import { toast } from 'vue3-toastify'
import { SERVICE_STATUS } from '@/enums'
import useModal from '@/composables/useModal'
import { useQueryClient } from '@tanstack/vue-query'
import BasicModal from '@/components/BasicModal.vue'
import BaseButton from '@/components/BaseButton.vue'
import SvgIcon from '@/components/icons/SvgIcon.vue'
import SelectField from '@/components/form/SelectField.vue'
import TextareaField from '@/components/form/TextareaField.vue'
import {
adminServicesKeys,
useSendAdminServiceMessageMutation,
} from '@/services/query/admin-services'
defineOptions({ name: 'SendMessageModal' })
const categoryOptions = Object.entries(SERVICE_STATUS).map(([value, label]) => ({
value,
label,
}))
const { getModal } = useModal()
const queryClient = useQueryClient()
const modalData = computed(() => getModal('SendMessageModal')?.data ?? {})
const serviceId = computed(() => modalData.value.id ?? null)
// FE-only — the message endpoint doesn't accept category. Keeping the dropdown
// visible per the Figma until the backend supports it.
const categoryOptions = [
{ value: 'general', label: 'عمومی' },
{ value: 'financial', label: 'مالی' },
{ value: 'technical', label: 'فنی' },
{ value: 'other', label: 'سایر' },
]
const priorityOptions = [
{ value: 'very_urgent', label: 'بسیار فوری' },
@@ -97,8 +113,18 @@ const canSubmit = computed(
() => form.value.category && form.value.priority && form.value.description.trim().length > 0
)
const onSubmit = (close) => {
if (!canSubmit.value) return
const sendMutation = useSendAdminServiceMessageMutation()
const onSubmit = async (close) => {
if (!canSubmit.value || !serviceId.value) return
// Backend POST /admin/tickets/:id/messages accepts only { message }.
// category + priority are collected in the form but not yet supported
// server-side (see backend-vs-ui-gaps).
await sendMutation.mutateAsync({
id: serviceId.value,
payload: { message: form.value.description.trim() },
})
await queryClient.invalidateQueries({ queryKey: adminServicesKeys.all })
toast.success('پیام با موفقیت ارسال شد')
close?.()
}