fix: ticket
This commit is contained in:
@@ -22,10 +22,14 @@
|
||||
import { computed } from 'vue'
|
||||
import Badge from '@/components/Badge.vue'
|
||||
|
||||
// Backend statuses are open/answered/closed. Legacy keys stay in place for any
|
||||
// pre-migration cached data.
|
||||
const TONE_MAP = {
|
||||
approved: 'success',
|
||||
rejected: 'danger',
|
||||
pending: 'neutral',
|
||||
open: 'neutral',
|
||||
answered: 'success',
|
||||
closed: 'info',
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,12 @@
|
||||
<form class="rcf__form" @submit.prevent="onSubmit">
|
||||
<div class="rcf__row">
|
||||
<div class="rcf__cell">
|
||||
<SelectField
|
||||
v-model="form.title"
|
||||
name="title"
|
||||
<TextField
|
||||
v-model="form.subject"
|
||||
name="subject"
|
||||
label="عنوان مشاوره درخواستی"
|
||||
placeholder="انتخاب کنید"
|
||||
:options="titleOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:error="errors.title"
|
||||
placeholder="عنوان مشاوره را وارد کنید"
|
||||
:error="errors.subject"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -19,12 +16,12 @@
|
||||
<div class="rcf__row">
|
||||
<div class="rcf__cell rcf__cell--full">
|
||||
<TextareaField
|
||||
v-model="form.description"
|
||||
name="description"
|
||||
v-model="form.message"
|
||||
name="message"
|
||||
label="توضیحات خود را وارد نمایید"
|
||||
placeholder="لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است."
|
||||
:row="5"
|
||||
:error="errors.description"
|
||||
:error="errors.message"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -48,14 +45,13 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import * as yup from 'yup'
|
||||
import { computed, ref } from 'vue'
|
||||
import useYup from '@/composables/useYup'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import { useStudentConsultantTitlesQuery } from '@/services/query/student-consultants'
|
||||
|
||||
defineProps({
|
||||
submitting: { type: Boolean, default: false },
|
||||
@@ -64,13 +60,13 @@ defineProps({
|
||||
const emit = defineEmits(['submit'])
|
||||
|
||||
const form = ref({
|
||||
title: '',
|
||||
description: '',
|
||||
subject: '',
|
||||
message: '',
|
||||
})
|
||||
|
||||
const schema = yup.object({
|
||||
title: yup.string().required('عنوان مشاوره را انتخاب کنید'),
|
||||
description: yup
|
||||
subject: yup.string().trim().required('عنوان مشاوره را وارد کنید'),
|
||||
message: yup
|
||||
.string()
|
||||
.trim()
|
||||
.min(5, 'توضیحات حداقل ۵ کاراکتر باشد')
|
||||
@@ -79,13 +75,10 @@ const schema = yup.object({
|
||||
|
||||
const { validate, errors } = useYup(schema)
|
||||
|
||||
const { data: titles } = useStudentConsultantTitlesQuery()
|
||||
const titleOptions = computed(() => titles.value ?? [])
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
emit('submit', { ...payload })
|
||||
emit('submit', { subject: payload.subject, message: payload.message })
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -35,9 +35,11 @@
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { toast } from 'vue3-toastify'
|
||||
import { TICKET_STATUS } from '@/enums'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
import TabsBlock from '@/components/blocks/TabsBlock.vue'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
@@ -46,10 +48,10 @@ import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import ConsultantItem from '@/features/student/consultants/components/ConsultantItem.vue'
|
||||
import RequestConsultantForm from '@/features/student/consultants/components/RequestConsultantForm.vue'
|
||||
import {
|
||||
studentConsultantsKeys,
|
||||
useCreateStudentConsultantMutation,
|
||||
useStudentConsultantsQuery,
|
||||
} from '@/services/query/student-consultants'
|
||||
studentTicketsKeys,
|
||||
useCreateStudentTicketMutation,
|
||||
useStudentTicketsQuery,
|
||||
} from '@/services/query/student-tickets'
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
@@ -59,13 +61,13 @@ const tabs = [
|
||||
]
|
||||
const activeTab = ref('create')
|
||||
|
||||
const historyFilters = ref({})
|
||||
const historyFilters = ref({ type: 'advise' })
|
||||
const { pagination: historyPagination, setPage: setHistoryPage } = usePagination({
|
||||
page: 1,
|
||||
perPage: 10,
|
||||
})
|
||||
|
||||
const { data: historyData, isLoading: historyLoading } = useStudentConsultantsQuery(
|
||||
const { data: historyData, isLoading: historyLoading } = useStudentTicketsQuery(
|
||||
historyFilters,
|
||||
historyPagination,
|
||||
{
|
||||
@@ -74,20 +76,42 @@ const { data: historyData, isLoading: historyLoading } = useStudentConsultantsQu
|
||||
}
|
||||
)
|
||||
|
||||
const consultants = computed(() => historyData.value?.data ?? [])
|
||||
const formatTime = (iso) => {
|
||||
if (!iso) return ''
|
||||
const d = new Date(iso)
|
||||
if (Number.isNaN(d.getTime())) return ''
|
||||
return d.toLocaleTimeString('fa-IR', { hour: '2-digit', minute: '2-digit' })
|
||||
}
|
||||
|
||||
// ConsultantItem expects title/requestNumber/dateLabel/timeLabel/statusLabel.
|
||||
// Bridge the new backend payload without touching the item template.
|
||||
const consultants = computed(() =>
|
||||
(historyData.value?.data?.items ?? []).map((t) => ({
|
||||
...t,
|
||||
title: t.subject ?? '',
|
||||
requestNumber: t.id,
|
||||
dateLabel: formatJalaaliDate(t.createdAt) || '',
|
||||
timeLabel: formatTime(t.createdAt),
|
||||
statusLabel: TICKET_STATUS[t.status] ?? '',
|
||||
}))
|
||||
)
|
||||
const historyMeta = computed(() => ({
|
||||
page: historyPagination.value.page,
|
||||
perPage: historyPagination.value.perPage,
|
||||
...historyData.value?.meta,
|
||||
}))
|
||||
|
||||
const createMutation = useCreateStudentConsultantMutation()
|
||||
const createMutation = useCreateStudentTicketMutation()
|
||||
|
||||
const onSubmit = async (payload) => {
|
||||
const onSubmit = async (formPayload) => {
|
||||
try {
|
||||
await createMutation.mutateAsync(payload)
|
||||
await createMutation.mutateAsync({
|
||||
type: 'advise',
|
||||
subject: formPayload.subject,
|
||||
message: formPayload.message,
|
||||
})
|
||||
toast.success('درخواست مشاوره با موفقیت ثبت شد.')
|
||||
await queryClient.invalidateQueries({ queryKey: studentConsultantsKeys.all })
|
||||
await queryClient.invalidateQueries({ queryKey: studentTicketsKeys.all })
|
||||
activeTab.value = 'history'
|
||||
} catch {
|
||||
toast.error('ثبت درخواست با خطا مواجه شد.')
|
||||
|
||||
@@ -83,4 +83,10 @@ export default [
|
||||
component: () => import('@/features/student/certificates/pages/StudentCertificatesPage.vue'),
|
||||
meta: { layout: 'student', role: 'student', title: 'گواهینامه ها' },
|
||||
},
|
||||
{
|
||||
path: '/my-tickets',
|
||||
name: 'student-tickets',
|
||||
component: () => import('@/features/student/tickets/pages/StudentTicketsPage.vue'),
|
||||
meta: { layout: 'student', role: 'student', title: 'تیکتهای من' },
|
||||
},
|
||||
]
|
||||
|
||||
@@ -3,29 +3,21 @@
|
||||
<form class="csf__form" @submit.prevent="onSubmit">
|
||||
<div class="csf__row">
|
||||
<div class="csf__cell">
|
||||
<SelectField
|
||||
v-model="form.typeKey"
|
||||
name="typeKey"
|
||||
<TextField
|
||||
v-model="form.category"
|
||||
name="category"
|
||||
label="نوع خدمت"
|
||||
placeholder="انتخاب کنید"
|
||||
:options="typeOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:error="errors.typeKey"
|
||||
@change="onTypeChange"
|
||||
placeholder="نوع خدمت را وارد کنید"
|
||||
:error="errors.category"
|
||||
/>
|
||||
</div>
|
||||
<div class="csf__cell">
|
||||
<SelectField
|
||||
v-model="form.title"
|
||||
name="title"
|
||||
<TextField
|
||||
v-model="form.subject"
|
||||
name="subject"
|
||||
label="عنوان خدمت"
|
||||
placeholder="انتخاب کنید"
|
||||
:options="titleOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:disabled="!form.typeKey"
|
||||
:error="errors.title"
|
||||
placeholder="عنوان خدمت را وارد کنید"
|
||||
:error="errors.subject"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -33,12 +25,12 @@
|
||||
<div class="csf__row">
|
||||
<div class="csf__cell csf__cell--full">
|
||||
<TextareaField
|
||||
v-model="form.description"
|
||||
name="description"
|
||||
v-model="form.message"
|
||||
name="message"
|
||||
label="توضیحات خود را وارد نمایید"
|
||||
placeholder="لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است."
|
||||
:row="5"
|
||||
:error="errors.description"
|
||||
:error="errors.message"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -48,6 +40,7 @@
|
||||
v-model="files"
|
||||
accept="image/*,application/pdf"
|
||||
:max-files="3"
|
||||
@select="onFilesSelect"
|
||||
@error="onFileError"
|
||||
/>
|
||||
</div>
|
||||
@@ -60,6 +53,7 @@
|
||||
text="ثبت درخواست"
|
||||
custom-class="csf__submit"
|
||||
:loading="submitting"
|
||||
:disabled="uploadMutation.isPending.value"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="16" color="#fff" />
|
||||
@@ -71,18 +65,17 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import * as yup from 'yup'
|
||||
import { toast } from 'vue3-toastify'
|
||||
import useYup from '@/composables/useYup'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import FileUploader from '@/components/form/FileUploader.vue'
|
||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||
import { useUploadMediaMutation } from '@/services/query/auth'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import {
|
||||
useStudentServiceTitlesQuery,
|
||||
useStudentServiceTypesQuery,
|
||||
} from '@/services/query/student-services'
|
||||
|
||||
defineProps({
|
||||
submitting: { type: Boolean, default: false },
|
||||
@@ -91,17 +84,20 @@ defineProps({
|
||||
const emit = defineEmits(['submit', 'file-error'])
|
||||
|
||||
const form = ref({
|
||||
typeKey: '',
|
||||
title: '',
|
||||
description: '',
|
||||
category: '',
|
||||
subject: '',
|
||||
message: '',
|
||||
})
|
||||
|
||||
// Items here are uploaded-media descriptors { id, name, size, url } — not raw
|
||||
// File objects. We upload immediately on select (same pattern as
|
||||
// AddAssignmentModal / SessionFormPage) and just collect the IDs at submit.
|
||||
const files = ref([])
|
||||
|
||||
const schema = yup.object({
|
||||
typeKey: yup.string().required('نوع خدمت را انتخاب کنید'),
|
||||
title: yup.string().required('عنوان خدمت را انتخاب کنید'),
|
||||
description: yup
|
||||
category: yup.string().trim().required('نوع خدمت را وارد کنید'),
|
||||
subject: yup.string().trim().required('عنوان خدمت را وارد کنید'),
|
||||
message: yup
|
||||
.string()
|
||||
.trim()
|
||||
.min(5, 'توضیحات حداقل ۵ کاراکتر باشد')
|
||||
@@ -110,32 +106,38 @@ const schema = yup.object({
|
||||
|
||||
const { validate, errors } = useYup(schema)
|
||||
|
||||
const { data: types } = useStudentServiceTypesQuery()
|
||||
const typeOptions = computed(() => types.value ?? [])
|
||||
const uploadMutation = useUploadMediaMutation()
|
||||
|
||||
const typeKeyRef = computed(() => form.value.typeKey)
|
||||
const { data: titles } = useStudentServiceTitlesQuery(typeKeyRef, {
|
||||
enabled: () => !!form.value.typeKey,
|
||||
})
|
||||
const titleOptions = computed(() => titles.value ?? [])
|
||||
|
||||
const onTypeChange = () => {
|
||||
form.value.title = ''
|
||||
}
|
||||
|
||||
watch(
|
||||
() => form.value.typeKey,
|
||||
() => {
|
||||
form.value.title = ''
|
||||
const onFilesSelect = async (newFiles) => {
|
||||
for (const file of newFiles) {
|
||||
try {
|
||||
const fd = objectToFormData({ file, purpose: 'attachment', context: 'ticket' })
|
||||
const response = await uploadMutation.mutateAsync(fd)
|
||||
const payload = response?.data ?? response
|
||||
const id = payload?.id ?? payload?.uploadId
|
||||
if (id == null) continue
|
||||
files.value = [
|
||||
...files.value,
|
||||
{ id, name: file.name, size: file.size, url: payload?.url ?? '' },
|
||||
]
|
||||
} catch {
|
||||
toast.error(`بارگذاری فایل "${file.name}" با خطا مواجه شد.`)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const onFileError = (msg) => emit('file-error', msg)
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
emit('submit', { ...payload, files: files.value })
|
||||
|
||||
emit('submit', {
|
||||
category: payload.category,
|
||||
subject: payload.subject,
|
||||
message: payload.message,
|
||||
mediaIds: files.value.map((f) => f.id).filter((id) => id != null),
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ const TONE_MAP = {
|
||||
approved: 'success',
|
||||
rejected: 'danger',
|
||||
pending: 'neutral',
|
||||
open: 'neutral',
|
||||
answered: 'success',
|
||||
closed: 'info',
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="58rem" min-width="auto" :show-close-button="true">
|
||||
<template #default>
|
||||
<div class="sdm">
|
||||
<header class="sdm__header">
|
||||
<LineTitleBlock title="جزئیات درخواست" title-en="Request details" />
|
||||
</header>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading && !service" :rows="2" :cols-per-row="1" />
|
||||
|
||||
<template v-else-if="service">
|
||||
<div class="sdm__top">
|
||||
<Badge :variant="statusVariant" size="sm" dot :value="statusLabel" />
|
||||
<span class="sdm__date">{{ requestDate }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="messages.length > 0" class="sdm__messages">
|
||||
<div v-for="message in messages" :key="message.id" class="sdm__bubble">
|
||||
<p class="sdm__text">{{ message.message }}</p>
|
||||
<span class="sdm__time">{{ messageTime(message) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<NoItems v-else title="پیامی نیست" desc="هنوز پیامی برای این درخواست ثبت نشده است." />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { TICKET_STATUS } from '@/enums'
|
||||
import Badge from '@/components/Badge.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import { useStudentTicketQuery } from '@/services/query/student-tickets'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
|
||||
defineOptions({ name: 'ServiceDetailsModal' })
|
||||
|
||||
const STATUS_VARIANT = {
|
||||
open: 'neutral',
|
||||
answered: 'success',
|
||||
closed: 'info',
|
||||
approved: 'success',
|
||||
rejected: 'danger',
|
||||
pending: 'neutral',
|
||||
}
|
||||
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('ServiceDetailsModal')?.data ?? {})
|
||||
const ticketId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const { data: service, isLoading } = useStudentTicketQuery(ticketId, {
|
||||
enabled: () => !!ticketId.value,
|
||||
})
|
||||
|
||||
const messages = computed(() => service.value?.messages ?? [])
|
||||
|
||||
const statusLabel = computed(() => TICKET_STATUS[service.value?.status] || '—')
|
||||
const statusVariant = computed(() => STATUS_VARIANT[service.value?.status] || 'neutral')
|
||||
|
||||
const requestDate = computed(() => formatJalaaliDate(service.value?.createdAt) || '—')
|
||||
|
||||
const messageTime = (message) => {
|
||||
if (!message.createdAt) return ''
|
||||
const d = new Date(message.createdAt)
|
||||
if (Number.isNaN(d.getTime())) return ''
|
||||
return d.toLocaleTimeString('fa-IR', { hour: '2-digit', minute: '2-digit' })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.sdm {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding-block: 0.25rem 0.5rem;
|
||||
text-align: start;
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&__top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&__date {
|
||||
background: #f5f5f5;
|
||||
color: #a3a3a3;
|
||||
border-radius: 9999px;
|
||||
padding: 0.3rem 0.875rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
line-height: 1.45;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__messages {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
&__bubble {
|
||||
position: relative;
|
||||
background: #f6f6f6;
|
||||
padding: 1rem 1rem 1.5rem;
|
||||
border-radius: 0.75rem 0.75rem 0 0.75rem;
|
||||
color: #454545;
|
||||
}
|
||||
|
||||
&__text {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 300;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.7;
|
||||
margin: 0;
|
||||
text-align: justify;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
&__time {
|
||||
position: absolute;
|
||||
inset-inline-end: 1rem;
|
||||
inset-block-end: 0.5rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.65rem;
|
||||
color: #a7a7a7;
|
||||
line-height: 1.45;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -33,12 +33,16 @@
|
||||
<PaginationBlock :pagination="historyMeta" @update:page="setHistoryPage" />
|
||||
</template>
|
||||
</TabsBlock>
|
||||
|
||||
<ServiceDetailsModal v-if="isModal('ServiceDetailsModal')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { toast } from 'vue3-toastify'
|
||||
import { TICKET_STATUS } from '@/enums'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
@@ -49,13 +53,15 @@ import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import ServiceItem from '@/features/student/services/components/ServiceItem.vue'
|
||||
import CreateServiceForm from '@/features/student/services/components/CreateServiceForm.vue'
|
||||
import ServiceDetailsModal from '@/features/student/services/components/modals/ServiceDetailsModal.vue'
|
||||
import {
|
||||
studentServicesKeys,
|
||||
useCreateStudentServiceMutation,
|
||||
useStudentServicesQuery,
|
||||
} from '@/services/query/student-services'
|
||||
studentTicketsKeys,
|
||||
useCreateStudentTicketMutation,
|
||||
useStudentTicketsQuery,
|
||||
} from '@/services/query/student-tickets'
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { openModal, isModal } = useModal()
|
||||
|
||||
const tabs = [
|
||||
{ name: 'create', label: 'درخواست خدمت', icon: 'paper-plane' },
|
||||
@@ -63,13 +69,13 @@ const tabs = [
|
||||
]
|
||||
const activeTab = ref('create')
|
||||
|
||||
const historyFilters = ref({})
|
||||
const historyFilters = ref({ type: 'service' })
|
||||
const { pagination: historyPagination, setPage: setHistoryPage } = usePagination({
|
||||
page: 1,
|
||||
perPage: 10,
|
||||
})
|
||||
|
||||
const { data: historyData, isLoading: historyLoading } = useStudentServicesQuery(
|
||||
const { data: historyData, isLoading: historyLoading } = useStudentTicketsQuery(
|
||||
historyFilters,
|
||||
historyPagination,
|
||||
{
|
||||
@@ -78,20 +84,37 @@ const { data: historyData, isLoading: historyLoading } = useStudentServicesQuery
|
||||
}
|
||||
)
|
||||
|
||||
const services = computed(() => historyData.value?.data ?? [])
|
||||
// ServiceItem expects title/requestNumber/typeLabel/statusLabel. Bridge the
|
||||
// new backend payload (subject/id/category/status) without changing the item
|
||||
// template.
|
||||
const services = computed(() =>
|
||||
(historyData.value?.data?.items ?? []).map((t) => ({
|
||||
...t,
|
||||
title: t.subject ?? '',
|
||||
requestNumber: t.id,
|
||||
typeLabel: t.category ?? '',
|
||||
statusLabel: TICKET_STATUS[t.status] ?? '',
|
||||
}))
|
||||
)
|
||||
const historyMeta = computed(() => ({
|
||||
page: historyPagination.value.page,
|
||||
perPage: historyPagination.value.perPage,
|
||||
...historyData.value?.meta,
|
||||
}))
|
||||
|
||||
const createMutation = useCreateStudentServiceMutation()
|
||||
const createMutation = useCreateStudentTicketMutation()
|
||||
|
||||
const onSubmit = async (payload) => {
|
||||
const onSubmit = async (formPayload) => {
|
||||
try {
|
||||
await createMutation.mutateAsync(payload)
|
||||
await createMutation.mutateAsync({
|
||||
type: 'service',
|
||||
category: formPayload.category,
|
||||
subject: formPayload.subject,
|
||||
message: formPayload.message,
|
||||
mediaIds: formPayload.mediaIds,
|
||||
})
|
||||
toast.success('درخواست خدمت با موفقیت ثبت شد.')
|
||||
await queryClient.invalidateQueries({ queryKey: studentServicesKeys.all })
|
||||
await queryClient.invalidateQueries({ queryKey: studentTicketsKeys.all })
|
||||
activeTab.value = 'history'
|
||||
} catch {
|
||||
toast.error('ثبت درخواست با خطا مواجه شد.')
|
||||
@@ -100,7 +123,9 @@ const onSubmit = async (payload) => {
|
||||
|
||||
const onFileError = (msg) => toast.warning(msg)
|
||||
|
||||
const onShowDetails = () => {}
|
||||
const onShowDetails = (service) => {
|
||||
openModal('ServiceDetailsModal', { id: service.id })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<div class="status-tile">
|
||||
<div class="status-tile__icon" :style="{ color: iconColor }">
|
||||
<SvgIcon :name="icon" :size="32" />
|
||||
</div>
|
||||
<p class="status-tile__label">{{ label }}</p>
|
||||
<p class="status-tile__count" :style="{ color: countColor }">{{ count }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
|
||||
defineProps({
|
||||
icon: { type: String, required: true },
|
||||
label: { type: String, required: true },
|
||||
count: { type: [Number, String], default: 0 },
|
||||
/** Hex color for the count number. Defaults to a neutral gray. */
|
||||
countColor: { type: String, default: '#4C4C4C' },
|
||||
/** Hex color for the icon. Defaults to a neutral gray. */
|
||||
iconColor: { type: String, default: '#A7A7A7' },
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.status-tile {
|
||||
flex: 0 0 12.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 0.5rem;
|
||||
padding: 0.875rem 0.75rem 1rem;
|
||||
background: rgba(255, 255, 255, 40%);
|
||||
box-shadow: 0 6.75px 19.4px rgba(0, 0, 0, 4%);
|
||||
border-radius: 0.75rem;
|
||||
min-height: 7rem;
|
||||
|
||||
&__icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 400;
|
||||
font-size: 0.95rem;
|
||||
line-height: 1.25;
|
||||
color: #4c4c4c;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__count {
|
||||
font-family: var(--font-family-en);
|
||||
font-weight: 500;
|
||||
font-size: 1rem;
|
||||
line-height: 1.75;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,168 @@
|
||||
<template>
|
||||
<div class="ticket-item">
|
||||
<div class="ticket-item__user">
|
||||
<div v-if="ticket.student?.avatarUrl" class="ticket-item__avatar">
|
||||
<img :src="ticket.student.avatarUrl" :alt="userName" />
|
||||
</div>
|
||||
<div v-else class="ticket-item__avatar ticket-item__avatar--placeholder">
|
||||
<SvgIcon name="user" :size="24" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="ticket-item__info">
|
||||
<p class="ticket-item__name">{{ userName }}</p>
|
||||
<p class="ticket-item__request-id">
|
||||
<span class="ticket-item__request-id-label">شماره درخواست :</span>
|
||||
<span class="ticket-item__request-id-value">{{ ticket.id || '—' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ticket-item__meta">
|
||||
<Badge variant="neutral" size="sm" label="تاریخ پیام :" :value="createdAt" />
|
||||
<Badge :variant="statusVariant" size="sm" dot :value="statusLabel" />
|
||||
</div>
|
||||
|
||||
<div class="ticket-item__actions">
|
||||
<BaseButton
|
||||
text="جزئیات تیکت"
|
||||
custom-class="ticket-item__details-btn"
|
||||
@click="emit('show-details', ticket)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { TICKET_STATUS } from '@/enums'
|
||||
import Badge from '@/components/Badge.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
const STATUS_VARIANT = {
|
||||
open: 'warning',
|
||||
answered: 'success',
|
||||
closed: 'info',
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
ticket: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['show-details'])
|
||||
|
||||
const userName = computed(() => props.ticket.student?.name || props.ticket.subject || '—')
|
||||
|
||||
const statusLabel = computed(() => TICKET_STATUS[props.ticket.status] || '—')
|
||||
const statusVariant = computed(() => STATUS_VARIANT[props.ticket.status] || 'neutral')
|
||||
|
||||
const createdAt = computed(() => formatJalaaliDate(props.ticket.createdAt) || '—')
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.ticket-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.625rem;
|
||||
padding: 0.75rem;
|
||||
background: rgba(255, 255, 255, 50%);
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
border-radius: 0.875rem;
|
||||
margin-bottom: 0.625rem;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
flex-flow: row wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__user {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
flex: 1 1 30%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
min-width: 3rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
}
|
||||
|
||||
&__info {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&__request-id {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
color: #8f8f8f;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__request-id-label {
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__request-id-value {
|
||||
font-family: var(--font-family-en);
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 45%;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 100%;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
}
|
||||
|
||||
&__details-btn {
|
||||
min-width: 9rem;
|
||||
padding: 0 0.875rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,249 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="58rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<form class="ctm" @submit.prevent="onSubmit(close)">
|
||||
<header class="ctm__header">
|
||||
<LineTitleBlock title="ارسال تیکت جدید" title-en="New ticket" />
|
||||
</header>
|
||||
|
||||
<div class="ctm__row ctm__row--two">
|
||||
<TextField
|
||||
v-model="form.subject"
|
||||
name="subject"
|
||||
label="موضوع را وارد کنید"
|
||||
placeholder="موضوع تیکت"
|
||||
:error="errors.subject"
|
||||
@blur="validateAt('subject', form.subject)"
|
||||
/>
|
||||
<SelectField
|
||||
v-model="form.priority"
|
||||
name="priority"
|
||||
label="اولویت تیکت"
|
||||
placeholder="انتخاب کنید"
|
||||
:options="priorityOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:error="errors.priority"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="ctm__row">
|
||||
<TextareaField
|
||||
v-model="form.message"
|
||||
name="message"
|
||||
label="توضیحات خودتان را وارد کنید"
|
||||
placeholder="لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است."
|
||||
:row="4"
|
||||
:error="errors.message"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="ctm__upload">
|
||||
<FileUploader
|
||||
v-model="files"
|
||||
accept="image/*,application/pdf"
|
||||
:max-files="5"
|
||||
@select="onFilesSelect"
|
||||
@error="onFileError"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="ctm__divider" />
|
||||
|
||||
<footer class="ctm__footer">
|
||||
<button type="button" class="ctm__cancel" @click="close">
|
||||
<span>منصرف شدم</span>
|
||||
<SvgIcon name="caret-left" :size="16" color="currentColor" />
|
||||
</button>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
text="ارسال تیکت"
|
||||
custom-class="ctm__submit"
|
||||
:loading="createMutation.isPending.value"
|
||||
:disabled="uploadMutation.isPending.value"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</footer>
|
||||
</form>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import * as yup from 'yup'
|
||||
import { toast } from 'vue3-toastify'
|
||||
import useYup from '@/composables/useYup'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import FileUploader from '@/components/form/FileUploader.vue'
|
||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||
import { useUploadMediaMutation } from '@/services/query/auth'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import {
|
||||
studentTicketsKeys,
|
||||
useCreateStudentTicketMutation,
|
||||
} from '@/services/query/student-tickets'
|
||||
|
||||
defineOptions({ name: 'CreateTicketModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const priorityOptions = [
|
||||
{ value: 'very_urgent', label: 'بسیار فوری' },
|
||||
{ value: 'urgent', label: 'فوری' },
|
||||
{ value: 'normal', label: 'عادی' },
|
||||
{ value: 'low', label: 'کم اهمیت' },
|
||||
]
|
||||
|
||||
const form = ref({
|
||||
subject: '',
|
||||
priority: 'very_urgent',
|
||||
message: '',
|
||||
})
|
||||
|
||||
// Uploaded-media descriptors { id, name, size, url }, populated as files are
|
||||
// picked. Submit just collects the IDs (same pattern as CreateServiceForm /
|
||||
// AddAssignmentModal).
|
||||
const files = ref([])
|
||||
|
||||
const schema = yup.object({
|
||||
subject: yup.string().trim().required('موضوع تیکت را وارد کنید'),
|
||||
priority: yup.string().required('اولویت را انتخاب کنید'),
|
||||
message: yup
|
||||
.string()
|
||||
.trim()
|
||||
.min(5, 'توضیحات حداقل ۵ کاراکتر باشد')
|
||||
.required('توضیحات را وارد کنید'),
|
||||
})
|
||||
|
||||
const { validate, validateAt, errors, resetErrors } = useYup(schema)
|
||||
|
||||
const uploadMutation = useUploadMediaMutation()
|
||||
const createMutation = useCreateStudentTicketMutation()
|
||||
|
||||
// FileUploader emits `select` on add (we upload + push the result) and
|
||||
// `update:modelValue` on remove (handled by v-model directly).
|
||||
const onFilesSelect = async (picked) => {
|
||||
for (const file of picked) {
|
||||
try {
|
||||
const fd = objectToFormData({ file, purpose: 'attachment', context: 'ticket' })
|
||||
const response = await uploadMutation.mutateAsync(fd)
|
||||
const payload = response?.data ?? response
|
||||
const id = payload?.id ?? payload?.uploadId
|
||||
if (id == null) continue
|
||||
files.value = [
|
||||
...files.value,
|
||||
{ id, name: file.name, size: file.size, url: payload?.url ?? '' },
|
||||
]
|
||||
} catch {
|
||||
toast.error(`بارگذاری فایل "${file.name}" با خطا مواجه شد.`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onFileError = (msg) => toast.warning(msg)
|
||||
|
||||
const onSubmit = async (close) => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
|
||||
try {
|
||||
await createMutation.mutateAsync({
|
||||
type: 'ticket',
|
||||
// Backend POST /student/tickets accepts `category` — we use it to carry
|
||||
// the FE-only priority value until the backend adds a dedicated field.
|
||||
category: payload.priority,
|
||||
subject: payload.subject,
|
||||
message: payload.message,
|
||||
mediaIds: files.value.map((f) => f.id).filter((id) => id != null),
|
||||
})
|
||||
await queryClient.invalidateQueries({ queryKey: studentTicketsKeys.all })
|
||||
toast.success('تیکت با موفقیت ثبت شد.')
|
||||
resetErrors()
|
||||
form.value = { subject: '', priority: 'very_urgent', message: '' }
|
||||
files.value = []
|
||||
close?.()
|
||||
} catch {
|
||||
toast.error('ارسال تیکت با خطا مواجه شد.')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.ctm {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
text-align: start;
|
||||
padding-block: 0.25rem 0.5rem;
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.875rem;
|
||||
|
||||
&--two {
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__upload {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid #ddd;
|
||||
margin-block: 0.25rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&__cancel {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 0.5rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: #969696;
|
||||
|
||||
&:hover {
|
||||
color: #6b6b6b;
|
||||
}
|
||||
}
|
||||
|
||||
&__submit {
|
||||
min-width: 16rem;
|
||||
padding: 0 1.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,144 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="جزئیات تیکت"
|
||||
title-en="Ticket details"
|
||||
width="95%"
|
||||
max-width="58rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default>
|
||||
<div class="tdm">
|
||||
<SkeletonLoaderBlock v-if="isLoading && !ticket" :rows="2" :cols-per-row="1" />
|
||||
|
||||
<template v-else-if="ticket">
|
||||
<div class="tdm__top">
|
||||
<Badge :variant="statusVariant" size="sm" dot :value="statusLabel" />
|
||||
<span class="tdm__date">{{ requestDate }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="messages.length > 0" class="tdm__messages">
|
||||
<div v-for="message in messages" :key="message.id" class="tdm__bubble">
|
||||
<p class="tdm__text">{{ message.message }}</p>
|
||||
<span class="tdm__time">{{ messageTime(message) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<NoItems v-else title="پیامی نیست" desc="هنوز پیامی برای این تیکت ثبت نشده است." />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { TICKET_STATUS } from '@/enums'
|
||||
import Badge from '@/components/Badge.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
import { useStudentTicketQuery } from '@/services/query/student-tickets'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
|
||||
defineOptions({ name: 'TicketDetailsModal' })
|
||||
|
||||
const STATUS_VARIANT = {
|
||||
open: 'warning',
|
||||
answered: 'success',
|
||||
closed: 'info',
|
||||
}
|
||||
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('TicketDetailsModal')?.data ?? {})
|
||||
const ticketId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const { data: ticket, isLoading } = useStudentTicketQuery(ticketId, {
|
||||
enabled: () => !!ticketId.value,
|
||||
})
|
||||
|
||||
const messages = computed(() => ticket.value?.messages ?? [])
|
||||
|
||||
const statusLabel = computed(() => TICKET_STATUS[ticket.value?.status] || '—')
|
||||
const statusVariant = computed(() => STATUS_VARIANT[ticket.value?.status] || 'neutral')
|
||||
|
||||
const requestDate = computed(() => formatJalaaliDate(ticket.value?.createdAt) || '—')
|
||||
|
||||
const messageTime = (message) => {
|
||||
if (!message.createdAt) return ''
|
||||
const d = new Date(message.createdAt)
|
||||
if (Number.isNaN(d.getTime())) return ''
|
||||
return d.toLocaleTimeString('fa-IR', { hour: '2-digit', minute: '2-digit' })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tdm {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding-block: 0.25rem 0.5rem;
|
||||
text-align: start;
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&__top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&__date {
|
||||
background: #f5f5f5;
|
||||
color: #a3a3a3;
|
||||
border-radius: 9999px;
|
||||
padding: 0.3rem 0.875rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
line-height: 1.45;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__messages {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
&__bubble {
|
||||
position: relative;
|
||||
background: #f6f6f6;
|
||||
padding: 1rem 1rem 1.5rem;
|
||||
border-radius: 0.75rem 0.75rem 0;
|
||||
color: #454545;
|
||||
}
|
||||
|
||||
&__text {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 300;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.7;
|
||||
margin: 0;
|
||||
text-align: justify;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
&__time {
|
||||
position: absolute;
|
||||
inset-inline-end: 1rem;
|
||||
inset-block-end: 0.5rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.65rem;
|
||||
color: #a7a7a7;
|
||||
line-height: 1.45;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,207 @@
|
||||
<template>
|
||||
<div class="tickets-page">
|
||||
<BoxedIconTitleBlock
|
||||
class="tickets-page__heading"
|
||||
title="تیکتهای من"
|
||||
desc="در این قسمت میتوانید تیکتهای خود را مدیریت کنید"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="chat" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<div class="tickets-page__tiles-scroll">
|
||||
<div class="tickets-page__tiles">
|
||||
<StatusTile
|
||||
v-for="tile in statusTiles"
|
||||
:key="tile.key"
|
||||
:icon="tile.icon"
|
||||
:label="tile.label"
|
||||
:count="tile.count"
|
||||
:count-color="tile.countColor"
|
||||
:icon-color="tile.iconColor"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tickets-page__title-bar">
|
||||
<SimpleTitleIconBlock title="لیست تمام تیکتها" class="tickets-page__list-title">
|
||||
<template #header-icon>
|
||||
<SvgIcon name="list-bullets" :size="16" color="#bcbcbc" />
|
||||
</template>
|
||||
</SimpleTitleIconBlock>
|
||||
<BaseButton
|
||||
type="button"
|
||||
text="ارسال تیکت جدید"
|
||||
custom-class="tickets-page__new-btn"
|
||||
@click="onNewTicket"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="plus" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="6" :cols-per-row="1" />
|
||||
<div v-else-if="tickets.length > 0">
|
||||
<TicketItem
|
||||
v-for="ticket in tickets"
|
||||
:key="ticket.id"
|
||||
:ticket="ticket"
|
||||
@show-details="onShowDetails"
|
||||
/>
|
||||
</div>
|
||||
<NoItems v-else title="موردی نیست" desc="هنوز تیکتی ثبت نکردهاید." />
|
||||
|
||||
<PaginationBlock :pagination="paginationMeta" @update:page="setPage" />
|
||||
|
||||
<TicketDetailsModal v-if="isModal('TicketDetailsModal')" />
|
||||
<CreateTicketModal v-if="isModal('CreateTicketModal')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import { useStudentTicketsQuery } from '@/services/query/student-tickets'
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import StatusTile from '@/features/student/tickets/components/StatusTile.vue'
|
||||
import TicketItem from '@/features/student/tickets/components/TicketItem.vue'
|
||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||
import CreateTicketModal from '@/features/student/tickets/components/modals/CreateTicketModal.vue'
|
||||
import TicketDetailsModal from '@/features/student/tickets/components/modals/TicketDetailsModal.vue'
|
||||
|
||||
const { openModal, isModal } = useModal()
|
||||
|
||||
const filters = ref({ type: 'ticket' })
|
||||
const { pagination, setPage } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = useStudentTicketsQuery(filters, pagination, {
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
// The query select normalizes to { data: Array, meta }. The page also tolerates
|
||||
// a backend that nests under `data.items` (Laravel-style pagination) until the
|
||||
// backend shape is locked in.
|
||||
const tickets = computed(() => {
|
||||
const raw = data.value?.data
|
||||
if (Array.isArray(raw)) return raw
|
||||
if (Array.isArray(raw?.items)) return raw.items
|
||||
return []
|
||||
})
|
||||
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const statusTiles = computed(() => {
|
||||
const list = tickets.value
|
||||
const countBy = (predicate) => list.filter((_el) => predicate(_el)).length
|
||||
return [
|
||||
{
|
||||
key: 'all',
|
||||
icon: 'list-bullets',
|
||||
label: 'همه تیکتها',
|
||||
count: list.length,
|
||||
iconColor: '#A7A7A7',
|
||||
countColor: '#4C4C4C',
|
||||
},
|
||||
{
|
||||
key: 'open',
|
||||
icon: 'chat',
|
||||
label: 'باز',
|
||||
count: countBy((t) => t.status === 'open'),
|
||||
iconColor: '#CC6F00',
|
||||
countColor: '#CC6F00',
|
||||
},
|
||||
{
|
||||
key: 'in_review',
|
||||
icon: 'chat-centered-dots',
|
||||
label: 'در حال بررسی',
|
||||
count: countBy((t) => t.status === 'answered' && t.assignee),
|
||||
iconColor: '#007074',
|
||||
countColor: '#007074',
|
||||
},
|
||||
{
|
||||
key: 'answered',
|
||||
icon: 'check-square',
|
||||
label: 'پاسخ داده شده',
|
||||
count: countBy((t) => t.status === 'answered'),
|
||||
iconColor: '#33BE65',
|
||||
countColor: '#33BE65',
|
||||
},
|
||||
{
|
||||
key: 'closed',
|
||||
icon: 'close',
|
||||
label: 'بسته شده',
|
||||
count: countBy((t) => t.status === 'closed'),
|
||||
iconColor: '#CC2831',
|
||||
countColor: '#CC2831',
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
const onShowDetails = (ticket) => {
|
||||
openModal('TicketDetailsModal', { id: ticket.id })
|
||||
}
|
||||
|
||||
const onNewTicket = () => {
|
||||
openModal('CreateTicketModal')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tickets-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
// Horizontal scroll for the 5 status tiles on small screens.
|
||||
&__tiles-scroll {
|
||||
overflow: auto hidden;
|
||||
margin-inline: -0.25rem;
|
||||
padding-inline: 0.25rem;
|
||||
padding-block: 0.5rem;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
&__tiles {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 0.75rem;
|
||||
min-width: max-content;
|
||||
}
|
||||
|
||||
&__title-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
margin-block: 0.5rem 0.25rem;
|
||||
}
|
||||
|
||||
&__list-title {
|
||||
margin-bottom: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
&__new-btn {
|
||||
min-width: 11rem;
|
||||
height: 2.25rem;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user