first commit
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
<template>
|
||||
<div class="assignment-item">
|
||||
<div class="assignment-item__main">
|
||||
<p class="assignment-item__title">{{ assignment.title || '—' }}</p>
|
||||
<div class="assignment-item__sub">
|
||||
<span class="assignment-item__sub-label">دوره:</span>
|
||||
<span class="assignment-item__sub-value">
|
||||
{{ assignment.courseTemplate?.title || assignment.courseTemplateTitle || '—' }}
|
||||
</span>
|
||||
<span class="assignment-item__dot">|</span>
|
||||
<span class="assignment-item__sub-label">جلسه:</span>
|
||||
<span class="assignment-item__sub-value">
|
||||
{{ assignment.session?.title || assignment.sessionTitle || '—' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="assignment-item__meta">
|
||||
<div class="assignment-item__pill">
|
||||
<span class="assignment-item__pill-label">مدت زمان ارسال:</span>
|
||||
<span class="assignment-item__pill-value">{{ duration }}</span>
|
||||
</div>
|
||||
<div class="assignment-item__pill">
|
||||
<span class="assignment-item__pill-label">تعداد فرستندگان:</span>
|
||||
<span class="assignment-item__pill-value">{{ submissions }}</span>
|
||||
</div>
|
||||
<div class="assignment-item__pill">
|
||||
<span class="assignment-item__pill-label">تاریخ ثبت:</span>
|
||||
<span class="assignment-item__pill-value">{{ createdAt }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="assignment-item__actions">
|
||||
<CircleButton
|
||||
tooltip="تکالیف ارسالشده"
|
||||
bg-color="rgba(0, 112, 116, 0.08)"
|
||||
size="2.5rem"
|
||||
@click="emit('show-submissions', assignment)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="users-three" :size="18" color="#007074" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="حذف"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('delete', assignment)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="18" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="ویرایش"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('edit', assignment)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="pencil" :size="18" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<BaseButton
|
||||
text="جزئیات تکلیف"
|
||||
custom-class="assignment-item__details-btn"
|
||||
@click="emit('show-details', assignment)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
const props = defineProps({
|
||||
assignment: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['edit', 'delete', 'show-details', 'show-submissions'])
|
||||
|
||||
const duration = computed(() =>
|
||||
props.assignment.durationDays == null ? '—' : `${props.assignment.durationDays} روز`
|
||||
)
|
||||
|
||||
const submissions = computed(() =>
|
||||
props.assignment.submissionsCount == null ? '—' : `${props.assignment.submissionsCount} نفر`
|
||||
)
|
||||
|
||||
const createdAt = computed(
|
||||
() => props.assignment.faCreatedAt || formatJalaaliDate(props.assignment.createdAt) || '—'
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.assignment-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;
|
||||
}
|
||||
|
||||
&__main {
|
||||
flex: 1 1 25%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__sub-label {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
&__sub-value {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&__dot {
|
||||
color: #c4c4c4;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 41%;
|
||||
}
|
||||
|
||||
&__pill {
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
padding: 0.25rem 1rem;
|
||||
border-radius: 0.875rem;
|
||||
line-height: 1.5;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__pill-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 300;
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__pill-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 500;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 100%;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
}
|
||||
|
||||
&__details-btn {
|
||||
min-width: 8rem;
|
||||
padding: 0 0.875rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,175 @@
|
||||
<template>
|
||||
<form class="assignments-filters" @submit.prevent="onSubmit">
|
||||
<div class="assignments-filters__grid">
|
||||
<TextField v-model="form.title" name="title" label="عنوان تکلیف">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="book" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.courseTemplateId"
|
||||
name="courseTemplateId"
|
||||
label="دوره الگو"
|
||||
:options="templateOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchTemplates"
|
||||
/>
|
||||
<SelectField
|
||||
v-model="form.sessionId"
|
||||
name="sessionId"
|
||||
label="جلسه"
|
||||
:options="sessionOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchSessions"
|
||||
/>
|
||||
<DatePickerField v-model="form.fromDate" name="fromDate" label="از تاریخ" :max="todayIso" />
|
||||
<DatePickerField v-model="form.toDate" name="toDate" label="تا تاریخ" :max="todayIso" />
|
||||
</div>
|
||||
|
||||
<div class="assignments-filters__actions">
|
||||
<CircleButton
|
||||
v-if="hasFilters"
|
||||
tooltip="حذف فیلتر"
|
||||
bg-color="transparent"
|
||||
size="2.5rem"
|
||||
type="button"
|
||||
@click="onReset"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="اعمال فیلتر"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
type="submit"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="funnel" :size="20" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { useAdminCourseTemplatesListQuery } from '@/services/query/admin-course-templates'
|
||||
import { useAdminSessionsListQuery } from '@/services/query/admin-sessions'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
title: '',
|
||||
courseTemplateId: '',
|
||||
sessionId: '',
|
||||
fromDate: '',
|
||||
toDate: '',
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'apply', 'reset'])
|
||||
|
||||
const emptyForm = () => ({
|
||||
title: '',
|
||||
courseTemplateId: '',
|
||||
sessionId: '',
|
||||
fromDate: '',
|
||||
toDate: '',
|
||||
})
|
||||
const form = ref({ ...emptyForm(), ...props.modelValue })
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(next) => {
|
||||
form.value = { ...emptyForm(), ...next }
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const todayIso = new Date().toISOString()
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: templatesResponse } = useAdminCourseTemplatesListQuery(
|
||||
templateFilters,
|
||||
templatePagination
|
||||
)
|
||||
const templateOptions = computed(() => templatesResponse.value?.data ?? [])
|
||||
|
||||
const sessionSearch = ref('')
|
||||
const sessionListFilters = computed(() => ({
|
||||
title: sessionSearch.value,
|
||||
courseTemplateId: form.value.courseTemplateId || undefined,
|
||||
}))
|
||||
const sessionPagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: sessionsResponse } = useAdminSessionsListQuery(sessionListFilters, sessionPagination)
|
||||
const sessionOptions = computed(() => sessionsResponse.value?.data ?? [])
|
||||
|
||||
const searchTemplates = useDebounce((q) => {
|
||||
templateSearch.value = q || ''
|
||||
}, 400)
|
||||
const searchSessions = useDebounce((q) => {
|
||||
sessionSearch.value = q || ''
|
||||
}, 400)
|
||||
|
||||
const hasFilters = computed(() =>
|
||||
Object.values(form.value).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
)
|
||||
|
||||
const onSubmit = () => {
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('apply', { ...form.value })
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
form.value = emptyForm()
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.assignments-filters {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
|
||||
&__grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding-top: 1.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,325 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="64rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<form class="add-assignment" @submit.prevent="onSubmit(close)">
|
||||
<LineTitleBlock
|
||||
:title="isEditMode ? 'ویرایش تکلیف' : 'افزودن تکلیف جدید'"
|
||||
:title-en="isEditMode ? 'Edit Assignment' : 'Add Assignment'"
|
||||
/>
|
||||
|
||||
<div class="add-assignment__grid">
|
||||
<TextField
|
||||
v-model="form.title"
|
||||
name="title"
|
||||
label="عنوان تکلیف"
|
||||
:error="errors.title"
|
||||
@blur="validateAt('title', form.title)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="book" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.courseTemplateId"
|
||||
name="courseTemplateId"
|
||||
label="دوره مرتبط"
|
||||
:options="templateOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchTemplates"
|
||||
:error="errors.courseTemplateId"
|
||||
@update:model-value="onCourseChange"
|
||||
/>
|
||||
<SelectField
|
||||
v-model="form.sessionId"
|
||||
name="sessionId"
|
||||
label="جلسه مرتبط"
|
||||
:options="sessionOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchSessions"
|
||||
:disabled="!form.courseTemplateId"
|
||||
:error="errors.sessionId"
|
||||
/>
|
||||
<DatePickerField
|
||||
v-model="form.startDate"
|
||||
name="startDate"
|
||||
label="تاریخ شروع"
|
||||
:error="errors.startDate"
|
||||
/>
|
||||
<DatePickerField
|
||||
v-model="form.endDate"
|
||||
name="endDate"
|
||||
label="تاریخ پایان"
|
||||
:error="errors.endDate"
|
||||
/>
|
||||
<SelectField
|
||||
v-model="form.priority"
|
||||
name="priority"
|
||||
label="اولویت"
|
||||
:options="priorityOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:error="errors.priority"
|
||||
/>
|
||||
<div class="add-assignment__cell--full">
|
||||
<TextareaField
|
||||
v-model="form.description"
|
||||
name="description"
|
||||
label="توضیحات تکلیف"
|
||||
:row="5"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="add-assignment__files">
|
||||
<LineTitleBlock title="فایلهای تکلیف" title-en="Assignment Files" />
|
||||
<FileUploader
|
||||
v-model="attachments"
|
||||
accept=".mp4,.mov,.avi,.mp3,.wav,.jpg,.jpeg,.png,.pdf,.txt,.doc,.docx"
|
||||
:multiple="true"
|
||||
:max-files="10"
|
||||
context="assignment"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="add-assignment__divider" />
|
||||
|
||||
<div class="add-assignment__actions">
|
||||
<BaseButton
|
||||
variant="transparent"
|
||||
text="منصرف شدم"
|
||||
custom-class="add-assignment__btn-cancel"
|
||||
@click="close"
|
||||
>
|
||||
<template #prependIcon>
|
||||
<SvgIcon name="caret-right" :size="14" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
text="تایید اطلاعات"
|
||||
:loading="submitting"
|
||||
custom-class="add-assignment__btn-submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import FileUploader from '@/components/form/FileUploader.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import useYup from '@/composables/useYup'
|
||||
import {
|
||||
adminAssignmentsKeys,
|
||||
useAddAdminAssignmentMutation,
|
||||
useAdminAssignmentQuery,
|
||||
useUpdateAdminAssignmentMutation,
|
||||
} from '@/services/query/admin-assignments'
|
||||
import { useAdminCourseTemplatesListQuery } from '@/services/query/admin-course-templates'
|
||||
import { useAdminSessionsListQuery } from '@/services/query/admin-sessions'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
import { ASSIGNMENT_PRIORITY } from '@/enums'
|
||||
import { assignmentSchema } from '@/features/admin/assignments/schema'
|
||||
|
||||
defineOptions({ name: 'AddAssignmentModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('AddAssignmentModal')?.data ?? {})
|
||||
const assignmentId = computed(() => modalData.value.id ?? null)
|
||||
const isEditMode = computed(() => !!assignmentId.value)
|
||||
|
||||
const priorityOptions = Object.entries(ASSIGNMENT_PRIORITY).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
|
||||
const form = ref({
|
||||
title: '',
|
||||
courseTemplateId: '',
|
||||
sessionId: '',
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
priority: 'mandatory',
|
||||
description: '',
|
||||
})
|
||||
|
||||
const attachments = ref([])
|
||||
|
||||
const schema = assignmentSchema
|
||||
|
||||
const { validate, validateAt, errors, resetErrors } = useYup(schema)
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: templatesResponse } = useAdminCourseTemplatesListQuery(
|
||||
templateFilters,
|
||||
templatePagination
|
||||
)
|
||||
const selectedTemplate = ref(null)
|
||||
const templateOptions = computed(() => {
|
||||
const base = templatesResponse.value?.data ?? []
|
||||
if (selectedTemplate.value && !base.some((t) => t.id === selectedTemplate.value.id)) {
|
||||
return [...base, selectedTemplate.value]
|
||||
}
|
||||
return base
|
||||
})
|
||||
|
||||
const sessionSearch = ref('')
|
||||
const sessionFilters = computed(() => ({
|
||||
title: sessionSearch.value,
|
||||
courseTemplateId: form.value.courseTemplateId,
|
||||
}))
|
||||
const sessionPagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: sessionsResponse } = useAdminSessionsListQuery(sessionFilters, sessionPagination, {
|
||||
enabled: () => !!form.value.courseTemplateId,
|
||||
})
|
||||
const selectedSession = ref(null)
|
||||
const sessionOptions = computed(() => {
|
||||
const base = sessionsResponse.value?.data ?? []
|
||||
if (selectedSession.value && !base.some((s) => s.id === selectedSession.value.id)) {
|
||||
return [...base, selectedSession.value]
|
||||
}
|
||||
return base
|
||||
})
|
||||
|
||||
const searchTemplates = useDebounce((q) => {
|
||||
templateSearch.value = q || ''
|
||||
}, 400)
|
||||
const searchSessions = useDebounce((q) => {
|
||||
sessionSearch.value = q || ''
|
||||
}, 400)
|
||||
|
||||
const onCourseChange = (value) => {
|
||||
form.value.courseTemplateId = value
|
||||
form.value.sessionId = ''
|
||||
selectedSession.value = null
|
||||
}
|
||||
|
||||
const { data: existingAssignment } = useAdminAssignmentQuery(assignmentId, {
|
||||
enabled: () => !!assignmentId.value,
|
||||
})
|
||||
|
||||
watch(existingAssignment, (assignment) => {
|
||||
if (!assignment) return
|
||||
const tpl = assignment.courseTemplate
|
||||
const sessionEntity = assignment.session
|
||||
if (tpl) selectedTemplate.value = tpl
|
||||
if (sessionEntity) selectedSession.value = sessionEntity
|
||||
form.value = {
|
||||
title: assignment.title || '',
|
||||
courseTemplateId: tpl?.id || assignment.courseTemplateId || '',
|
||||
sessionId: sessionEntity?.id || assignment.sessionId || '',
|
||||
startDate: assignment.startDate || '',
|
||||
endDate: assignment.endDate || '',
|
||||
priority: assignment.priority || 'mandatory',
|
||||
description: assignment.description || '',
|
||||
}
|
||||
attachments.value = Array.isArray(assignment.attachments)
|
||||
? assignment.attachments.map((file) => ({
|
||||
id: file.id,
|
||||
name: file.title || `فایل ${file.id}`,
|
||||
url: file.fileUrl || '',
|
||||
type: file.type || 'other',
|
||||
}))
|
||||
: []
|
||||
})
|
||||
|
||||
const addMutation = useAddAdminAssignmentMutation()
|
||||
const updateMutation = useUpdateAdminAssignmentMutation()
|
||||
|
||||
const submitting = computed(() => addMutation.isPending.value || updateMutation.isPending.value)
|
||||
|
||||
const onSubmit = async (close) => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
const finalPayload = {
|
||||
...payload,
|
||||
attachments: attachments.value.map((file, index) => ({
|
||||
fileId: file.id,
|
||||
type: file.type || 'other',
|
||||
title: file.name,
|
||||
order: index + 1,
|
||||
})),
|
||||
}
|
||||
if (isEditMode.value) {
|
||||
await updateMutation.mutateAsync({ id: assignmentId.value, payload: finalPayload })
|
||||
} else {
|
||||
await addMutation.mutateAsync(finalPayload)
|
||||
}
|
||||
await queryClient.invalidateQueries({ queryKey: adminAssignmentsKeys.all })
|
||||
resetErrors()
|
||||
close()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.add-assignment {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
padding: 0.5rem 0;
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
margin-block: 0.75rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__cell--full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
&__files {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.5rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
&__btn-submit {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,205 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="جزئیات تکلیف"
|
||||
title-en="Assignment Details"
|
||||
width="95%"
|
||||
max-width="60rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ close }">
|
||||
<div class="assignment-details">
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="3" :cols-per-row="1" />
|
||||
<template v-else-if="assignment">
|
||||
<div class="assignment-details__head">
|
||||
<p class="assignment-details__title">{{ assignment.title || '—' }}</p>
|
||||
<p class="assignment-details__sub">
|
||||
<span>
|
||||
دوره:
|
||||
{{ assignment.courseTemplate?.title || assignment.courseTemplateTitle || '—' }}
|
||||
</span>
|
||||
<span class="assignment-details__sep">|</span>
|
||||
<span>جلسه: {{ assignment.session?.title || assignment.sessionTitle || '—' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="assignment-details__grid">
|
||||
<LineInfoBlock
|
||||
title="تاریخ شروع"
|
||||
:numeric-desc="formatJalaaliDate(assignment.startDate) || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="تاریخ پایان"
|
||||
:numeric-desc="formatJalaaliDate(assignment.endDate) || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="مدت زمان"
|
||||
:numeric-desc="
|
||||
assignment.durationDays != null ? `${assignment.durationDays} روز` : '—'
|
||||
"
|
||||
/>
|
||||
<LineInfoBlock title="اولویت" :desc="ASSIGNMENT_PRIORITY[assignment.priority] || '—'" />
|
||||
<LineInfoBlock
|
||||
title="تعداد فرستندگان"
|
||||
:numeric-desc="assignment.submissionsCount ?? 0"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="تاریخ ثبت"
|
||||
:numeric-desc="
|
||||
assignment.faCreatedAt || formatJalaaliDate(assignment.createdAt) || '—'
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="assignment.description" class="assignment-details__desc">
|
||||
<LineInfoBlock title="توضیحات" :desc="assignment.description" />
|
||||
</div>
|
||||
|
||||
<div v-if="assignment.attachments?.length" class="assignment-details__attachments">
|
||||
<LineTitleBlock title="فایلهای تکلیف" title-en="Attachments" />
|
||||
<ul class="assignment-details__attachments-list">
|
||||
<li v-for="file in assignment.attachments" :key="file.id">
|
||||
<a
|
||||
:href="file.fileUrl || '#'"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="assignment-details__file"
|
||||
>
|
||||
<SvgIcon name="file" :size="16" color="var(--color-prim-gray)" />
|
||||
<span>{{ file.title || `فایل ${file.id}` }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
<NoItems v-else title="یافت نشد" desc="اطلاعات این تکلیف در دسترس نیست." />
|
||||
|
||||
<div class="assignment-details__divider" />
|
||||
|
||||
<div class="assignment-details__footer">
|
||||
<BaseButton text="بستن" custom-class="assignment-details__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { useAdminAssignmentQuery } from '@/services/query/admin-assignments'
|
||||
import { ASSIGNMENT_PRIORITY } from '@/enums'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'AssignmentDetailsModal' })
|
||||
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('AssignmentDetailsModal')?.data ?? {})
|
||||
const assignmentId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const { data: assignment, isLoading } = useAdminAssignmentQuery(assignmentId, {
|
||||
enabled: () => !!assignmentId.value,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.assignment-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__head {
|
||||
margin: 1rem 0 0.5rem;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1.1rem;
|
||||
font-weight: 500;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #535353;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: #c4c4c4;
|
||||
}
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.25rem;
|
||||
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__desc,
|
||||
&__attachments {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
&__attachments-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
&__file {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
color: var(--color-primary);
|
||||
text-decoration: none;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 10rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+350
@@ -0,0 +1,350 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="55rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<div class="submission-details">
|
||||
<LineTitleBlock title="جزئیات تکلیف" title-en="Submission Details" />
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="3" :cols-per-row="1" />
|
||||
<template v-else-if="submission">
|
||||
<div class="submission-details__person">
|
||||
<div v-if="submission.user?.avatarUrl" class="submission-details__avatar">
|
||||
<img :src="submission.user.avatarUrl" :alt="userName" />
|
||||
</div>
|
||||
<div v-else class="submission-details__avatar submission-details__avatar--placeholder">
|
||||
<SvgIcon name="user" :size="32" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="submission-details__person-grid">
|
||||
<LineInfoBlock title="نام و نام خانوادگی" :desc="userName" />
|
||||
<LineInfoBlock
|
||||
title="وضعیت تحصیلی"
|
||||
:desc="EDUCATION_STATUS[submission.user?.profile?.educationStatus] || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="آخرین مدرک تحصیلی (طلبه)"
|
||||
:desc="SEMINARY_LEVEL[submission.user?.profile?.seminaryLevel] || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="آخرین مدرک تحصیلی"
|
||||
:desc="UNIVERSITY_LEVEL[submission.user?.profile?.universityLevel] || '—'"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="submission-details__assignment">
|
||||
<p class="submission-details__assignment-title">{{ assignmentTitle }}</p>
|
||||
<div class="submission-details__assignment-meta">
|
||||
<span>ترم: {{ submission.termTitle || '—' }}</span>
|
||||
<span class="submission-details__sep">|</span>
|
||||
<span>دوره: {{ submission.courseTemplateTitle || '—' }}</span>
|
||||
<span class="submission-details__sep">|</span>
|
||||
<span>جلسه: {{ submission.sessionTitle || '—' }}</span>
|
||||
<span class="submission-details__sep">|</span>
|
||||
<span>تاریخ: {{ submittedAt }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="submission-details__row">
|
||||
<LineInfoBlock title="پاسخ دانشجو" :desc="submission.userDescription || '—'" />
|
||||
</div>
|
||||
|
||||
<div v-if="submission.attachments?.length" class="submission-details__attachments">
|
||||
<p class="submission-details__attachments-title">فایلهای ارسالی</p>
|
||||
<ul>
|
||||
<li v-for="file in submission.attachments" :key="file.id">
|
||||
<a
|
||||
:href="file.fileUrl || '#'"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="submission-details__file"
|
||||
>
|
||||
<SvgIcon name="file" :size="16" color="var(--color-prim-gray)" />
|
||||
<span>{{ file.title || `فایل ${file.id}` }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<form class="submission-details__review" @submit.prevent="onSubmit(close)">
|
||||
<div class="submission-details__review-grid">
|
||||
<TextField
|
||||
v-model="form.score"
|
||||
name="score"
|
||||
label="نمره"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
:error="errors.score"
|
||||
@blur="validateAt('score', form.score)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="check" :size="18" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.status"
|
||||
name="status"
|
||||
label="وضعیت"
|
||||
:options="statusOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:error="errors.status"
|
||||
/>
|
||||
</div>
|
||||
<TextareaField
|
||||
v-model="form.reviewerNote"
|
||||
name="reviewerNote"
|
||||
label="بازخورد"
|
||||
:row="4"
|
||||
/>
|
||||
|
||||
<div class="submission-details__divider" />
|
||||
|
||||
<div class="submission-details__actions">
|
||||
<BaseButton
|
||||
variant="transparent"
|
||||
text="بستن"
|
||||
custom-class="submission-details__btn-cancel"
|
||||
@click="close"
|
||||
/>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
text="ثبت بازخورد"
|
||||
:loading="reviewMutation.isPending.value"
|
||||
custom-class="submission-details__btn-submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
<NoItems v-else title="موردی یافت نشد" desc="جزئیات این تکلیف در دسترس نیست." />
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import useYup from '@/composables/useYup'
|
||||
import {
|
||||
adminAssignmentsKeys,
|
||||
useAdminAssignmentSubmissionQuery,
|
||||
useReviewAdminAssignmentSubmissionMutation,
|
||||
} from '@/services/query/admin-assignments'
|
||||
import { EDUCATION_STATUS, SEMINARY_LEVEL, UNIVERSITY_LEVEL } from '@/enums'
|
||||
import { assignmentSubmissionReviewSchema } from '@/features/admin/assignments/schema'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'AssignmentSubmissionDetailsModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('AssignmentSubmissionDetailsModal')?.data ?? {})
|
||||
const assignmentId = computed(() => modalData.value.assignmentId ?? null)
|
||||
const submissionId = computed(() => modalData.value.submissionId ?? null)
|
||||
|
||||
const { data: fetched, isLoading } = useAdminAssignmentSubmissionQuery(assignmentId, submissionId, {
|
||||
enabled: () => !!assignmentId.value && !!submissionId.value,
|
||||
})
|
||||
|
||||
const submission = computed(() => fetched.value || modalData.value.submission || null)
|
||||
|
||||
const userName = computed(() => {
|
||||
const u = submission.value?.user
|
||||
if (!u) return '—'
|
||||
return `${u.firstName || ''} ${u.lastName || ''}`.trim() || u.fullName || '—'
|
||||
})
|
||||
|
||||
const assignmentTitle = computed(
|
||||
() => submission.value?.assignment?.title || modalData.value.assignmentTitle || '—'
|
||||
)
|
||||
|
||||
const submittedAt = computed(
|
||||
() => submission.value?.faSubmittedAt || formatJalaaliDate(submission.value?.submittedAt) || '—'
|
||||
)
|
||||
|
||||
const statusOptions = [
|
||||
{ value: 'pending', label: 'در انتظار بررسی' },
|
||||
{ value: 'approved', label: 'تایید شده' },
|
||||
{ value: 'rejected', label: 'رد شده' },
|
||||
{ value: 'needs_revision', label: 'نیازمند اصلاح' },
|
||||
]
|
||||
|
||||
const schema = assignmentSubmissionReviewSchema
|
||||
|
||||
const { validate, validateAt, errors } = useYup(schema)
|
||||
|
||||
const form = ref({ score: '', status: 'approved', reviewerNote: '' })
|
||||
|
||||
watch(submission, (sub) => {
|
||||
if (!sub) return
|
||||
form.value = {
|
||||
score: sub.score ?? '',
|
||||
status: sub.status || 'approved',
|
||||
reviewerNote: sub.reviewerNote || '',
|
||||
}
|
||||
})
|
||||
|
||||
const reviewMutation = useReviewAdminAssignmentSubmissionMutation()
|
||||
|
||||
const onSubmit = async (close) => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
await reviewMutation.mutateAsync({
|
||||
assignmentId: assignmentId.value,
|
||||
submissionId: submissionId.value,
|
||||
payload,
|
||||
})
|
||||
await queryClient.invalidateQueries({ queryKey: adminAssignmentsKeys.all })
|
||||
close()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.submission-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__person {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
margin: 1rem 0 1.25rem;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 4.9rem;
|
||||
height: 4.9rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
background: #f5f5f5;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__person-grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.25rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__assignment {
|
||||
border-inline-end: 3px solid #ebebeb;
|
||||
padding-inline-end: 0.875rem;
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
&__assignment-title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__assignment-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: #d6d6d6;
|
||||
}
|
||||
|
||||
&__row {
|
||||
margin-block: 0.5rem;
|
||||
}
|
||||
|
||||
&__attachments {
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
&__attachments-title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
color: var(--color-prim-gray);
|
||||
margin: 0 0 0.5rem;
|
||||
}
|
||||
|
||||
&__file {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
color: var(--color-primary);
|
||||
text-decoration: none;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
padding: 0.25rem 0;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
&__review {
|
||||
margin-top: 1.25rem;
|
||||
}
|
||||
|
||||
&__review-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
&__btn-submit {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,237 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="60rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ data, close }">
|
||||
<div class="assignment-submissions">
|
||||
<LineTitleBlock title="تکالیف فرستادگان" title-en="Delegates’ Submissions" />
|
||||
<p v-if="data?.title" class="assignment-submissions__assignment">{{ data.title }}</p>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="4" :cols-per-row="1" />
|
||||
<div v-else-if="submissions.length > 0" class="assignment-submissions__list">
|
||||
<div
|
||||
v-for="submission in submissions"
|
||||
:key="submission.id"
|
||||
class="assignment-submissions__row"
|
||||
>
|
||||
<div class="assignment-submissions__user">
|
||||
<div v-if="submission.user?.avatarUrl" class="assignment-submissions__avatar">
|
||||
<img :src="submission.user.avatarUrl" :alt="userName(submission.user)" />
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="assignment-submissions__avatar assignment-submissions__avatar--placeholder"
|
||||
>
|
||||
<SvgIcon name="user" :size="20" color="#bcbcbc" />
|
||||
</div>
|
||||
<div>
|
||||
<p class="assignment-submissions__name">{{ userName(submission.user) }}</p>
|
||||
<p class="assignment-submissions__location">
|
||||
{{ locationFromAddress(submission.user) || '—' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="assignment-submissions__pill">
|
||||
<span class="assignment-submissions__pill-label">تاریخ ارسال:</span>
|
||||
<span class="assignment-submissions__pill-value">{{ submittedAt(submission) }}</span>
|
||||
</div>
|
||||
|
||||
<BaseButton
|
||||
text="جزئیات"
|
||||
custom-class="assignment-submissions__details-btn"
|
||||
@click="onShowDetails(submission)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="14" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
<NoItems v-else title="موردی یافت نشد" desc="تکلیفی ارسال نشده است." />
|
||||
|
||||
<PaginationBlock :pagination="paginationMeta" @update:page="setPage" />
|
||||
|
||||
<div class="assignment-submissions__divider" />
|
||||
|
||||
<div class="assignment-submissions__footer">
|
||||
<BaseButton text="بستن" custom-class="assignment-submissions__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import { useAdminAssignmentSubmissionsQuery } from '@/services/query/admin-assignments'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'AssignmentSubmissionsModal' })
|
||||
|
||||
const { getModal, openModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('AssignmentSubmissionsModal')?.data ?? {})
|
||||
const assignmentId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const filters = ref({})
|
||||
const { pagination, setPage } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = useAdminAssignmentSubmissionsQuery(assignmentId, filters, pagination, {
|
||||
enabled: () => !!assignmentId.value,
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
const submissions = computed(() => data.value?.data ?? [])
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const userName = (user) =>
|
||||
`${user?.firstName || ''} ${user?.lastName || ''}`.trim() || user?.fullName || '—'
|
||||
|
||||
const locationFromAddress = (user) => {
|
||||
const province = user?.address?.province?.name || ''
|
||||
const city = user?.address?.city?.name || ''
|
||||
return [province, city].filter(Boolean).join('، ')
|
||||
}
|
||||
|
||||
const submittedAt = (sub) => sub.faSubmittedAt || formatJalaaliDate(sub.submittedAt) || '—'
|
||||
|
||||
const onShowDetails = (submission) => {
|
||||
openModal('AssignmentSubmissionDetailsModal', {
|
||||
assignmentId: assignmentId.value,
|
||||
submissionId: submission.id,
|
||||
submission,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.assignment-submissions {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__assignment {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
color: var(--color-prim-gray);
|
||||
margin: 0 0 0.75rem;
|
||||
}
|
||||
|
||||
&__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: rgba(255, 255, 255, 60%);
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&__user {
|
||||
flex: 1 1 40%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 2.75rem;
|
||||
height: 2.75rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
background: #f5f5f5;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__location {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
color: #989898;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__pill {
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
border-radius: 0.875rem;
|
||||
padding: 0.375rem 1rem;
|
||||
text-align: center;
|
||||
min-width: 9rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__pill-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__pill-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__details-btn {
|
||||
min-width: 5rem;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,150 @@
|
||||
<template>
|
||||
<div class="assignments-page">
|
||||
<BoxedIconTitleBlock
|
||||
class="assignments-page__heading"
|
||||
title="مدیریت تکالیف"
|
||||
desc="در این قسمت میتوانید تکالیف خود را مدیریت کنید"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="check-square" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<AssignmentsFilters v-model="filters" @apply="onFilterApply" @reset="onFilterReset" />
|
||||
|
||||
<div class="assignments-page__list-header">
|
||||
<SimpleTitleIconBlock title="لیست همه تکالیف" class="assignments-page__list-title">
|
||||
<template #header-icon>
|
||||
<SvgIcon name="list-bullets" :size="16" color="#bcbcbc" />
|
||||
</template>
|
||||
</SimpleTitleIconBlock>
|
||||
<BaseButton text="افزودن تکلیف جدید" custom-class="assignments-page__add-btn" @click="onAdd">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="plus" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="6" :cols-per-row="1" />
|
||||
<div v-else-if="assignments.length > 0">
|
||||
<AssignmentItem
|
||||
v-for="assignment in assignments"
|
||||
:key="assignment.id"
|
||||
:assignment="assignment"
|
||||
@edit="onEdit"
|
||||
@delete="onAskDelete"
|
||||
@show-details="onShowDetails"
|
||||
@show-submissions="onShowSubmissions"
|
||||
/>
|
||||
</div>
|
||||
<NoItems v-else title="متاسفیم" desc="تکلیفی برای نمایش وجود ندارد." />
|
||||
|
||||
<PaginationBlock :pagination="paginationMeta" @update:page="setPage" />
|
||||
|
||||
<AddAssignmentModal v-if="isModal('AddAssignmentModal')" />
|
||||
<AssignmentSubmissionsModal v-if="isModal('AssignmentSubmissionsModal')" />
|
||||
<AssignmentSubmissionDetailsModal v-if="isModal('AssignmentSubmissionDetailsModal')" />
|
||||
<AssignmentDetailsModal v-if="isModal('AssignmentDetailsModal')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import AssignmentsFilters from '@/features/admin/assignments/components/AssignmentsFilters.vue'
|
||||
import AssignmentItem from '@/features/admin/assignments/components/AssignmentItem.vue'
|
||||
import AddAssignmentModal from '@/features/admin/assignments/components/modals/AddAssignmentModal.vue'
|
||||
import AssignmentSubmissionsModal from '@/features/admin/assignments/components/modals/AssignmentSubmissionsModal.vue'
|
||||
import AssignmentSubmissionDetailsModal from '@/features/admin/assignments/components/modals/AssignmentSubmissionDetailsModal.vue'
|
||||
import AssignmentDetailsModal from '@/features/admin/assignments/components/modals/AssignmentDetailsModal.vue'
|
||||
import {
|
||||
adminAssignmentsKeys,
|
||||
useAdminAssignmentsListQuery,
|
||||
useDeleteAdminAssignmentMutation,
|
||||
} from '@/services/query/admin-assignments'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import useModal from '@/composables/useModal'
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { openModal, isModal } = useModal()
|
||||
|
||||
const filters = ref({
|
||||
title: '',
|
||||
courseTemplateId: '',
|
||||
sessionId: '',
|
||||
fromDate: '',
|
||||
toDate: '',
|
||||
})
|
||||
const { pagination, setPage, reset: resetPagination } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = useAdminAssignmentsListQuery(filters, pagination, {
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
const assignments = computed(() => data.value?.data ?? [])
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const onFilterApply = () => resetPagination()
|
||||
const onFilterReset = () => resetPagination()
|
||||
|
||||
const onAdd = () => openModal('AddAssignmentModal', { mode: 'add' })
|
||||
const onEdit = (assignment) => openModal('AddAssignmentModal', { mode: 'edit', id: assignment.id })
|
||||
|
||||
const onShowDetails = (assignment) => openModal('AssignmentDetailsModal', { id: assignment.id })
|
||||
|
||||
const onShowSubmissions = (assignment) =>
|
||||
openModal('AssignmentSubmissionsModal', { id: assignment.id, title: assignment.title })
|
||||
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminAssignmentsKeys.all })
|
||||
|
||||
const deleteMutation = useDeleteAdminAssignmentMutation()
|
||||
|
||||
const onAskDelete = (assignment) => {
|
||||
openModal('ConfirmModal', {
|
||||
title: `حذف ${assignment.title}`,
|
||||
message: `بعد از حذف امکان بازگشت وجود ندارد، آیا مطمئن هستید که میخواهید <strong>${assignment.title}</strong> را حذف کنید؟`,
|
||||
onConfirm: () => deleteMutation.mutate(assignment.id, { onSuccess: invalidate }),
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.assignments-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__list-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
margin-bottom: 0.375rem;
|
||||
}
|
||||
|
||||
&__list-title {
|
||||
flex: 1;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&__add-btn {
|
||||
min-width: fit-content;
|
||||
padding: 0 1.25rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,17 @@
|
||||
import { number, object, string } from 'yup'
|
||||
|
||||
export const assignmentSchema = object().shape({
|
||||
title: string().required().min(3),
|
||||
courseTemplateId: string().required(),
|
||||
sessionId: string().required(),
|
||||
startDate: string().required(),
|
||||
endDate: string().required(),
|
||||
priority: string().required(),
|
||||
description: string().nullable().notRequired(),
|
||||
})
|
||||
|
||||
export const assignmentSubmissionReviewSchema = object().shape({
|
||||
score: number().typeError('نمره باید عدد باشد').required(),
|
||||
status: string().required(),
|
||||
reviewerNote: string().nullable().notRequired(),
|
||||
})
|
||||
@@ -0,0 +1,285 @@
|
||||
<template>
|
||||
<div class="consultation-item">
|
||||
<div class="consultation-item__user">
|
||||
<div v-if="consultation.user?.avatarUrl" class="consultation-item__avatar">
|
||||
<img :src="consultation.user.avatarUrl" :alt="userName" />
|
||||
</div>
|
||||
<div v-else class="consultation-item__avatar consultation-item__avatar--placeholder">
|
||||
<SvgIcon name="user" :size="24" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="consultation-item__info">
|
||||
<p class="consultation-item__name">{{ userName }}</p>
|
||||
<p class="consultation-item__request-id">
|
||||
<span class="consultation-item__request-id-label">شماره درخواست :</span>
|
||||
<span class="consultation-item__request-id-value">
|
||||
{{ consultation.requestId || consultation.id || '—' }}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="consultation-item__meta">
|
||||
<div class="consultation-item__pill">
|
||||
<span class="consultation-item__pill-label">تاریخ پیام :</span>
|
||||
<span class="consultation-item__pill-value">{{ createdAt }}</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="consultation-item__status"
|
||||
:class="`consultation-item__status--${consultation.status || 'in_progress'}`"
|
||||
@click="onStatusClick"
|
||||
>
|
||||
<span class="consultation-item__status-dot" />
|
||||
<span>{{ statusLabel }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="consultation-item__actions">
|
||||
<BaseButton
|
||||
text="جزئیات مشاوره"
|
||||
custom-class="consultation-item__details-btn"
|
||||
@click="emit('show-details', consultation)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<DropdownMenu
|
||||
v-model="menuOpen"
|
||||
:reference="menuTrigger"
|
||||
:items="menuItems"
|
||||
placement="bottom-end"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import DropdownMenu from '@/components/DropdownMenu.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { CONSULTATION_STATUS } from '@/enums'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
const props = defineProps({
|
||||
consultation: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['show-details', 'change-status'])
|
||||
|
||||
const userName = computed(() => {
|
||||
const u = props.consultation.user
|
||||
if (!u) return '—'
|
||||
return `${u.firstName || ''} ${u.lastName || ''}`.trim() || u.fullName || '—'
|
||||
})
|
||||
|
||||
const statusLabel = computed(
|
||||
() => props.consultation.statusLabel || CONSULTATION_STATUS[props.consultation.status] || '—'
|
||||
)
|
||||
|
||||
const createdAt = computed(() => {
|
||||
if (props.consultation.faCreatedAt) {
|
||||
return props.consultation.faCreatedTime
|
||||
? `${props.consultation.faCreatedTime}، ${props.consultation.faCreatedAt}`
|
||||
: props.consultation.faCreatedAt
|
||||
}
|
||||
return formatJalaaliDate(props.consultation.createdAt) || '—'
|
||||
})
|
||||
|
||||
const menuOpen = ref(false)
|
||||
const menuTrigger = ref(null)
|
||||
|
||||
const onStatusClick = (event) => {
|
||||
const trigger = event.currentTarget
|
||||
if (menuOpen.value && menuTrigger.value === trigger) {
|
||||
menuOpen.value = false
|
||||
return
|
||||
}
|
||||
menuTrigger.value = trigger
|
||||
menuOpen.value = true
|
||||
}
|
||||
|
||||
const menuItems = computed(() =>
|
||||
Object.entries(CONSULTATION_STATUS)
|
||||
.filter(([value]) => value !== props.consultation.status)
|
||||
.map(([value, label]) => ({
|
||||
key: `status-${value}`,
|
||||
label: `تغییر به ${label}`,
|
||||
icon: 'arrows-clockwise',
|
||||
onClick: () => emit('change-status', { consultation: props.consultation, status: value }),
|
||||
}))
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.consultation-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%;
|
||||
}
|
||||
|
||||
&__pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
padding: 0.375rem 0.875rem;
|
||||
border-radius: 0.875rem;
|
||||
line-height: 1.5;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__pill-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 300;
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__pill-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 500;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
padding: 0.375rem 0.875rem;
|
||||
border-radius: 0.875rem;
|
||||
border: none;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
transition: filter 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
filter: brightness(0.96);
|
||||
}
|
||||
|
||||
&--answered {
|
||||
background: rgba(0, 154, 18, 8%);
|
||||
color: #009a12;
|
||||
}
|
||||
|
||||
&--in_progress {
|
||||
background: rgba(0, 112, 116, 10%);
|
||||
color: #007074;
|
||||
}
|
||||
|
||||
&--closed {
|
||||
background: rgba(104, 104, 104, 10%);
|
||||
color: #686868;
|
||||
}
|
||||
}
|
||||
|
||||
&__status-dot {
|
||||
width: 0.45rem;
|
||||
height: 0.45rem;
|
||||
border-radius: 9999px;
|
||||
background: currentcolor;
|
||||
}
|
||||
|
||||
&__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,125 @@
|
||||
<template>
|
||||
<form class="consultations-filters" @submit.prevent="onSubmit">
|
||||
<div class="consultations-filters__grid">
|
||||
<TextField v-model="form.userName" name="userName" label="جستجو اسم کاربر">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="user" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.status"
|
||||
name="status"
|
||||
label="دسته بندی"
|
||||
:options="statusOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
/>
|
||||
<DatePickerField v-model="form.fromDate" name="fromDate" label="از تاریخ" :max="todayIso" />
|
||||
<DatePickerField v-model="form.toDate" name="toDate" label="تا تاریخ" :max="todayIso" />
|
||||
</div>
|
||||
|
||||
<div class="consultations-filters__actions">
|
||||
<CircleButton
|
||||
v-if="hasFilters"
|
||||
tooltip="حذف فیلتر"
|
||||
bg-color="transparent"
|
||||
size="2.5rem"
|
||||
type="button"
|
||||
@click="onReset"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="اعمال فیلتر"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
type="submit"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="funnel" :size="20" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { CONSULTATION_STATUS } from '@/enums'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: () => ({ userName: '', status: '', fromDate: '', toDate: '' }),
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'apply', 'reset'])
|
||||
|
||||
const emptyForm = () => ({ userName: '', status: '', fromDate: '', toDate: '' })
|
||||
const form = ref({ ...emptyForm(), ...props.modelValue })
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(next) => {
|
||||
form.value = { ...emptyForm(), ...next }
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const todayIso = new Date().toISOString()
|
||||
|
||||
const statusOptions = Object.entries(CONSULTATION_STATUS).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
|
||||
const hasFilters = computed(() =>
|
||||
Object.values(form.value).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
)
|
||||
|
||||
const onSubmit = () => {
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('apply', { ...form.value })
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
form.value = emptyForm()
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.consultations-filters {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
|
||||
&__grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding-top: 1.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,251 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="64rem" min-width="auto" :show-close-button="true">
|
||||
<template #default>
|
||||
<div class="consultation-details">
|
||||
<LineTitleBlock title="جزئیات مشاوره" title-en="Consultation Details" />
|
||||
|
||||
<div v-if="consultation" class="consultation-details__date">
|
||||
<span>{{ consultationDate }}</span>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading && !consultation" :rows="3" :cols-per-row="1" />
|
||||
<div v-else-if="messages.length > 0" ref="thread" class="consultation-details__thread">
|
||||
<div
|
||||
v-for="message in messages"
|
||||
:key="message.id"
|
||||
class="consultation-details__row"
|
||||
:class="`consultation-details__row--${senderClass(message)}`"
|
||||
>
|
||||
<div class="consultation-details__bubble">
|
||||
<p class="consultation-details__text">{{ message.text }}</p>
|
||||
<span class="consultation-details__time">{{ messageTime(message) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<NoItems v-else title="پیامی نیست" desc="هنوز پیامی در این مشاوره ثبت نشده است." />
|
||||
|
||||
<div class="consultation-details__divider" />
|
||||
|
||||
<form class="consultation-details__compose" @submit.prevent="onSend">
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="!canSend"
|
||||
class="consultation-details__send"
|
||||
aria-label="ارسال"
|
||||
>
|
||||
<SvgIcon name="paper-plane-right" :size="22" color="var(--color-primary)" />
|
||||
</button>
|
||||
<input
|
||||
v-model="text"
|
||||
type="text"
|
||||
placeholder="ارسال پیام"
|
||||
class="consultation-details__input"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, nextTick, ref, watch } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import {
|
||||
adminConsultationsKeys,
|
||||
useAdminConsultationQuery,
|
||||
useSendAdminConsultationMessageMutation,
|
||||
} from '@/services/query/admin-consultations'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'ConsultationDetailsModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('ConsultationDetailsModal')?.data ?? {})
|
||||
const consultationId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const { data: consultation, isLoading } = useAdminConsultationQuery(consultationId, {
|
||||
enabled: () => !!consultationId.value,
|
||||
})
|
||||
|
||||
const messages = computed(() => consultation.value?.messages ?? [])
|
||||
|
||||
const consultationDate = computed(
|
||||
() => consultation.value?.faCreatedAt || formatJalaaliDate(consultation.value?.createdAt) || '—'
|
||||
)
|
||||
|
||||
const senderClass = (message) => (message.sender === 'admin' ? 'admin' : 'user')
|
||||
|
||||
const messageTime = (message) => message.time || message.faSentAt || message.sentAt || '—'
|
||||
|
||||
const text = ref('')
|
||||
const canSend = computed(() => text.value.trim().length > 0)
|
||||
|
||||
const sendMutation = useSendAdminConsultationMessageMutation()
|
||||
|
||||
const onSend = async () => {
|
||||
if (!canSend.value || !consultationId.value) return
|
||||
const value = text.value.trim()
|
||||
text.value = ''
|
||||
await sendMutation.mutateAsync({ id: consultationId.value, payload: { text: value } })
|
||||
await queryClient.invalidateQueries({ queryKey: adminConsultationsKeys.all })
|
||||
}
|
||||
|
||||
const thread = ref(null)
|
||||
|
||||
watch(messages, async () => {
|
||||
await nextTick()
|
||||
if (thread.value) {
|
||||
thread.value.scrollTop = thread.value.scrollHeight
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.consultation-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: calc(100dvh - 8rem);
|
||||
min-height: 28rem;
|
||||
|
||||
&__date {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin: 0.5rem 0 0.875rem;
|
||||
}
|
||||
|
||||
&__date span {
|
||||
background: #f7f7f7;
|
||||
color: #9c9c9c;
|
||||
border-radius: 9999px;
|
||||
padding: 0.5rem 1.25rem;
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
&__thread {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
padding-block: 0.5rem 1rem;
|
||||
padding-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
|
||||
&--admin {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&--user {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
&__bubble {
|
||||
max-width: 72%;
|
||||
border-radius: 1rem;
|
||||
padding: 0.75rem 1.25rem;
|
||||
|
||||
.consultation-details__row--admin & {
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
border-end-start-radius: 0;
|
||||
}
|
||||
|
||||
.consultation-details__row--user & {
|
||||
background: #f8f8f8;
|
||||
color: #5d5d5d;
|
||||
border-end-end-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&__text {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.7;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__time {
|
||||
display: block;
|
||||
margin-top: 0.375rem;
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.7rem;
|
||||
|
||||
.consultation-details__row--admin & {
|
||||
color: rgba(255, 255, 255, 80%);
|
||||
}
|
||||
|
||||
.consultation-details__row--user & {
|
||||
color: #b1b1b1;
|
||||
}
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 0.75rem;
|
||||
}
|
||||
|
||||
&__compose {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
&__send {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: 9999px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--color-primary);
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.2s ease;
|
||||
|
||||
&:hover:enabled {
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
&__input {
|
||||
flex: 1;
|
||||
height: 2.5rem;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 1.5rem;
|
||||
padding: 0 1rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
color: #4b4b4b;
|
||||
outline: none;
|
||||
|
||||
&:focus {
|
||||
border-color: var(--color-thd-gray);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<div class="consultations-page">
|
||||
<BoxedIconTitleBlock
|
||||
class="consultations-page__heading"
|
||||
title="مدیریت مشاوره"
|
||||
desc="در این قسمت میتوانید مشاوره های خواسته شده را مدیریت کنید"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="chat" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<ConsultationsFilters v-model="filters" @apply="onFilterApply" @reset="onFilterReset" />
|
||||
|
||||
<SimpleTitleIconBlock
|
||||
title="لیست تمام مشاوره های خواسته شده"
|
||||
class="consultations-page__list-title"
|
||||
>
|
||||
<template #header-icon>
|
||||
<SvgIcon name="list-bullets" :size="16" color="#bcbcbc" />
|
||||
</template>
|
||||
</SimpleTitleIconBlock>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="6" :cols-per-row="1" />
|
||||
<div v-else-if="consultations.length > 0">
|
||||
<ConsultationItem
|
||||
v-for="consultation in consultations"
|
||||
:key="consultation.id"
|
||||
:consultation="consultation"
|
||||
@show-details="onShowDetails"
|
||||
@change-status="onChangeStatus"
|
||||
/>
|
||||
</div>
|
||||
<NoItems v-else title="متاسفیم" desc="درخواست مشاورهای برای نمایش وجود ندارد." />
|
||||
|
||||
<PaginationBlock :pagination="paginationMeta" @update:page="setPage" />
|
||||
|
||||
<ConsultationDetailsModal v-if="isModal('ConsultationDetailsModal')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import ConsultationsFilters from '@/features/admin/consultations/components/ConsultationsFilters.vue'
|
||||
import ConsultationItem from '@/features/admin/consultations/components/ConsultationItem.vue'
|
||||
import ConsultationDetailsModal from '@/features/admin/consultations/components/modals/ConsultationDetailsModal.vue'
|
||||
import {
|
||||
adminConsultationsKeys,
|
||||
useAdminConsultationsListQuery,
|
||||
useChangeAdminConsultationStatusMutation,
|
||||
} from '@/services/query/admin-consultations'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import useModal from '@/composables/useModal'
|
||||
|
||||
const { openModal, isModal } = useModal()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const filters = ref({ userName: '', status: '', fromDate: '', toDate: '' })
|
||||
const { pagination, setPage, reset: resetPagination } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = useAdminConsultationsListQuery(filters, pagination, {
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
const consultations = computed(() => data.value?.data ?? [])
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const onFilterApply = () => resetPagination()
|
||||
const onFilterReset = () => resetPagination()
|
||||
|
||||
const onShowDetails = (consultation) => {
|
||||
openModal('ConsultationDetailsModal', { id: consultation.id })
|
||||
}
|
||||
|
||||
const changeStatusMutation = useChangeAdminConsultationStatusMutation()
|
||||
|
||||
const onChangeStatus = async ({ consultation, status }) => {
|
||||
await changeStatusMutation.mutateAsync({ id: consultation.id, payload: { status } })
|
||||
await queryClient.invalidateQueries({ queryKey: adminConsultationsKeys.all })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.consultations-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__list-title {
|
||||
margin-bottom: 0.375rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,261 @@
|
||||
<template>
|
||||
<div class="course-item">
|
||||
<div class="course-item__main">
|
||||
<div v-if="course.image" class="course-item__image">
|
||||
<img :src="course.image" :alt="course.title" />
|
||||
</div>
|
||||
<div v-else class="course-item__image course-item__image--placeholder">
|
||||
<SvgIcon name="book" :size="22" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="course-item__title-block">
|
||||
<p class="course-item__title">
|
||||
<span>دوره</span>
|
||||
<strong>{{ course.title }}</strong>
|
||||
</p>
|
||||
<div class="course-item__teacher">
|
||||
<SvgIcon name="user" :size="11" color="#bcbcbc" />
|
||||
<span class="course-item__teacher-label">استاد:</span>
|
||||
<span class="course-item__teacher-name">{{ teacherName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="course-item__meta">
|
||||
<div v-if="course.term?.title" class="course-item__pill">
|
||||
<span class="course-item__pill-label">مختص به:</span>
|
||||
<span class="course-item__pill-value">{{ course.term.title }}</span>
|
||||
</div>
|
||||
<div class="course-item__pill">
|
||||
<span class="course-item__pill-label">ظرفیت:</span>
|
||||
<span class="course-item__pill-value">{{ capacity || '—' }}</span>
|
||||
</div>
|
||||
<div v-if="course.prerequisitesCount" class="course-item__pill">
|
||||
<span class="course-item__pill-label">پیشنیاز:</span>
|
||||
<span class="course-item__pill-value">{{ course.prerequisitesCount }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!isActive" class="course-item__status">
|
||||
<span class="course-item__status-badge">
|
||||
<span class="course-item__status-dot" />
|
||||
غیرفعال
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="course-item__actions">
|
||||
<ToggleSwitch
|
||||
:model-value="!!isActive"
|
||||
@update:model-value="emit('change-status', { id: course.id, isActive: !isActive })"
|
||||
/>
|
||||
<CircleButton
|
||||
tooltip="حذف"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('delete', course)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="18" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="ویرایش"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('edit', course)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="pencil" :size="18" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<BaseButton
|
||||
text="جزئیات دوره"
|
||||
custom-class="course-item__details-btn"
|
||||
@click="emit('show-details', course)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import ToggleSwitch from '@/components/form/ToggleSwitch.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
|
||||
const props = defineProps({
|
||||
course: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['edit', 'delete', 'change-status', 'show-details'])
|
||||
|
||||
const teacherName = computed(() => {
|
||||
const t = props.course.teacher || props.course.defaultTeacher
|
||||
if (!t) return '—'
|
||||
return `${t.firstName || ''} ${t.lastName || ''}`.trim() || t.fullName || '—'
|
||||
})
|
||||
|
||||
const capacity = computed(() => props.course.capacity ?? props.course.defaultCapacity ?? '')
|
||||
|
||||
const isActive = computed(() => props.course.isActive ?? props.course.isActiveByDefault ?? false)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.course-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: 1280px) {
|
||||
flex-flow: row wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
flex: 1 1 33%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__image {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
min-width: 3rem;
|
||||
border-radius: 0.375rem;
|
||||
border: 1px solid #eee;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__title-block {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
|
||||
strong {
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
&__teacher {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
&__teacher-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.65rem;
|
||||
color: #838383;
|
||||
}
|
||||
|
||||
&__teacher-name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #4b4b4b;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 33%;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__pill {
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
padding: 0.25rem 1rem;
|
||||
border-radius: 0.875rem;
|
||||
line-height: 1.5;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__pill-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 300;
|
||||
font-size: 0.75rem;
|
||||
color: #848484;
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__pill-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
&__status {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
&__status-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
padding: 0.25rem 1rem;
|
||||
border-radius: 0.875rem;
|
||||
background: rgba(204, 40, 49, 6%);
|
||||
color: var(--color-error);
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
|
||||
&__status-dot {
|
||||
width: 0.375rem;
|
||||
height: 0.375rem;
|
||||
border-radius: 9999px;
|
||||
background: currentcolor;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 100%;
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
}
|
||||
|
||||
&__details-btn {
|
||||
min-width: 8rem;
|
||||
padding: 0 0.875rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,185 @@
|
||||
<template>
|
||||
<div class="course-session-item">
|
||||
<div class="course-session-item__main">
|
||||
<p class="course-session-item__title">
|
||||
<span>{{ orderLabel }}</span>
|
||||
<span v-if="session.title" class="course-session-item__title-dash">–</span>
|
||||
<strong v-if="session.title">{{ session.title }}</strong>
|
||||
</p>
|
||||
<div class="course-session-item__duration">
|
||||
<SvgIcon name="calendar" :size="12" color="#bcbcbc" />
|
||||
<span class="course-session-item__duration-label">زمان جلسه:</span>
|
||||
<span class="course-session-item__duration-value">{{ durationLabel }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="course-session-item__badges">
|
||||
<span
|
||||
v-for="badge in badges"
|
||||
:key="badge.key"
|
||||
class="course-session-item__badge"
|
||||
:class="badge.variant ? `course-session-item__badge--${badge.variant}` : null"
|
||||
>
|
||||
<SvgIcon
|
||||
v-if="badge.icon"
|
||||
:name="badge.icon"
|
||||
:size="11"
|
||||
:color="badge.iconColor || '#848484'"
|
||||
/>
|
||||
<span>{{ badge.label }}</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
|
||||
const props = defineProps({
|
||||
session: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const orderLabel = computed(() => {
|
||||
const order = props.session.order
|
||||
if (order == null) return 'جلسه'
|
||||
return `جلسه ${order}`
|
||||
})
|
||||
|
||||
const durationLabel = computed(() => {
|
||||
const m = props.session.durationMinutes
|
||||
if (m == null) return '—'
|
||||
const hours = Math.floor(m / 60)
|
||||
if (hours <= 0) return `${m} دقیقه`
|
||||
return `${hours} ساعت`
|
||||
})
|
||||
|
||||
const sessionType = computed(() => props.session.sessionType || props.session.type)
|
||||
|
||||
const sessionTypeLabel = computed(() => {
|
||||
switch (sessionType.value) {
|
||||
case 'online': {
|
||||
return 'جلسه آنلاین'
|
||||
}
|
||||
case 'in_person': {
|
||||
return 'جلسه حضوری'
|
||||
}
|
||||
case 'video': {
|
||||
return 'جلسه ویدئویی'
|
||||
}
|
||||
case 'audio': {
|
||||
return 'جلسه صوتی'
|
||||
}
|
||||
case 'text': {
|
||||
return 'جلسه متنی'
|
||||
}
|
||||
case 'slide': {
|
||||
return 'جلسه اسلایدی'
|
||||
}
|
||||
case 'pdf': {
|
||||
return 'جلسه PDF'
|
||||
}
|
||||
default: {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const badges = computed(() => {
|
||||
const list = []
|
||||
if (props.session.hasAssignment ?? props.session.assignment) {
|
||||
list.push({ key: 'assignment', icon: 'file', label: 'ارسال تکلیف' })
|
||||
}
|
||||
if (props.session.hasExam ?? props.session.exam) {
|
||||
list.push({ key: 'exam', icon: 'check-square', label: 'دارای آزمون' })
|
||||
}
|
||||
if (sessionTypeLabel.value) {
|
||||
list.push({ key: 'type', icon: 'calendar', label: sessionTypeLabel.value })
|
||||
}
|
||||
if (props.session.watched ?? props.session.isWatched) {
|
||||
list.push({
|
||||
key: 'watched',
|
||||
icon: 'check',
|
||||
iconColor: '#35c245',
|
||||
variant: 'success',
|
||||
label: 'دیده شده',
|
||||
})
|
||||
}
|
||||
return list
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.course-session-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
padding: 0.75rem 1rem;
|
||||
background: rgba(255, 255, 255, 85%);
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
&__main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
|
||||
strong {
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
&__title-dash {
|
||||
color: #c4c4c4;
|
||||
}
|
||||
|
||||
&__duration {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
color: #848484;
|
||||
}
|
||||
|
||||
&__duration-label {
|
||||
color: #b7b7b7;
|
||||
}
|
||||
|
||||
&__badges {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.375rem;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding: 0.25rem 0.75rem;
|
||||
border-radius: 9999px;
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
color: #4b4b4b;
|
||||
white-space: nowrap;
|
||||
|
||||
&--success {
|
||||
background: rgba(53, 194, 69, 8%);
|
||||
color: #35c245;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,153 @@
|
||||
<template>
|
||||
<form class="courses-filters" @submit.prevent="onSubmit">
|
||||
<div class="courses-filters__grid">
|
||||
<TextField v-model="form.title" name="title" label="عنوان دوره">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="book" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-if="showTermFilter"
|
||||
v-model="form.termId"
|
||||
name="termId"
|
||||
label="ترم"
|
||||
:options="termOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
/>
|
||||
<SelectField
|
||||
v-model="form.status"
|
||||
name="status"
|
||||
label="وضعیت"
|
||||
:options="statusOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
/>
|
||||
<DatePickerField v-model="form.fromDate" name="fromDate" label="از تاریخ" :max="todayIso" />
|
||||
<DatePickerField v-model="form.toDate" name="toDate" label="تا تاریخ" :max="todayIso" />
|
||||
</div>
|
||||
|
||||
<div class="courses-filters__actions">
|
||||
<CircleButton
|
||||
v-if="hasFilters"
|
||||
tooltip="حذف فیلتر"
|
||||
bg-color="transparent"
|
||||
size="2.5rem"
|
||||
type="button"
|
||||
@click="onReset"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="اعمال فیلتر"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
type="submit"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="funnel" :size="20" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { useAdminTermsListQuery } from '@/services/query/admin-terms'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: () => ({ title: '', termId: '', status: '', fromDate: '', toDate: '' }),
|
||||
},
|
||||
showTermFilter: { type: Boolean, default: false },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'apply', 'reset'])
|
||||
|
||||
const emptyForm = () => ({
|
||||
title: '',
|
||||
termId: '',
|
||||
status: '',
|
||||
fromDate: '',
|
||||
toDate: '',
|
||||
})
|
||||
|
||||
const form = ref({ ...emptyForm(), ...props.modelValue })
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(next) => {
|
||||
form.value = { ...emptyForm(), ...next }
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const todayIso = new Date().toISOString()
|
||||
|
||||
const statusOptions = [
|
||||
{ value: 1, label: 'فعال' },
|
||||
{ value: 0, label: 'غیرفعال' },
|
||||
]
|
||||
|
||||
const termFilters = ref({})
|
||||
const termPagination = ref({ page: 1, perPage: 100 })
|
||||
const { data: termsResponse } = useAdminTermsListQuery(termFilters, termPagination, {
|
||||
enabled: () => props.showTermFilter,
|
||||
})
|
||||
const termOptions = computed(() => termsResponse.value?.data ?? [])
|
||||
|
||||
const hasFilters = computed(() =>
|
||||
Object.values(form.value).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
)
|
||||
|
||||
const onSubmit = () => {
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('apply', { ...form.value })
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
form.value = emptyForm()
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.courses-filters {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
|
||||
&__grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding-top: 1.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,307 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="42rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<div class="add-course-student">
|
||||
<LineTitleBlock title="افزودن دانشجو" title-en="Add Student" />
|
||||
|
||||
<div class="add-course-student__search">
|
||||
<SvgIcon name="user" :size="18" color="var(--color-thd-gray)" />
|
||||
<input
|
||||
v-model="searchInput"
|
||||
type="text"
|
||||
class="add-course-student__search-input"
|
||||
placeholder="اسم دانشجو را وارد نمایید"
|
||||
@input="onSearchInput"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="4" :cols-per-row="1" />
|
||||
|
||||
<div v-else-if="users.length > 0" class="add-course-student__list">
|
||||
<div v-for="user in users" :key="user.id" class="add-course-student__row">
|
||||
<div class="add-course-student__main">
|
||||
<div v-if="user.avatarUrl" class="add-course-student__avatar">
|
||||
<img :src="user.avatarUrl" :alt="userLabel(user)" />
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="add-course-student__avatar add-course-student__avatar--placeholder"
|
||||
>
|
||||
<SvgIcon name="user" :size="20" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="add-course-student__text">
|
||||
<p class="add-course-student__name">{{ userLabel(user) }}</p>
|
||||
<p class="add-course-student__meta">
|
||||
<span>{{ user.address?.province?.name || '—' }}</span>
|
||||
<span class="add-course-student__sep">،</span>
|
||||
<span>{{ user.address?.city?.name || '—' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CircleButton
|
||||
v-if="isAttached(user.id)"
|
||||
tooltip="حذف از دوره"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.25rem"
|
||||
type="button"
|
||||
:loading="pendingId === user.id"
|
||||
@click="onDetach(user)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="16" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
v-else
|
||||
tooltip="افزودن به دوره"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.25rem"
|
||||
type="button"
|
||||
:loading="pendingId === user.id"
|
||||
@click="onAttach(user)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="plus" :size="16" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<NoItems v-else title="بدون نتیجه" desc="دانشجویی یافت نشد." />
|
||||
|
||||
<div class="add-course-student__divider" />
|
||||
|
||||
<div class="add-course-student__footer">
|
||||
<BaseButton text="تایید" custom-class="add-course-student__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
import { useAdminUsersListQuery } from '@/services/query/admin-users'
|
||||
import {
|
||||
adminCourseTemplatesKeys,
|
||||
useAddAdminTemplateStudentMutation,
|
||||
useAdminTemplateStudentsQuery,
|
||||
useRemoveAdminTemplateStudentMutation,
|
||||
} from '@/services/query/admin-course-templates'
|
||||
|
||||
defineOptions({ name: 'AddCourseStudentModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('AddCourseStudentModal')?.data ?? {})
|
||||
const templateId = computed(() => modalData.value.templateId ?? null)
|
||||
|
||||
const searchInput = ref('')
|
||||
const searchQuery = ref('')
|
||||
const userFilters = computed(() => ({ name: searchQuery.value }))
|
||||
const userPagination = ref({ page: 1, perPage: 20 })
|
||||
|
||||
const { data: usersResponse, isLoading } = useAdminUsersListQuery(userFilters, userPagination)
|
||||
const users = computed(() => usersResponse.value?.data ?? [])
|
||||
|
||||
const attachedFilters = computed(() => ({}))
|
||||
const attachedPagination = ref({ page: 1, perPage: 200 })
|
||||
const { data: attachedResponse } = useAdminTemplateStudentsQuery(
|
||||
templateId,
|
||||
attachedFilters,
|
||||
attachedPagination,
|
||||
{ enabled: () => !!templateId.value }
|
||||
)
|
||||
const attachedIds = computed(() => new Set((attachedResponse.value?.data ?? []).map((u) => u.id)))
|
||||
|
||||
const isAttached = (id) => attachedIds.value.has(id)
|
||||
|
||||
const userLabel = (user) =>
|
||||
`${user.firstName || ''} ${user.lastName || ''}`.trim() ||
|
||||
user.fullName ||
|
||||
user.phoneNumber ||
|
||||
'—'
|
||||
|
||||
const onSearchInput = useDebounce(() => {
|
||||
searchQuery.value = searchInput.value || ''
|
||||
userPagination.value = { ...userPagination.value, page: 1 }
|
||||
}, 400)
|
||||
|
||||
const pendingId = ref(null)
|
||||
|
||||
const addMutation = useAddAdminTemplateStudentMutation()
|
||||
const removeMutation = useRemoveAdminTemplateStudentMutation()
|
||||
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminCourseTemplatesKeys.all })
|
||||
|
||||
const onAttach = async (user) => {
|
||||
if (!templateId.value) return
|
||||
pendingId.value = user.id
|
||||
try {
|
||||
await addMutation.mutateAsync({
|
||||
templateId: templateId.value,
|
||||
payload: { userIds: [user.id] },
|
||||
})
|
||||
invalidate()
|
||||
} finally {
|
||||
pendingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const onDetach = async (user) => {
|
||||
if (!templateId.value) return
|
||||
pendingId.value = user.id
|
||||
try {
|
||||
await removeMutation.mutateAsync({ templateId: templateId.value, userId: user.id })
|
||||
invalidate()
|
||||
} finally {
|
||||
pendingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
watch(templateId, () => {
|
||||
searchInput.value = ''
|
||||
searchQuery.value = ''
|
||||
pendingId.value = null
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.add-course-student {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
padding: 0.5rem 0.25rem;
|
||||
|
||||
&__search {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-block: 1rem;
|
||||
padding: 0 1rem;
|
||||
height: 2.75rem;
|
||||
border: 1px solid var(--color-thd-gray);
|
||||
border-radius: 9999px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
&__search-input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
color: #4b4b4b;
|
||||
text-align: start;
|
||||
|
||||
&::placeholder {
|
||||
color: var(--color-prim-gray);
|
||||
}
|
||||
}
|
||||
|
||||
&__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
max-height: 22rem;
|
||||
overflow-y: auto;
|
||||
padding-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: rgba(255, 255, 255, 85%);
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
}
|
||||
|
||||
&__main {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #eee;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__text {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 300;
|
||||
color: #848484;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: #c4c4c4;
|
||||
margin-inline: 0.25rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,318 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="60rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<form class="offered-course" @submit.prevent="onSubmit(close)">
|
||||
<LineTitleBlock :title="modeTitle" title-en="Offered Course" />
|
||||
|
||||
<div class="offered-course__grid">
|
||||
<div class="offered-course__image-col">
|
||||
<ImageCropper
|
||||
v-model="image"
|
||||
name="image"
|
||||
bg-color="#eeeeee"
|
||||
@crop="onImageCropped"
|
||||
@error="onImageError"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="offered-course__main-col">
|
||||
<div class="offered-course__row">
|
||||
<div class="offered-course__cell">
|
||||
<SelectField
|
||||
v-model="form.termId"
|
||||
name="termId"
|
||||
label="ترم"
|
||||
:options="termOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchTerms"
|
||||
:error="errors.termId"
|
||||
/>
|
||||
</div>
|
||||
<div class="offered-course__cell">
|
||||
<SelectField
|
||||
v-model="form.templateId"
|
||||
name="templateId"
|
||||
label="دوره الگو"
|
||||
:options="templateOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchTemplates"
|
||||
:error="errors.templateId"
|
||||
/>
|
||||
</div>
|
||||
<div class="offered-course__cell">
|
||||
<TextField
|
||||
v-model="form.title"
|
||||
name="title"
|
||||
label="عنوان دوره"
|
||||
:error="errors.title"
|
||||
@blur="validateAt('title', form.title)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="book" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
</div>
|
||||
<div class="offered-course__cell">
|
||||
<TextField
|
||||
v-model="form.capacity"
|
||||
name="capacity"
|
||||
label="ظرفیت (نفر)"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
:error="errors.capacity"
|
||||
@blur="validateAt('capacity', form.capacity)"
|
||||
/>
|
||||
</div>
|
||||
<div class="offered-course__cell offered-course__toggle-cell">
|
||||
<ToggleSwitch v-model="form.isActive" label="دوره فعال باشد" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="offered-course__divider" />
|
||||
|
||||
<div class="offered-course__actions">
|
||||
<BaseButton
|
||||
variant="transparent"
|
||||
text="منصرف شدم"
|
||||
custom-class="offered-course__btn-cancel"
|
||||
@click="close"
|
||||
>
|
||||
<template #prependIcon>
|
||||
<SvgIcon name="caret-right" :size="14" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
text="تایید اطلاعات"
|
||||
:loading="submitting"
|
||||
custom-class="offered-course__btn-submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { toast } from 'vue3-toastify'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import ToggleSwitch from '@/components/form/ToggleSwitch.vue'
|
||||
import ImageCropper from '@/components/form/ImageCropper.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import useYup from '@/composables/useYup'
|
||||
import {
|
||||
adminCoursesKeys,
|
||||
useAddAdminCourseMutation,
|
||||
useAdminCourseQuery,
|
||||
useUpdateAdminCourseMutation,
|
||||
} from '@/services/query/admin-courses'
|
||||
import { useUploadTemporaryMutation } from '@/services/query/auth'
|
||||
import { useAdminTermsListQuery } from '@/services/query/admin-terms'
|
||||
import { useAdminCourseTemplatesListQuery } from '@/services/query/admin-course-templates'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
import { offeredCourseSchema } from '@/features/admin/courses/schema'
|
||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||
|
||||
defineOptions({ name: 'AddOfferedCourseModal' })
|
||||
|
||||
const { getModal } = useModal()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const modalData = computed(() => getModal('AddOfferedCourseModal')?.data ?? {})
|
||||
const mode = computed(() => modalData.value.mode || 'add')
|
||||
const courseId = computed(() => modalData.value.courseId ?? null)
|
||||
const isEditMode = computed(() => mode.value === 'edit')
|
||||
|
||||
const modeTitle = computed(() =>
|
||||
isEditMode.value ? 'ویرایش دوره ارائه شده' : 'افزودن دوره ارائه شده'
|
||||
)
|
||||
|
||||
const form = ref({
|
||||
termId: '',
|
||||
templateId: '',
|
||||
title: '',
|
||||
capacity: '',
|
||||
imageId: null,
|
||||
isActive: false,
|
||||
})
|
||||
const image = ref(null)
|
||||
|
||||
const schema = offeredCourseSchema
|
||||
|
||||
const { validate, validateAt, errors, resetErrors } = useYup(schema)
|
||||
|
||||
const termSearch = ref('')
|
||||
const termFilters = computed(() => ({ title: termSearch.value }))
|
||||
const termPagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: termsResponse } = useAdminTermsListQuery(termFilters, termPagination)
|
||||
const selectedTerm = ref(null)
|
||||
const termOptions = computed(() => {
|
||||
const base = termsResponse.value?.data ?? []
|
||||
if (selectedTerm.value && !base.some((t) => t.id === selectedTerm.value.id)) {
|
||||
return [...base, selectedTerm.value]
|
||||
}
|
||||
return base
|
||||
})
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: templatesResponse } = useAdminCourseTemplatesListQuery(
|
||||
templateFilters,
|
||||
templatePagination
|
||||
)
|
||||
const selectedTemplate = ref(null)
|
||||
const templateOptions = computed(() => {
|
||||
const base = templatesResponse.value?.data ?? []
|
||||
if (selectedTemplate.value && !base.some((t) => t.id === selectedTemplate.value.id)) {
|
||||
return [...base, selectedTemplate.value]
|
||||
}
|
||||
return base
|
||||
})
|
||||
|
||||
const searchTerms = useDebounce((q) => {
|
||||
termSearch.value = q || ''
|
||||
}, 400)
|
||||
const searchTemplates = useDebounce((q) => {
|
||||
templateSearch.value = q || ''
|
||||
}, 400)
|
||||
|
||||
const { data: existingCourse } = useAdminCourseQuery(courseId, {
|
||||
enabled: () => isEditMode.value && !!courseId.value,
|
||||
})
|
||||
|
||||
watch(existingCourse, (course) => {
|
||||
if (!course) return
|
||||
if (course.term) selectedTerm.value = course.term
|
||||
if (course.template) selectedTemplate.value = course.template
|
||||
form.value = {
|
||||
termId: course.term?.id || course.termId || '',
|
||||
templateId: course.template?.id || course.templateId || '',
|
||||
title: course.title || '',
|
||||
capacity: course.capacity ?? '',
|
||||
imageId: course.imageId || null,
|
||||
isActive: course.isActive ?? false,
|
||||
}
|
||||
if (course.image) image.value = { url: course.image }
|
||||
})
|
||||
|
||||
const uploadMutation = useUploadTemporaryMutation()
|
||||
|
||||
const onImageCropped = async (file) => {
|
||||
try {
|
||||
const formData = objectToFormData({ file, subType: 'avatar', context: 'course' })
|
||||
const response = await uploadMutation.mutateAsync(formData)
|
||||
const payload = response?.data ?? response
|
||||
image.value = { url: payload?.url, uploadId: payload?.uploadId, ...payload }
|
||||
form.value.imageId = payload?.uploadId || payload?.id
|
||||
} catch {
|
||||
/* handled globally */
|
||||
}
|
||||
}
|
||||
|
||||
const onImageError = (msg) => toast.error(msg)
|
||||
|
||||
const addMutation = useAddAdminCourseMutation()
|
||||
const updateMutation = useUpdateAdminCourseMutation()
|
||||
|
||||
const submitting = computed(() => addMutation.isPending.value || updateMutation.isPending.value)
|
||||
|
||||
const onSubmit = async (close) => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
if (isEditMode.value) {
|
||||
await updateMutation.mutateAsync({ id: courseId.value, payload })
|
||||
} else {
|
||||
await addMutation.mutateAsync(payload)
|
||||
}
|
||||
await queryClient.invalidateQueries({ queryKey: adminCoursesKeys.all })
|
||||
resetErrors()
|
||||
close()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.offered-course {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 1rem;
|
||||
margin-block: 0.75rem;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: 4fr 8fr;
|
||||
}
|
||||
}
|
||||
|
||||
&__image-col {
|
||||
order: 2;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
order: 1;
|
||||
}
|
||||
}
|
||||
|
||||
&__main-col {
|
||||
order: 1;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
order: 2;
|
||||
padding-inline-start: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__toggle-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.5rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
&__btn-submit {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,306 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="42rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<div class="add-session">
|
||||
<LineTitleBlock title="افزودن جلسه" title-en="Add" />
|
||||
|
||||
<div class="add-session__search">
|
||||
<SvgIcon name="book" :size="18" color="var(--color-thd-gray)" />
|
||||
<input
|
||||
v-model="searchInput"
|
||||
type="text"
|
||||
class="add-session__search-input"
|
||||
placeholder="عنوان جلسه مورد نظر را جستوجو کنید"
|
||||
@input="onSearchInput"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="4" :cols-per-row="1" />
|
||||
|
||||
<div v-else-if="sessions.length > 0" class="add-session__list">
|
||||
<div v-for="session in sessions" :key="session.id" class="add-session__row">
|
||||
<div class="add-session__main">
|
||||
<div class="add-session__image">
|
||||
<img v-if="session.image" :src="session.image" :alt="session.title" />
|
||||
<SvgIcon v-else name="book" :size="20" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="add-session__text">
|
||||
<p class="add-session__title">
|
||||
{{ session.title || `جلسه ${session.order || ''}` }}
|
||||
</p>
|
||||
<p class="add-session__teacher">
|
||||
<SvgIcon name="user" :size="11" color="#bcbcbc" />
|
||||
<span class="add-session__teacher-label">استاد:</span>
|
||||
<span class="add-session__teacher-name">{{ teacherName(session) }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CircleButton
|
||||
v-if="isAttached(session.id)"
|
||||
tooltip="حذف از دوره"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.25rem"
|
||||
type="button"
|
||||
:loading="pendingId === session.id"
|
||||
@click="onDetach(session)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="16" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
v-else
|
||||
tooltip="افزودن به دوره"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.25rem"
|
||||
type="button"
|
||||
:loading="pendingId === session.id"
|
||||
@click="onAttach(session)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="plus" :size="16" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<NoItems v-else title="بدون نتیجه" desc="جلسهای یافت نشد." />
|
||||
|
||||
<div class="add-session__divider" />
|
||||
|
||||
<div class="add-session__footer">
|
||||
<BaseButton text="تایید" custom-class="add-session__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
import { useAdminSessionsListQuery } from '@/services/query/admin-sessions'
|
||||
import {
|
||||
adminCourseTemplatesKeys,
|
||||
useAdminTemplateSessionsQuery,
|
||||
useAttachAdminTemplateSessionMutation,
|
||||
useDetachAdminTemplateSessionMutation,
|
||||
} from '@/services/query/admin-course-templates'
|
||||
|
||||
defineOptions({ name: 'AddSessionToCourseModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('AddSessionToCourseModal')?.data ?? {})
|
||||
const templateId = computed(() => modalData.value.templateId ?? null)
|
||||
|
||||
const searchInput = ref('')
|
||||
const searchQuery = ref('')
|
||||
const sessionFilters = computed(() => ({ title: searchQuery.value }))
|
||||
const sessionPagination = ref({ page: 1, perPage: 20 })
|
||||
|
||||
const { data: sessionsResponse, isLoading } = useAdminSessionsListQuery(
|
||||
sessionFilters,
|
||||
sessionPagination
|
||||
)
|
||||
const sessions = computed(() => sessionsResponse.value?.data ?? [])
|
||||
|
||||
const attachedFilters = computed(() => ({}))
|
||||
const attachedPagination = ref({ page: 1, perPage: 200 })
|
||||
const { data: attachedResponse } = useAdminTemplateSessionsQuery(
|
||||
templateId,
|
||||
attachedFilters,
|
||||
attachedPagination,
|
||||
{ enabled: () => !!templateId.value }
|
||||
)
|
||||
const attachedIds = computed(() => new Set((attachedResponse.value?.data ?? []).map((s) => s.id)))
|
||||
|
||||
const isAttached = (id) => attachedIds.value.has(id)
|
||||
|
||||
const teacherName = (session) => {
|
||||
const t = session.teacher || session.defaultTeacher
|
||||
if (!t) return '—'
|
||||
return `${t.firstName || ''} ${t.lastName || ''}`.trim() || t.fullName || '—'
|
||||
}
|
||||
|
||||
const onSearchInput = useDebounce(() => {
|
||||
searchQuery.value = searchInput.value || ''
|
||||
sessionPagination.value = { ...sessionPagination.value, page: 1 }
|
||||
}, 400)
|
||||
|
||||
const pendingId = ref(null)
|
||||
|
||||
const attachMutation = useAttachAdminTemplateSessionMutation()
|
||||
const detachMutation = useDetachAdminTemplateSessionMutation()
|
||||
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminCourseTemplatesKeys.all })
|
||||
|
||||
const onAttach = async (session) => {
|
||||
if (!templateId.value) return
|
||||
pendingId.value = session.id
|
||||
try {
|
||||
await attachMutation.mutateAsync({
|
||||
templateId: templateId.value,
|
||||
payload: { sessionIds: [session.id] },
|
||||
})
|
||||
invalidate()
|
||||
} finally {
|
||||
pendingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const onDetach = async (session) => {
|
||||
if (!templateId.value) return
|
||||
pendingId.value = session.id
|
||||
try {
|
||||
await detachMutation.mutateAsync({ templateId: templateId.value, sessionId: session.id })
|
||||
invalidate()
|
||||
} finally {
|
||||
pendingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
watch(templateId, () => {
|
||||
searchInput.value = ''
|
||||
searchQuery.value = ''
|
||||
pendingId.value = null
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.add-session {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
padding: 0.5rem 0.25rem;
|
||||
|
||||
&__search {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-block: 1rem;
|
||||
padding: 0 1rem;
|
||||
height: 2.75rem;
|
||||
border: 1px solid var(--color-thd-gray);
|
||||
border-radius: 9999px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
&__search-input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
color: #4b4b4b;
|
||||
text-align: start;
|
||||
|
||||
&::placeholder {
|
||||
color: var(--color-prim-gray);
|
||||
}
|
||||
}
|
||||
|
||||
&__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
max-height: 22rem;
|
||||
overflow-y: auto;
|
||||
padding-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: rgba(255, 255, 255, 85%);
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
}
|
||||
|
||||
&__main {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__image {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: 0.5rem;
|
||||
overflow: hidden;
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
&__text {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__teacher {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #848484;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__teacher-label {
|
||||
color: #b7b7b7;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,431 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="80rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<div class="course-details">
|
||||
<LineTitleBlock title="جزئیات دوره" title-en="details" />
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="3" :cols-per-row="1" />
|
||||
|
||||
<template v-else-if="course">
|
||||
<div class="course-details__hero">
|
||||
<div class="course-details__image">
|
||||
<img v-if="course.image" :src="course.image" :alt="course.title" />
|
||||
<SvgIcon v-else name="book" :size="32" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="course-details__grid">
|
||||
<LineInfoBlock title="عنوان دوره" :desc="course.title || '—'" />
|
||||
<LineInfoBlock
|
||||
title="تاریخ شروع"
|
||||
:numeric-desc="course.faStartDate || formatJalaaliDate(course.startDate) || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="تاریخ پایان"
|
||||
:numeric-desc="course.faEndDate || formatJalaaliDate(course.endDate) || '—'"
|
||||
/>
|
||||
<LineInfoBlock title="تعداد جلسات" :numeric-desc="course.sessionsCount ?? 0" />
|
||||
<LineInfoBlock title="پیشنیاز دوره" :desc="teacherName" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="course.description" class="course-details__description">
|
||||
<LineInfoBlock title="توضیحات دوره" :desc="course.description" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<NoItems v-else title="یافت نشد" desc="اطلاعات این دوره در دسترس نیست." />
|
||||
|
||||
<TabsBlock v-if="course" :tabs="tabs" v-model="activeTab">
|
||||
<template #sessions>
|
||||
<div class="course-details__panel-header">
|
||||
<LineTitleBlock title="لیست جلسات" title-en="Sessions" />
|
||||
<BaseButton
|
||||
text="افزودن جلسه به این دوره"
|
||||
custom-class="course-details__panel-btn"
|
||||
@click="onOpenAddSession"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="sessionsPending" :rows="4" :cols-per-row="1" />
|
||||
<div v-else-if="sessions.length > 0">
|
||||
<CourseSessionItem v-for="session in sessions" :key="session.id" :session="session" />
|
||||
</div>
|
||||
<NoItems v-else title="بدون جلسه" desc="جلسهای برای این دوره ثبت نشده است." />
|
||||
|
||||
<PaginationBlock
|
||||
v-if="sessionsPaginationMeta.lastPage > 1"
|
||||
:pagination="sessionsPaginationMeta"
|
||||
@update:page="setSessionsPage"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #students>
|
||||
<div class="course-details__panel-header">
|
||||
<LineTitleBlock title="دانشجویان" title-en="Students" />
|
||||
<BaseButton
|
||||
text="افزودن دانشجو به این دوره"
|
||||
custom-class="course-details__panel-btn"
|
||||
@click="onOpenAddStudent"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="studentsPending" :rows="4" :cols-per-row="1" />
|
||||
<div v-else-if="students.length > 0">
|
||||
<div
|
||||
v-for="student in students"
|
||||
:key="student.id"
|
||||
class="course-details__student-row"
|
||||
>
|
||||
<div class="course-details__student-main">
|
||||
<div v-if="student.avatarUrl" class="course-details__avatar">
|
||||
<img :src="student.avatarUrl" :alt="studentName(student)" />
|
||||
</div>
|
||||
<div v-else class="course-details__avatar course-details__avatar--placeholder">
|
||||
<SvgIcon name="user" :size="20" color="#bcbcbc" />
|
||||
</div>
|
||||
<div>
|
||||
<p class="course-details__student-name">{{ studentName(student) }}</p>
|
||||
<p class="course-details__student-meta">
|
||||
<span>{{ student.address?.province?.name || '—' }}</span>
|
||||
<span class="course-details__sep">،</span>
|
||||
<span>{{ student.address?.city?.name || '—' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="course-details__student-actions">
|
||||
<CircleButton
|
||||
v-if="student.phoneNumber"
|
||||
tooltip="ارسال پیام"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.25rem"
|
||||
@click="onMessageStudent(student)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="chat" :size="16" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="حذف"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.25rem"
|
||||
@click="onAskRemoveStudent(student)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="16" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<NoItems v-else title="بدون دانشجو" desc="دانشجویی به این دوره اضافه نشده است." />
|
||||
|
||||
<PaginationBlock
|
||||
v-if="studentsPaginationMeta.lastPage > 1"
|
||||
:pagination="studentsPaginationMeta"
|
||||
@update:page="setStudentsPage"
|
||||
/>
|
||||
</template>
|
||||
</TabsBlock>
|
||||
|
||||
<div class="course-details__divider" />
|
||||
|
||||
<div class="course-details__footer">
|
||||
<BaseButton text="تایید" custom-class="course-details__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import TabsBlock from '@/components/blocks/TabsBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import CourseSessionItem from '@/features/admin/courses/components/CourseSessionItem.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import {
|
||||
adminCourseTemplatesKeys,
|
||||
useAdminCourseTemplateQuery,
|
||||
useAdminTemplateSessionsQuery,
|
||||
useAdminTemplateStudentsQuery,
|
||||
useRemoveAdminTemplateStudentMutation,
|
||||
} from '@/services/query/admin-course-templates'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'CourseDetailsModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { openModal, getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('CourseDetailsModal')?.data ?? {})
|
||||
const templateId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const { data: course, isLoading } = useAdminCourseTemplateQuery(templateId, {
|
||||
enabled: () => !!templateId.value,
|
||||
})
|
||||
|
||||
const teacherName = computed(() => {
|
||||
const t = course.value?.defaultTeacher || course.value?.teacher
|
||||
if (!t) return '—'
|
||||
return `${t.firstName || ''} ${t.lastName || ''}`.trim() || t.fullName || '—'
|
||||
})
|
||||
|
||||
const tabs = [
|
||||
{ name: 'sessions', label: 'لیست جلسات', icon: 'list-bullets' },
|
||||
{ name: 'students', label: 'دانشجویان', icon: 'users' },
|
||||
]
|
||||
const activeTab = ref('sessions')
|
||||
|
||||
const sessionsFilters = ref({})
|
||||
const { pagination: sessionsPagination, setPage: setSessionsPage } = usePagination({
|
||||
page: 1,
|
||||
perPage: 10,
|
||||
})
|
||||
|
||||
const { data: sessionsData, isLoading: sessionsPending } = useAdminTemplateSessionsQuery(
|
||||
templateId,
|
||||
sessionsFilters,
|
||||
sessionsPagination,
|
||||
{
|
||||
enabled: () => !!templateId.value && activeTab.value === 'sessions',
|
||||
keepPreviousData: true,
|
||||
}
|
||||
)
|
||||
|
||||
const sessions = computed(() => sessionsData.value?.data ?? [])
|
||||
const sessionsPaginationMeta = computed(() => ({
|
||||
page: sessionsPagination.value.page,
|
||||
perPage: sessionsPagination.value.perPage,
|
||||
...sessionsData.value?.meta,
|
||||
}))
|
||||
|
||||
const studentsFilters = ref({})
|
||||
const { pagination: studentsPagination, setPage: setStudentsPage } = usePagination({
|
||||
page: 1,
|
||||
perPage: 10,
|
||||
})
|
||||
|
||||
const { data: studentsData, isLoading: studentsPending } = useAdminTemplateStudentsQuery(
|
||||
templateId,
|
||||
studentsFilters,
|
||||
studentsPagination,
|
||||
{
|
||||
enabled: () => !!templateId.value && activeTab.value === 'students',
|
||||
keepPreviousData: true,
|
||||
}
|
||||
)
|
||||
|
||||
const students = computed(() => studentsData.value?.data ?? [])
|
||||
const studentsPaginationMeta = computed(() => ({
|
||||
page: studentsPagination.value.page,
|
||||
perPage: studentsPagination.value.perPage,
|
||||
...studentsData.value?.meta,
|
||||
}))
|
||||
|
||||
const studentName = (student) =>
|
||||
`${student.firstName || ''} ${student.lastName || ''}`.trim() ||
|
||||
student.fullName ||
|
||||
student.phoneNumber ||
|
||||
'—'
|
||||
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminCourseTemplatesKeys.all })
|
||||
|
||||
const removeStudentMutation = useRemoveAdminTemplateStudentMutation()
|
||||
|
||||
const onOpenAddSession = () => {
|
||||
openModal('AddSessionToCourseModal', { templateId: templateId.value })
|
||||
}
|
||||
|
||||
const onOpenAddStudent = () => {
|
||||
openModal('AddCourseStudentModal', { templateId: templateId.value })
|
||||
}
|
||||
|
||||
const onAskRemoveStudent = (student) => {
|
||||
openModal('ConfirmModal', {
|
||||
title: `حذف ${studentName(student)}`,
|
||||
message: `آیا از حذف <strong>${studentName(student)}</strong> از این دوره اطمینان دارید؟`,
|
||||
onConfirm: () =>
|
||||
removeStudentMutation.mutate(
|
||||
{ templateId: templateId.value, userId: student.id },
|
||||
{ onSuccess: invalidate }
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
const onMessageStudent = (student) => {
|
||||
if (!student?.phoneNumber) return
|
||||
window.location.href = `sms:${student.phoneNumber}`
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.course-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__hero {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 1rem;
|
||||
margin: 1rem 0 0.5rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
&__image {
|
||||
width: 5rem;
|
||||
height: 5rem;
|
||||
border-radius: 0.5rem;
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
&__grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.25rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__description {
|
||||
margin-block: 0.5rem 1rem;
|
||||
}
|
||||
|
||||
&__panel-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
&__panel-btn {
|
||||
min-width: 14rem;
|
||||
padding: 0 1rem;
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
&__student-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: rgba(255, 255, 255, 85%);
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
&__student-main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #eee;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__student-name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__student-meta {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 300;
|
||||
color: #848484;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: #c4c4c4;
|
||||
margin-inline: 0.25rem;
|
||||
}
|
||||
|
||||
&__student-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.5rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,372 @@
|
||||
<template>
|
||||
<div class="course-form">
|
||||
<BoxedIconTitleBlock
|
||||
class="course-form__heading"
|
||||
:title="isEditMode ? 'ویرایش دوره الگو' : 'افزودن دوره الگوی جدید'"
|
||||
:desc="
|
||||
isEditMode
|
||||
? 'اطلاعات دوره الگو را بهروز کنید'
|
||||
: 'در این قسمت میتوانید دوره الگوی جدید اضافه کنید'
|
||||
"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="book" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<form class="course-form__form" @submit.prevent="onSubmit">
|
||||
<div class="course-form__grid">
|
||||
<div class="course-form__image-col">
|
||||
<ImageCropper
|
||||
v-model="image"
|
||||
name="image"
|
||||
bg-color="#eeeeee"
|
||||
@crop="onImageCropped"
|
||||
@error="onImageError"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="course-form__main-col">
|
||||
<LineTitleBlock title="اطلاعات دوره" title-en="Course Details" />
|
||||
<div class="course-form__row">
|
||||
<div class="course-form__cell course-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.title"
|
||||
name="title"
|
||||
label="عنوان دوره"
|
||||
:error="errors.title"
|
||||
@blur="validateAt('title', form.title)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="book" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
</div>
|
||||
<div class="course-form__cell course-form__cell--third">
|
||||
<SelectField
|
||||
v-model="form.defaultTeacherId"
|
||||
name="defaultTeacherId"
|
||||
label="استاد"
|
||||
:options="teacherOptions"
|
||||
option-label="label"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchTeachers"
|
||||
:error="errors.defaultTeacherId"
|
||||
/>
|
||||
</div>
|
||||
<div class="course-form__cell course-form__cell--third">
|
||||
<SelectField
|
||||
v-model="form.prerequisites"
|
||||
name="prerequisites"
|
||||
label="دورههای پیشنیاز"
|
||||
:options="prerequisiteOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:multiple="true"
|
||||
:searchable="true"
|
||||
:on-search="searchPrerequisites"
|
||||
/>
|
||||
</div>
|
||||
<div class="course-form__cell course-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.defaultCapacity"
|
||||
name="defaultCapacity"
|
||||
label="ظرفیت (نفر)"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
:error="errors.defaultCapacity"
|
||||
@blur="validateAt('defaultCapacity', form.defaultCapacity)"
|
||||
/>
|
||||
</div>
|
||||
<div class="course-form__cell course-form__cell--third course-form__toggle-cell">
|
||||
<ToggleSwitch v-model="form.isActiveByDefault" label="دوره فعال باشد" />
|
||||
</div>
|
||||
<div class="course-form__cell course-form__cell--full">
|
||||
<TextareaField
|
||||
v-model="form.description"
|
||||
name="description"
|
||||
label="توضیحات"
|
||||
:row="5"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="course-form__divider" />
|
||||
|
||||
<div class="course-form__actions">
|
||||
<BaseButton
|
||||
variant="transparent"
|
||||
text="منصرف شدم"
|
||||
custom-class="course-form__btn-cancel"
|
||||
@click="onCancel"
|
||||
>
|
||||
<template #prependIcon>
|
||||
<SvgIcon name="caret-right" :size="14" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
:text="isEditMode ? 'ذخیره تغییرات' : 'تایید اطلاعات'"
|
||||
:loading="submitting"
|
||||
custom-class="course-form__btn-submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="20" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { toast } from 'vue3-toastify'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import ToggleSwitch from '@/components/form/ToggleSwitch.vue'
|
||||
import ImageCropper from '@/components/form/ImageCropper.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useYup from '@/composables/useYup'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
import {
|
||||
adminCourseTemplatesKeys,
|
||||
useAddAdminCourseTemplateMutation,
|
||||
useAdminCourseTemplateQuery,
|
||||
useAdminCourseTemplatesListQuery,
|
||||
useUpdateAdminCourseTemplateMutation,
|
||||
} from '@/services/query/admin-course-templates'
|
||||
import { useUploadTemporaryMutation } from '@/services/query/auth'
|
||||
import { useAdminUsersListQuery } from '@/services/query/admin-users'
|
||||
import { courseTemplateSchema } from '@/features/admin/courses/schema'
|
||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const courseId = computed(() => (route.params.id ? Number(route.params.id) : null))
|
||||
const isEditMode = computed(() => !!courseId.value)
|
||||
|
||||
const form = ref({
|
||||
title: '',
|
||||
defaultTeacherId: '',
|
||||
prerequisites: [],
|
||||
defaultCapacity: '',
|
||||
description: '',
|
||||
imageId: null,
|
||||
isActiveByDefault: false,
|
||||
})
|
||||
|
||||
const image = ref(null)
|
||||
|
||||
const schema = courseTemplateSchema
|
||||
|
||||
const { validate, validateAt, errors } = useYup(schema)
|
||||
|
||||
const teacherSearch = ref('')
|
||||
const teacherFilters = computed(() => ({ name: teacherSearch.value }))
|
||||
const teacherPagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: teachersResponse } = useAdminUsersListQuery(teacherFilters, teacherPagination)
|
||||
const selectedTeacher = ref(null)
|
||||
const teacherOptions = computed(() => {
|
||||
const base = teachersResponse.value?.data ?? []
|
||||
const merged =
|
||||
selectedTeacher.value && !base.some((t) => t.id === selectedTeacher.value.id)
|
||||
? [...base, selectedTeacher.value]
|
||||
: base
|
||||
return merged.map((t) => ({
|
||||
...t,
|
||||
label: `${t.firstName || ''} ${t.lastName || ''}`.trim() || t.fullName || '—',
|
||||
}))
|
||||
})
|
||||
|
||||
const prereqSearch = ref('')
|
||||
const prereqFilters = computed(() => ({ title: prereqSearch.value }))
|
||||
const prereqPagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: prereqsResponse } = useAdminCourseTemplatesListQuery(prereqFilters, prereqPagination)
|
||||
const selectedPrereqs = ref([])
|
||||
const prerequisiteOptions = computed(() => {
|
||||
const base = prereqsResponse.value?.data ?? []
|
||||
const extras = selectedPrereqs.value.filter((p) => !base.some((b) => b.id === p.id))
|
||||
return [...base, ...extras]
|
||||
})
|
||||
|
||||
const searchTeachers = useDebounce((q) => {
|
||||
teacherSearch.value = q || ''
|
||||
}, 400)
|
||||
const searchPrerequisites = useDebounce((q) => {
|
||||
prereqSearch.value = q || ''
|
||||
}, 400)
|
||||
|
||||
const { data: existingCourse } = useAdminCourseTemplateQuery(courseId, {
|
||||
enabled: () => !!courseId.value,
|
||||
})
|
||||
|
||||
watch(existingCourse, (course) => {
|
||||
if (!course) return
|
||||
const teacher = course.defaultTeacher || course.teacher
|
||||
if (teacher) selectedTeacher.value = teacher
|
||||
const prereqs = Array.isArray(course.prerequisites) ? course.prerequisites : []
|
||||
selectedPrereqs.value = prereqs.map((p) => p.course || p).filter((c) => c?.id)
|
||||
|
||||
form.value = {
|
||||
title: course.title || '',
|
||||
defaultTeacherId: teacher?.id || course.defaultTeacherId || '',
|
||||
prerequisites: prereqs.map((p) => p.courseId ?? p.id).filter(Boolean),
|
||||
defaultCapacity: course.defaultCapacity ?? course.capacity ?? '',
|
||||
description: course.description || '',
|
||||
imageId: course.imageId || null,
|
||||
isActiveByDefault: course.isActiveByDefault ?? course.isActive ?? false,
|
||||
}
|
||||
if (course.image) image.value = { url: course.image }
|
||||
})
|
||||
|
||||
const uploadMutation = useUploadTemporaryMutation()
|
||||
|
||||
const onImageCropped = async (file) => {
|
||||
try {
|
||||
const formData = objectToFormData({ file, subType: 'avatar', context: 'course' })
|
||||
const response = await uploadMutation.mutateAsync(formData)
|
||||
const payload = response?.data ?? response
|
||||
image.value = { url: payload?.url, uploadId: payload?.uploadId, ...payload }
|
||||
form.value.imageId = payload?.uploadId || payload?.id
|
||||
} catch {
|
||||
/* handled globally */
|
||||
}
|
||||
}
|
||||
|
||||
const onImageError = (msg) => toast.error(msg)
|
||||
|
||||
const addMutation = useAddAdminCourseTemplateMutation()
|
||||
const updateMutation = useUpdateAdminCourseTemplateMutation()
|
||||
|
||||
const submitting = computed(() => addMutation.isPending.value || updateMutation.isPending.value)
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
if (isEditMode.value) {
|
||||
await updateMutation.mutateAsync({ id: courseId.value, payload })
|
||||
} else {
|
||||
await addMutation.mutateAsync(payload)
|
||||
}
|
||||
await queryClient.invalidateQueries({ queryKey: adminCourseTemplatesKeys.all })
|
||||
router.push({ name: 'admin-courses' })
|
||||
}
|
||||
|
||||
const onCancel = () => router.push({ name: 'admin-courses' })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.course-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__form {
|
||||
background: rgba(255, 255, 255, 60%);
|
||||
padding: 1rem;
|
||||
border-radius: 1rem;
|
||||
}
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 1rem;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: 4fr 8fr;
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: 3fr 9fr;
|
||||
}
|
||||
}
|
||||
|
||||
&__image-col {
|
||||
order: 2;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
order: 1;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__main-col {
|
||||
order: 1;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
order: 2;
|
||||
padding-inline-start: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
flex-flow: column wrap;
|
||||
gap: 0.5rem;
|
||||
align-items: stretch;
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
flex-direction: row;
|
||||
}
|
||||
}
|
||||
|
||||
&__cell {
|
||||
width: 100%;
|
||||
|
||||
&--third {
|
||||
@media (min-width: 768px) {
|
||||
width: 49%;
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
width: 32.3%;
|
||||
}
|
||||
}
|
||||
|
||||
&--full {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&__toggle-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.5rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
&__btn-submit {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,283 @@
|
||||
<template>
|
||||
<div class="courses-page">
|
||||
<BoxedIconTitleBlock
|
||||
class="courses-page__heading"
|
||||
title="مدیریت دوره"
|
||||
desc="در این قسمت میتوانید دورههای خود را مدیریت کنید"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="book" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<CoursesFilters
|
||||
v-model="currentFilters"
|
||||
:show-term-filter="activeTab === 'offered'"
|
||||
@apply="onFilterApply"
|
||||
@reset="onFilterReset"
|
||||
/>
|
||||
|
||||
<div class="courses-page__list-header">
|
||||
<SimpleTitleIconBlock
|
||||
:title="activeTab === 'templates' ? 'لیست دورههای الگو' : 'لیست دورههای ارائه شده'"
|
||||
class="courses-page__list-title"
|
||||
>
|
||||
<template #header-icon>
|
||||
<SvgIcon name="list-bullets" :size="16" color="#bcbcbc" />
|
||||
</template>
|
||||
</SimpleTitleIconBlock>
|
||||
<BaseButton
|
||||
:text="activeTab === 'templates' ? 'افزودن دوره الگو' : 'افزودن دوره ارائه شده'"
|
||||
custom-class="courses-page__add-btn"
|
||||
@click="onAdd"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="plus" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<TabsBlock :tabs="tabs" v-model="activeTab" @change-tab="onTabChange">
|
||||
<template #templates>
|
||||
<SkeletonLoaderBlock v-if="templatesPending" :rows="6" :cols-per-row="1" />
|
||||
<div v-else-if="templates.length > 0">
|
||||
<CourseItem
|
||||
v-for="course in templates"
|
||||
:key="course.id"
|
||||
:course="course"
|
||||
@edit="onEditTemplate"
|
||||
@delete="onAskDeleteTemplate"
|
||||
@change-status="onChangeTemplateStatus"
|
||||
@show-details="onShowDetails"
|
||||
/>
|
||||
</div>
|
||||
<NoItems v-else title="متاسفیم" desc="دوره الگویی برای نمایش وجود ندارد." />
|
||||
<PaginationBlock :pagination="templatesPaginationMeta" @update:page="setTemplatesPage" />
|
||||
</template>
|
||||
|
||||
<template #offered>
|
||||
<SkeletonLoaderBlock v-if="offeredPending" :rows="6" :cols-per-row="1" />
|
||||
<div v-else-if="offered.length > 0">
|
||||
<CourseItem
|
||||
v-for="course in offered"
|
||||
:key="course.id"
|
||||
:course="course"
|
||||
@edit="onEditOffered"
|
||||
@delete="onAskDeleteOffered"
|
||||
@change-status="onChangeOfferedStatus"
|
||||
@show-details="onShowDetails"
|
||||
/>
|
||||
</div>
|
||||
<NoItems v-else title="متاسفیم" desc="دورهای برای نمایش وجود ندارد." />
|
||||
<PaginationBlock :pagination="offeredPaginationMeta" @update:page="setOfferedPage" />
|
||||
</template>
|
||||
</TabsBlock>
|
||||
|
||||
<AddOfferedCourseModal v-if="isModal('AddOfferedCourseModal')" />
|
||||
<CourseDetailsModal v-if="isModal('CourseDetailsModal')" />
|
||||
<AddCourseStudentModal v-if="isModal('AddCourseStudentModal')" />
|
||||
<AddSessionToCourseModal v-if="isModal('AddSessionToCourseModal')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import TabsBlock from '@/components/blocks/TabsBlock.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import CoursesFilters from '@/features/admin/courses/components/CoursesFilters.vue'
|
||||
import CourseItem from '@/features/admin/courses/components/CourseItem.vue'
|
||||
import AddOfferedCourseModal from '@/features/admin/courses/components/modals/AddOfferedCourseModal.vue'
|
||||
import CourseDetailsModal from '@/features/admin/courses/components/modals/CourseDetailsModal.vue'
|
||||
import AddCourseStudentModal from '@/features/admin/courses/components/modals/AddCourseStudentModal.vue'
|
||||
import AddSessionToCourseModal from '@/features/admin/courses/components/modals/AddSessionToCourseModal.vue'
|
||||
import {
|
||||
adminCourseTemplatesKeys,
|
||||
useAdminCourseTemplatesListQuery,
|
||||
useChangeAdminCourseTemplateStatusMutation,
|
||||
useDeleteAdminCourseTemplateMutation,
|
||||
} from '@/services/query/admin-course-templates'
|
||||
import {
|
||||
adminCoursesKeys,
|
||||
useAdminCoursesListQuery,
|
||||
useChangeAdminCourseStatusMutation,
|
||||
useDeleteAdminCourseMutation,
|
||||
} from '@/services/query/admin-courses'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import useModal from '@/composables/useModal'
|
||||
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
const { openModal, isModal } = useModal()
|
||||
|
||||
const tabs = [
|
||||
{ name: 'templates', label: 'دورههای الگو', icon: 'list-bullets' },
|
||||
{ name: 'offered', label: 'دورههای ارائه شده', icon: 'list-bullets' },
|
||||
]
|
||||
const activeTab = ref('templates')
|
||||
|
||||
const templateFilters = ref({ title: '', status: '', fromDate: '', toDate: '' })
|
||||
const offeredFilters = ref({ title: '', termId: '', status: '', fromDate: '', toDate: '' })
|
||||
|
||||
const currentFilters = computed({
|
||||
get: () => (activeTab.value === 'templates' ? templateFilters.value : offeredFilters.value),
|
||||
set: (val) => {
|
||||
if (activeTab.value === 'templates') templateFilters.value = val
|
||||
else offeredFilters.value = val
|
||||
},
|
||||
})
|
||||
|
||||
const {
|
||||
pagination: templatesPagination,
|
||||
setPage: setTemplatesPage,
|
||||
reset: resetTemplatesPagination,
|
||||
} = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const {
|
||||
pagination: offeredPagination,
|
||||
setPage: setOfferedPage,
|
||||
reset: resetOfferedPagination,
|
||||
} = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data: templatesData, isLoading: templatesPending } = useAdminCourseTemplatesListQuery(
|
||||
templateFilters,
|
||||
templatesPagination,
|
||||
{
|
||||
enabled: () => activeTab.value === 'templates',
|
||||
keepPreviousData: true,
|
||||
}
|
||||
)
|
||||
|
||||
const { data: offeredData, isLoading: offeredPending } = useAdminCoursesListQuery(
|
||||
offeredFilters,
|
||||
offeredPagination,
|
||||
{
|
||||
enabled: () => activeTab.value === 'offered',
|
||||
keepPreviousData: true,
|
||||
}
|
||||
)
|
||||
|
||||
const templates = computed(() => templatesData.value?.data ?? [])
|
||||
const templatesPaginationMeta = computed(() => ({
|
||||
page: templatesPagination.value.page,
|
||||
perPage: templatesPagination.value.perPage,
|
||||
...templatesData.value?.meta,
|
||||
}))
|
||||
|
||||
const offered = computed(() => offeredData.value?.data ?? [])
|
||||
const offeredPaginationMeta = computed(() => ({
|
||||
page: offeredPagination.value.page,
|
||||
perPage: offeredPagination.value.perPage,
|
||||
...offeredData.value?.meta,
|
||||
}))
|
||||
|
||||
const onTabChange = () => {
|
||||
/* tab managed via v-model; no further action required */
|
||||
}
|
||||
|
||||
const onFilterApply = () => {
|
||||
if (activeTab.value === 'templates') resetTemplatesPagination()
|
||||
else resetOfferedPagination()
|
||||
}
|
||||
const onFilterReset = onFilterApply
|
||||
|
||||
const onAdd = () => {
|
||||
if (activeTab.value === 'templates') {
|
||||
router.push({ name: 'admin-add-course-template' }).catch(() => {})
|
||||
} else {
|
||||
openModal('AddOfferedCourseModal', { mode: 'add' })
|
||||
}
|
||||
}
|
||||
|
||||
const onEditTemplate = (course) => {
|
||||
router.push({ name: 'admin-edit-course-template', params: { id: course.id } }).catch(() => {})
|
||||
}
|
||||
|
||||
const onEditOffered = (course) => {
|
||||
openModal('AddOfferedCourseModal', { mode: 'edit', courseId: course.id })
|
||||
}
|
||||
|
||||
const onShowDetails = (course) => {
|
||||
openModal('CourseDetailsModal', {
|
||||
id: course.id,
|
||||
type: activeTab.value === 'templates' ? 'template' : 'offered',
|
||||
})
|
||||
}
|
||||
|
||||
const invalidateTemplates = () =>
|
||||
queryClient.invalidateQueries({ queryKey: adminCourseTemplatesKeys.all })
|
||||
const invalidateOffered = () => queryClient.invalidateQueries({ queryKey: adminCoursesKeys.all })
|
||||
|
||||
const deleteTemplateMutation = useDeleteAdminCourseTemplateMutation()
|
||||
const changeTemplateStatusMutation = useChangeAdminCourseTemplateStatusMutation()
|
||||
|
||||
const deleteOfferedMutation = useDeleteAdminCourseMutation()
|
||||
const changeOfferedStatusMutation = useChangeAdminCourseStatusMutation()
|
||||
|
||||
const onAskDeleteTemplate = (course) => {
|
||||
openModal('ConfirmModal', {
|
||||
title: `حذف ${course.title}`,
|
||||
message: `بعد از حذف امکان بازگشت وجود ندارد، آیا مطمئن هستید که میخواهید <strong>${course.title}</strong> را حذف کنید؟`,
|
||||
onConfirm: () => deleteTemplateMutation.mutate(course.id, { onSuccess: invalidateTemplates }),
|
||||
})
|
||||
}
|
||||
|
||||
const onAskDeleteOffered = (course) => {
|
||||
openModal('ConfirmModal', {
|
||||
title: `حذف ${course.title}`,
|
||||
message: `بعد از حذف امکان بازگشت وجود ندارد، آیا مطمئن هستید که میخواهید <strong>${course.title}</strong> را حذف کنید؟`,
|
||||
onConfirm: () => deleteOfferedMutation.mutate(course.id, { onSuccess: invalidateOffered }),
|
||||
})
|
||||
}
|
||||
|
||||
const onChangeTemplateStatus = ({ id, isActive }) => {
|
||||
changeTemplateStatusMutation.mutate(
|
||||
{ id, payload: { isActiveByDefault: isActive } },
|
||||
{ onSuccess: invalidateTemplates }
|
||||
)
|
||||
}
|
||||
|
||||
const onChangeOfferedStatus = ({ id, isActive }) => {
|
||||
changeOfferedStatusMutation.mutate(
|
||||
{ id, payload: { isActive } },
|
||||
{ onSuccess: invalidateOffered }
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.courses-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__list-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
margin-bottom: 0.375rem;
|
||||
}
|
||||
|
||||
&__list-title {
|
||||
flex: 1;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&__add-btn {
|
||||
min-width: fit-content;
|
||||
padding: 0 1.25rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,18 @@
|
||||
import { array, boolean, object, string } from 'yup'
|
||||
|
||||
export const courseTemplateSchema = object().shape({
|
||||
title: string().required().min(3).max(255),
|
||||
defaultTeacherId: string().required(),
|
||||
defaultCapacity: string().required(),
|
||||
prerequisites: array().nullable().default([]),
|
||||
description: string().nullable().notRequired(),
|
||||
})
|
||||
|
||||
export const offeredCourseSchema = object().shape({
|
||||
termId: string().required(),
|
||||
templateId: string().required(),
|
||||
title: string().required(),
|
||||
capacity: string().required(),
|
||||
imageId: string().nullable().notRequired(),
|
||||
isActive: boolean().nullable().notRequired(),
|
||||
})
|
||||
@@ -0,0 +1,204 @@
|
||||
<template>
|
||||
<div class="exam-item">
|
||||
<div class="exam-item__main">
|
||||
<p class="exam-item__title">{{ exam.title || '—' }}</p>
|
||||
<div class="exam-item__sub">
|
||||
<span class="exam-item__sub-label">دوره:</span>
|
||||
<span class="exam-item__sub-value">
|
||||
{{ exam.courseTemplate?.title || exam.courseTemplateTitle || '—' }}
|
||||
</span>
|
||||
<span class="exam-item__dot">|</span>
|
||||
<span class="exam-item__sub-label">جلسه:</span>
|
||||
<span class="exam-item__sub-value">
|
||||
{{ exam.session?.title || exam.sessionTitle || '—' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="exam-item__meta">
|
||||
<div class="exam-item__pill">
|
||||
<span class="exam-item__pill-label">مدت آزمون:</span>
|
||||
<span class="exam-item__pill-value">{{ duration }}</span>
|
||||
</div>
|
||||
<div class="exam-item__pill">
|
||||
<span class="exam-item__pill-label">تعداد سوالات:</span>
|
||||
<span class="exam-item__pill-value">{{ questions }}</span>
|
||||
</div>
|
||||
<div class="exam-item__pill">
|
||||
<span class="exam-item__pill-label">تاریخ ثبت:</span>
|
||||
<span class="exam-item__pill-value">{{ createdAt }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="exam-item__actions">
|
||||
<CircleButton
|
||||
tooltip="شرکتکنندگان"
|
||||
bg-color="rgba(0, 112, 116, 0.08)"
|
||||
size="2.5rem"
|
||||
@click="emit('show-participants', exam)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="users-three" :size="18" color="#007074" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="حذف"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('delete', exam)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="18" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="ویرایش"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('edit', exam)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="pencil" :size="18" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<BaseButton
|
||||
text="جزئیات آزمون"
|
||||
custom-class="exam-item__details-btn"
|
||||
@click="emit('show-details', exam)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
const props = defineProps({
|
||||
exam: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['edit', 'delete', 'show-details', 'show-participants'])
|
||||
|
||||
const duration = computed(() =>
|
||||
props.exam.durationMinutes == null ? '—' : `${props.exam.durationMinutes} دقیقه`
|
||||
)
|
||||
|
||||
const questions = computed(() =>
|
||||
props.exam.questionsCount == null ? '—' : `${props.exam.questionsCount} سوال`
|
||||
)
|
||||
|
||||
const createdAt = computed(
|
||||
() => props.exam.faCreatedAt || formatJalaaliDate(props.exam.createdAt) || '—'
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.exam-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;
|
||||
}
|
||||
|
||||
&__main {
|
||||
flex: 1 1 25%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__sub-label {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
&__sub-value {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&__dot {
|
||||
color: #c4c4c4;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 41%;
|
||||
}
|
||||
|
||||
&__pill {
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
padding: 0.25rem 1rem;
|
||||
border-radius: 0.875rem;
|
||||
line-height: 1.5;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__pill-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 300;
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__pill-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 500;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 100%;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
}
|
||||
|
||||
&__details-btn {
|
||||
min-width: 8rem;
|
||||
padding: 0 0.875rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,406 @@
|
||||
<template>
|
||||
<div class="exam-question-builder">
|
||||
<div
|
||||
v-for="(question, questionIndex) in questions"
|
||||
:key="question.id"
|
||||
class="exam-question-builder__card"
|
||||
>
|
||||
<div class="exam-question-builder__head">
|
||||
<p class="exam-question-builder__title">سوال شماره {{ questionIndex + 1 }}</p>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="disabled"
|
||||
class="exam-question-builder__remove"
|
||||
aria-label="حذف سوال"
|
||||
@click="removeQuestion(question.id)"
|
||||
>
|
||||
<SvgIcon name="close" :size="20" color="#b1b1b1" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="exam-question-builder__row">
|
||||
<div class="exam-question-builder__col exam-question-builder__col--main">
|
||||
<label class="exam-question-builder__label">متن سوال</label>
|
||||
<textarea
|
||||
:value="question.title"
|
||||
:disabled="disabled"
|
||||
rows="1"
|
||||
placeholder="لطفا سوال خود را وارد کنید"
|
||||
class="exam-question-builder__textarea"
|
||||
@input="updateQuestion(question.id, { title: $event.target.value })"
|
||||
/>
|
||||
</div>
|
||||
<div class="exam-question-builder__col exam-question-builder__col--score">
|
||||
<label class="exam-question-builder__label">بارم نمره</label>
|
||||
<input
|
||||
:value="question.score"
|
||||
:disabled="disabled"
|
||||
type="text"
|
||||
inputmode="numeric"
|
||||
placeholder="15"
|
||||
class="exam-question-builder__input"
|
||||
@input="updateQuestion(question.id, { score: $event.target.value })"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="exam-question-builder__answers-row">
|
||||
<div class="exam-question-builder__answers">
|
||||
<p class="exam-question-builder__label">گزینهها</p>
|
||||
<div class="exam-question-builder__answers-list">
|
||||
<div
|
||||
v-for="answer in question.answers"
|
||||
:key="answer.id"
|
||||
class="exam-question-builder__answer"
|
||||
>
|
||||
<input
|
||||
:value="answer.title"
|
||||
:disabled="disabled"
|
||||
type="text"
|
||||
placeholder="متن گزینه"
|
||||
class="exam-question-builder__answer-input"
|
||||
@input="updateOption(question.id, answer.id, $event.target.value)"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="disabled"
|
||||
class="exam-question-builder__answer-remove"
|
||||
aria-label="حذف گزینه"
|
||||
@click="removeOption(question.id, answer.id)"
|
||||
>
|
||||
<SvgIcon name="close" :size="14" color="#b1b1b1" />
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="disabled"
|
||||
class="exam-question-builder__answer-add"
|
||||
aria-label="افزودن گزینه"
|
||||
@click="addOption(question.id)"
|
||||
>
|
||||
<SvgIcon name="plus" :size="16" color="#b1b1b1" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="exam-question-builder__correct">
|
||||
<SelectField
|
||||
:model-value="question.correctAnswerId"
|
||||
:name="`correctAnswer-${question.id}`"
|
||||
:options="correctAnswerOptions(question)"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
label="گزینه صحیح"
|
||||
:disabled="disabled || question.answers.length === 0"
|
||||
@update:model-value="
|
||||
(value) => updateQuestion(question.id, { correctAnswerId: value || null })
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
:disabled="disabled"
|
||||
class="exam-question-builder__add"
|
||||
aria-label="افزودن سوال"
|
||||
@click="addQuestion"
|
||||
>
|
||||
<SvgIcon name="plus" :size="20" color="#b1b1b1" />
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: Array, default: () => [] },
|
||||
disabled: { type: Boolean, default: false },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const defaultLabels = ['گزینه اول', 'گزینه دوم', 'گزینه سوم', 'گزینه چهارم']
|
||||
|
||||
const questions = computed(() => (Array.isArray(props.modelValue) ? props.modelValue : []))
|
||||
|
||||
const cloneQuestions = () =>
|
||||
questions.value.map((q) => ({
|
||||
...q,
|
||||
answers: Array.isArray(q.answers) ? q.answers.map((a) => ({ ...a })) : [],
|
||||
}))
|
||||
|
||||
const createId = (prefix) => `${prefix}-${Date.now()}-${Math.random().toString(16).slice(2)}`
|
||||
|
||||
const createOption = () => ({ id: createId('answer'), title: '' })
|
||||
|
||||
const createQuestion = () => ({
|
||||
id: createId('question'),
|
||||
title: '',
|
||||
score: '',
|
||||
correctAnswerId: null,
|
||||
answers: [createOption(), createOption()],
|
||||
})
|
||||
|
||||
const emitQuestions = (next) => emit('update:modelValue', next)
|
||||
|
||||
const addQuestion = () => emitQuestions([...cloneQuestions(), createQuestion()])
|
||||
|
||||
const removeQuestion = (questionId) => {
|
||||
const next = cloneQuestions().filter((q) => q.id !== questionId)
|
||||
emitQuestions(next.length > 0 ? next : [createQuestion()])
|
||||
}
|
||||
|
||||
const updateQuestion = (questionId, patch) => {
|
||||
const next = cloneQuestions().map((q) => (q.id === questionId ? { ...q, ...patch } : q))
|
||||
emitQuestions(next)
|
||||
}
|
||||
|
||||
const addOption = (questionId) => {
|
||||
const next = cloneQuestions().map((q) => {
|
||||
if (q.id !== questionId) return q
|
||||
return { ...q, answers: [...q.answers, createOption()] }
|
||||
})
|
||||
emitQuestions(next)
|
||||
}
|
||||
|
||||
const removeOption = (questionId, answerId) => {
|
||||
const next = cloneQuestions().map((q) => {
|
||||
if (q.id !== questionId) return q
|
||||
const answers = q.answers.filter((a) => a.id !== answerId)
|
||||
return {
|
||||
...q,
|
||||
answers,
|
||||
correctAnswerId: String(q.correctAnswerId) === String(answerId) ? null : q.correctAnswerId,
|
||||
}
|
||||
})
|
||||
emitQuestions(next)
|
||||
}
|
||||
|
||||
const updateOption = (questionId, answerId, title) => {
|
||||
const next = cloneQuestions().map((q) => {
|
||||
if (q.id !== questionId) return q
|
||||
return {
|
||||
...q,
|
||||
answers: q.answers.map((a) => (a.id === answerId ? { ...a, title } : a)),
|
||||
}
|
||||
})
|
||||
emitQuestions(next)
|
||||
}
|
||||
|
||||
const optionLabel = (index) => defaultLabels[index] || `گزینه ${index + 1}`
|
||||
|
||||
const correctAnswerOptions = (question) =>
|
||||
question.answers.map((a, idx) => ({ value: a.id, label: optionLabel(idx) }))
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.exam-question-builder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
|
||||
&__card {
|
||||
border: 1px solid #e7e2dd;
|
||||
border-radius: 1.5rem;
|
||||
padding: 0.875rem;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 2.5%);
|
||||
}
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: #4b4b4b;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__remove {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border-radius: 9999px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:hover {
|
||||
background: #f8f8f8;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: 5fr 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
&__col--main {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__label {
|
||||
display: block;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 300;
|
||||
color: var(--color-prim-gray);
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
&__textarea,
|
||||
&__input {
|
||||
width: 100%;
|
||||
border: 1px solid var(--color-thd-gray);
|
||||
border-radius: 1.5rem;
|
||||
padding: 0.5rem 1.25rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.9rem;
|
||||
color: #4b4b4b;
|
||||
outline: none;
|
||||
|
||||
&:focus {
|
||||
box-shadow: 0 0 0 1px var(--color-validate, var(--color-primary));
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
&__textarea {
|
||||
resize: none;
|
||||
min-height: 2.35rem;
|
||||
}
|
||||
|
||||
&__input {
|
||||
height: 2.35rem;
|
||||
font-family: var(--font-family-en);
|
||||
}
|
||||
|
||||
&__answers-row {
|
||||
margin-top: 0.75rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
flex-direction: row;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
|
||||
&__answers {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__answers-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__answer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
border: 1px solid var(--color-thd-gray);
|
||||
border-radius: 1.5rem;
|
||||
padding: 0.375rem 0.875rem;
|
||||
min-width: 10rem;
|
||||
}
|
||||
|
||||
&__answer-input {
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
color: #4b4b4b;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&__answer-remove,
|
||||
&__answer-add {
|
||||
border: none;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
border-radius: 9999px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
&__answer-add {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
background: rgba(104, 104, 104, 5%);
|
||||
}
|
||||
|
||||
&__correct {
|
||||
width: 100%;
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
width: 14rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__add {
|
||||
height: 3rem;
|
||||
width: 100%;
|
||||
border-radius: 1rem;
|
||||
border: 1px dashed #e7e2dd;
|
||||
background: #f7f7f7;
|
||||
color: #b1b1b1;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--color-primary);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,136 @@
|
||||
<template>
|
||||
<form class="exams-filters" @submit.prevent="onSubmit">
|
||||
<div class="exams-filters__grid">
|
||||
<TextField v-model="form.title" name="title" label="عنوان آزمون">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="book" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.courseTemplateId"
|
||||
name="courseTemplateId"
|
||||
label="دوره الگو"
|
||||
:options="templateOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchTemplates"
|
||||
/>
|
||||
<DatePickerField v-model="form.fromDate" name="fromDate" label="از تاریخ" :max="todayIso" />
|
||||
<DatePickerField v-model="form.toDate" name="toDate" label="تا تاریخ" :max="todayIso" />
|
||||
</div>
|
||||
|
||||
<div class="exams-filters__actions">
|
||||
<CircleButton
|
||||
v-if="hasFilters"
|
||||
tooltip="حذف فیلتر"
|
||||
bg-color="transparent"
|
||||
size="2.5rem"
|
||||
type="button"
|
||||
@click="onReset"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="اعمال فیلتر"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
type="submit"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="funnel" :size="20" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { useAdminCourseTemplatesListQuery } from '@/services/query/admin-course-templates'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: () => ({ title: '', courseTemplateId: '', fromDate: '', toDate: '' }),
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'apply', 'reset'])
|
||||
|
||||
const emptyForm = () => ({ title: '', courseTemplateId: '', fromDate: '', toDate: '' })
|
||||
const form = ref({ ...emptyForm(), ...props.modelValue })
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(next) => {
|
||||
form.value = { ...emptyForm(), ...next }
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const todayIso = new Date().toISOString()
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: templatesResponse } = useAdminCourseTemplatesListQuery(
|
||||
templateFilters,
|
||||
templatePagination
|
||||
)
|
||||
const templateOptions = computed(() => templatesResponse.value?.data ?? [])
|
||||
|
||||
const searchTemplates = useDebounce((q) => {
|
||||
templateSearch.value = q || ''
|
||||
}, 400)
|
||||
|
||||
const hasFilters = computed(() =>
|
||||
Object.values(form.value).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
)
|
||||
|
||||
const onSubmit = () => {
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('apply', { ...form.value })
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
form.value = emptyForm()
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.exams-filters {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
|
||||
&__grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding-top: 1.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,236 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="60rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<div class="exam-details">
|
||||
<LineTitleBlock title="جزئیات آزمون" title-en="Exam Details" />
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="3" :cols-per-row="1" />
|
||||
<template v-else-if="exam">
|
||||
<div class="exam-details__head">
|
||||
<p class="exam-details__title">{{ exam.title || '—' }}</p>
|
||||
<p class="exam-details__sub">
|
||||
<span>دوره: {{ exam.courseTemplate?.title || exam.courseTemplateTitle || '—' }}</span>
|
||||
<span class="exam-details__sep">|</span>
|
||||
<span>جلسه: {{ exam.session?.title || exam.sessionTitle || '—' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="exam-details__grid">
|
||||
<LineInfoBlock
|
||||
title="مدت آزمون"
|
||||
:numeric-desc="exam.durationMinutes != null ? `${exam.durationMinutes} دقیقه` : '—'"
|
||||
/>
|
||||
<LineInfoBlock title="حداقل نمره قبولی" :numeric-desc="exam.passingScore ?? '—'" />
|
||||
<LineInfoBlock
|
||||
title="تعداد سوالات"
|
||||
:numeric-desc="exam.questionsCount ?? questionsLength"
|
||||
/>
|
||||
<LineInfoBlock title="رندوم" :desc="exam.randomize ? 'بله' : 'خیر'" />
|
||||
<LineInfoBlock
|
||||
title="تاریخ اعتبار"
|
||||
:numeric-desc="formatJalaaliDate(exam.endDate) || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="تاریخ ثبت"
|
||||
:numeric-desc="exam.faCreatedAt || formatJalaaliDate(exam.createdAt) || '—'"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="exam.description" class="exam-details__desc">
|
||||
<LineInfoBlock title="توضیحات" :desc="exam.description" />
|
||||
</div>
|
||||
|
||||
<div v-if="exam.questions?.length" class="exam-details__questions">
|
||||
<LineTitleBlock title="سوالات" title-en="Questions" />
|
||||
<div v-for="(q, index) in exam.questions" :key="q.id" class="exam-details__question">
|
||||
<p class="exam-details__question-title">
|
||||
<span class="exam-details__question-index">{{ index + 1 }}.</span>
|
||||
{{ q.title }}
|
||||
<span v-if="q.score" class="exam-details__question-score">
|
||||
({{ q.score }} نمره)
|
||||
</span>
|
||||
</p>
|
||||
<ul class="exam-details__answers">
|
||||
<li
|
||||
v-for="(a, ai) in q.answers || []"
|
||||
:key="a.id"
|
||||
class="exam-details__answer"
|
||||
:class="{
|
||||
'exam-details__answer--correct': String(q.correctAnswerId) === String(a.id),
|
||||
}"
|
||||
>
|
||||
<span class="exam-details__answer-index">{{ optionLabel(ai) }}:</span>
|
||||
{{ a.title }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<NoItems v-else title="یافت نشد" desc="اطلاعات این آزمون در دسترس نیست." />
|
||||
|
||||
<div class="exam-details__divider" />
|
||||
|
||||
<div class="exam-details__footer">
|
||||
<BaseButton text="بستن" custom-class="exam-details__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { useAdminExamQuery } from '@/services/query/admin-exams'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'ExamDetailsModal' })
|
||||
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('ExamDetailsModal')?.data ?? {})
|
||||
const examId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const { data: exam, isLoading } = useAdminExamQuery(examId, {
|
||||
enabled: () => !!examId.value,
|
||||
})
|
||||
|
||||
const questionsLength = computed(() => exam.value?.questions?.length ?? 0)
|
||||
|
||||
const labels = ['گزینه اول', 'گزینه دوم', 'گزینه سوم', 'گزینه چهارم']
|
||||
const optionLabel = (index) => labels[index] || `گزینه ${index + 1}`
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.exam-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__head {
|
||||
margin: 1rem 0 0.5rem;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1.1rem;
|
||||
font-weight: 500;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #535353;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: #c4c4c4;
|
||||
}
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.25rem;
|
||||
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__desc,
|
||||
&__questions {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
&__question {
|
||||
padding: 0.625rem 0;
|
||||
border-block-end: 1px solid #f0f0f0;
|
||||
|
||||
&:last-child {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__question-title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.9rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.375rem;
|
||||
}
|
||||
|
||||
&__question-index {
|
||||
color: #b3b3b3;
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__question-score {
|
||||
margin-inline-start: 0.25rem;
|
||||
color: #007074;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
&__answers {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
&__answer {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
color: #4b4b4b;
|
||||
padding: 0.25rem 0.625rem;
|
||||
border-radius: 0.5rem;
|
||||
background: #fafafa;
|
||||
|
||||
&--correct {
|
||||
background: rgba(0, 154, 18, 8%);
|
||||
color: #009a12;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
&__answer-index {
|
||||
color: #9c9c9c;
|
||||
margin-inline-end: 0.375rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 10rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,289 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="80rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<div class="participant-details">
|
||||
<LineTitleBlock title="جزئیات شرکتکننده" title-en="Participant Details" />
|
||||
<p v-if="participant" class="participant-details__name">
|
||||
{{ participantName }}
|
||||
</p>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="3" :cols-per-row="1" />
|
||||
<div v-else-if="attempts.length > 0" class="participant-details__list">
|
||||
<div v-for="attempt in attempts" :key="attempt.id" class="participant-details__attempt">
|
||||
<button
|
||||
type="button"
|
||||
class="participant-details__attempt-head"
|
||||
@click="toggle(attempt.id)"
|
||||
>
|
||||
<SvgIcon
|
||||
:name="isOpen(attempt.id) ? 'caret-down' : 'caret-left'"
|
||||
:size="18"
|
||||
color="#d8d8d8"
|
||||
/>
|
||||
<div class="participant-details__attempt-info">
|
||||
<p class="participant-details__attempt-title">{{ attempt.title || 'تلاش' }}</p>
|
||||
<div class="participant-details__attempt-meta">
|
||||
<span>دوره: {{ attempt.courseTitle || '—' }}</span>
|
||||
<span class="participant-details__sep">|</span>
|
||||
<span>جلسه: {{ attempt.sessionTitle || '—' }}</span>
|
||||
<span class="participant-details__sep">|</span>
|
||||
<span>تاریخ: {{ attemptDate(attempt) }}</span>
|
||||
<span
|
||||
class="participant-details__score"
|
||||
:class="`participant-details__score--${attempt.scoreTone || 'neutral'}`"
|
||||
>
|
||||
نمره: {{ attempt.score ?? '—' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div v-if="isOpen(attempt.id)" class="participant-details__body">
|
||||
<div
|
||||
v-for="(question, qIdx) in attempt.questions || []"
|
||||
:key="question.id"
|
||||
class="participant-details__question"
|
||||
>
|
||||
<p class="participant-details__question-title">
|
||||
{{ qIdx + 1 }}- {{ question.title }}
|
||||
</p>
|
||||
<div class="participant-details__answers">
|
||||
<span
|
||||
v-for="(answer, aIdx) in question.answers || []"
|
||||
:key="answer.id"
|
||||
class="participant-details__answer"
|
||||
:class="answerClass(question, answer)"
|
||||
>
|
||||
<span class="participant-details__answer-index">{{ aIdx + 1 }}.</span>
|
||||
{{ answer.title }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<NoItems v-else title="موردی یافت نشد" desc="تلاشی برای این شرکتکننده ثبت نشده است." />
|
||||
|
||||
<div class="participant-details__divider" />
|
||||
|
||||
<div class="participant-details__footer">
|
||||
<BaseButton text="بستن" custom-class="participant-details__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { useAdminExamParticipantQuery } from '@/services/query/admin-exams'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'ExamParticipantDetailsModal' })
|
||||
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('ExamParticipantDetailsModal')?.data ?? {})
|
||||
const examId = computed(() => modalData.value.examId ?? null)
|
||||
const participantId = computed(() => modalData.value.participantId ?? null)
|
||||
const participant = computed(() => modalData.value.participant ?? null)
|
||||
|
||||
const { data: detail, isLoading } = useAdminExamParticipantQuery(examId, participantId, {
|
||||
enabled: () => !!examId.value && !!participantId.value,
|
||||
})
|
||||
|
||||
const attempts = computed(() => detail.value?.attempts || detail.value?.data?.attempts || [])
|
||||
|
||||
const opened = ref(new Set())
|
||||
const isOpen = (id) => opened.value.has(id)
|
||||
const toggle = (id) => {
|
||||
const next = new Set(opened.value)
|
||||
if (next.has(id)) next.delete(id)
|
||||
else next.add(id)
|
||||
opened.value = next
|
||||
}
|
||||
|
||||
const participantName = computed(() => {
|
||||
const p = participant.value
|
||||
if (!p) return ''
|
||||
return `${p.firstName || ''} ${p.lastName || ''}`.trim() || p.fullName || ''
|
||||
})
|
||||
|
||||
const attemptDate = (attempt) => attempt.faDate || formatJalaaliDate(attempt.date) || '—'
|
||||
|
||||
const answerClass = (question, answer) => {
|
||||
const isCorrect = String(question.correctAnswerId) === String(answer.id)
|
||||
const isUserChoice = String(question.userAnswerId) === String(answer.id)
|
||||
if (isUserChoice && isCorrect) return 'participant-details__answer--correct'
|
||||
if (isUserChoice && !isCorrect) return 'participant-details__answer--wrong'
|
||||
if (isCorrect) return 'participant-details__answer--correct-outline'
|
||||
return ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.participant-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0.5rem 0 1rem;
|
||||
}
|
||||
|
||||
&__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
&__attempt {
|
||||
border: 1px solid #e7e2dd;
|
||||
border-radius: 1.5rem;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
&__attempt-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.75rem;
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
padding: 1rem 1.25rem;
|
||||
border: none;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&__attempt-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__attempt-title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 500;
|
||||
font-size: 1rem;
|
||||
color: #494949;
|
||||
margin: 0 0 0.5rem;
|
||||
}
|
||||
|
||||
&__attempt-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.625rem 1.25rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #8e8e8e;
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: #d6d6d6;
|
||||
}
|
||||
|
||||
&__score {
|
||||
padding: 0.25rem 0.875rem;
|
||||
border-radius: 0.55rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
|
||||
&--good {
|
||||
background: rgba(0, 154, 18, 8%);
|
||||
color: #009a12;
|
||||
}
|
||||
|
||||
&--neutral {
|
||||
background: rgba(180, 180, 180, 8%);
|
||||
color: #8e8e8e;
|
||||
}
|
||||
|
||||
&--bad {
|
||||
background: rgba(204, 40, 49, 8%);
|
||||
color: var(--color-error);
|
||||
}
|
||||
}
|
||||
|
||||
&__body {
|
||||
padding: 1rem 1.25rem 1.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
&__question-title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
color: #bdbdbd;
|
||||
margin: 0 0 0.75rem;
|
||||
}
|
||||
|
||||
&__answers {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.625rem 1rem;
|
||||
}
|
||||
|
||||
&__answer {
|
||||
border: 1px solid #e7e2dd;
|
||||
border-radius: 0.875rem;
|
||||
padding: 0.375rem 0.875rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
color: #4b4b4b;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
|
||||
&--correct {
|
||||
background: rgba(0, 154, 18, 8%);
|
||||
border-color: rgba(0, 154, 18, 40%);
|
||||
color: #009a12;
|
||||
}
|
||||
|
||||
&--correct-outline {
|
||||
border-color: rgba(0, 154, 18, 40%);
|
||||
color: #009a12;
|
||||
}
|
||||
|
||||
&--wrong {
|
||||
background: rgba(204, 40, 49, 8%);
|
||||
border-color: rgba(204, 40, 49, 40%);
|
||||
color: var(--color-error);
|
||||
}
|
||||
}
|
||||
|
||||
&__answer-index {
|
||||
font-family: var(--font-family-en);
|
||||
color: #b3b3b3;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,233 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="60rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ data, close }">
|
||||
<div class="exam-participants">
|
||||
<LineTitleBlock title="شرکتکنندگان" title-en="Participants" />
|
||||
<p v-if="data?.title" class="exam-participants__exam">{{ data.title }}</p>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="4" :cols-per-row="1" />
|
||||
<div v-else-if="participants.length > 0" class="exam-participants__list">
|
||||
<div
|
||||
v-for="participant in participants"
|
||||
:key="participant.id"
|
||||
class="exam-participants__row"
|
||||
>
|
||||
<div class="exam-participants__user">
|
||||
<div v-if="participant.avatarUrl" class="exam-participants__avatar">
|
||||
<img :src="participant.avatarUrl" :alt="userName(participant)" />
|
||||
</div>
|
||||
<div v-else class="exam-participants__avatar exam-participants__avatar--placeholder">
|
||||
<SvgIcon name="user" :size="20" color="#bcbcbc" />
|
||||
</div>
|
||||
<div>
|
||||
<p class="exam-participants__name">{{ userName(participant) }}</p>
|
||||
<p class="exam-participants__location">
|
||||
{{ participant.location || locationFromAddress(participant) || '—' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="exam-participants__pill">
|
||||
<span class="exam-participants__pill-label">تاریخ شرکت:</span>
|
||||
<span class="exam-participants__pill-value">{{ registeredAt(participant) }}</span>
|
||||
</div>
|
||||
|
||||
<BaseButton
|
||||
text="جزئیات"
|
||||
custom-class="exam-participants__details-btn"
|
||||
@click="onShowDetails(participant)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="14" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
<NoItems v-else title="موردی یافت نشد" desc="شرکتکنندهای ثبت نشده است." />
|
||||
|
||||
<PaginationBlock :pagination="paginationMeta" @update:page="setPage" />
|
||||
|
||||
<div class="exam-participants__divider" />
|
||||
|
||||
<div class="exam-participants__footer">
|
||||
<BaseButton text="بستن" custom-class="exam-participants__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import { useAdminExamParticipantsQuery } from '@/services/query/admin-exams'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'ExamParticipantsModal' })
|
||||
|
||||
const { getModal, openModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('ExamParticipantsModal')?.data ?? {})
|
||||
const examId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const filters = ref({})
|
||||
const { pagination, setPage } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = useAdminExamParticipantsQuery(examId, filters, pagination, {
|
||||
enabled: () => !!examId.value,
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
const participants = computed(() => data.value?.data ?? [])
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const userName = (p) => `${p.firstName || ''} ${p.lastName || ''}`.trim() || p.fullName || '—'
|
||||
|
||||
const locationFromAddress = (p) => {
|
||||
const province = p.address?.province?.name || ''
|
||||
const city = p.address?.city?.name || ''
|
||||
return [province, city].filter(Boolean).join('، ')
|
||||
}
|
||||
|
||||
const registeredAt = (p) => p.faRegisteredAt || formatJalaaliDate(p.registeredAt) || '—'
|
||||
|
||||
const onShowDetails = (participant) => {
|
||||
openModal('ExamParticipantDetailsModal', {
|
||||
examId: examId.value,
|
||||
participantId: participant.id,
|
||||
participant,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.exam-participants {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__exam {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
color: var(--color-prim-gray);
|
||||
margin: 0 0 0.75rem;
|
||||
}
|
||||
|
||||
&__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: rgba(255, 255, 255, 60%);
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&__user {
|
||||
flex: 1 1 40%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 2.75rem;
|
||||
height: 2.75rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
background: #f5f5f5;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__location {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
color: #989898;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__pill {
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
border-radius: 0.875rem;
|
||||
padding: 0.375rem 1rem;
|
||||
text-align: center;
|
||||
min-width: 9rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__pill-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__pill-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__details-btn {
|
||||
min-width: 5rem;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,347 @@
|
||||
<template>
|
||||
<div class="exam-form">
|
||||
<BoxedIconTitleBlock
|
||||
class="exam-form__heading"
|
||||
:title="isEditMode ? 'ویرایش آزمون' : 'طراحی سوال'"
|
||||
desc="در این قسمت شما میتوانید سوالات خود را ایجاد، حذف، ویرایش کنید"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="pencil" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<form class="exam-form__form" @submit.prevent="onSubmit">
|
||||
<div class="exam-form__card">
|
||||
<div class="exam-form__grid">
|
||||
<SelectField
|
||||
v-model="form.sessionId"
|
||||
name="sessionId"
|
||||
label="جلسه"
|
||||
:options="sessionOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchSessions"
|
||||
:error="errors.sessionId"
|
||||
/>
|
||||
<TextField
|
||||
v-model="form.title"
|
||||
name="title"
|
||||
label="عنوان آزمون"
|
||||
:error="errors.title"
|
||||
@blur="validateAt('title', form.title)"
|
||||
/>
|
||||
<TextField
|
||||
v-model="form.durationMinutes"
|
||||
name="durationMinutes"
|
||||
label="مدت آزمون"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
:error="errors.durationMinutes"
|
||||
@blur="validateAt('durationMinutes', form.durationMinutes)"
|
||||
/>
|
||||
<TextField
|
||||
v-model="form.passingScore"
|
||||
name="passingScore"
|
||||
label="حداقل نمره قبولی"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
:error="errors.passingScore"
|
||||
@blur="validateAt('passingScore', form.passingScore)"
|
||||
/>
|
||||
<DatePickerField
|
||||
v-model="form.endDate"
|
||||
name="endDate"
|
||||
label="تاریخ اعتبار"
|
||||
:error="errors.endDate"
|
||||
/>
|
||||
<div class="exam-form__toggle-cell">
|
||||
<ToggleSwitch v-model="form.randomize" label="به صورت رندوم باشد" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="exam-form__card">
|
||||
<TextareaField
|
||||
v-model="form.description"
|
||||
name="description"
|
||||
label="توضیحات آزمون"
|
||||
:row="4"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<ExamQuestionBuilder v-model="questions" :disabled="submitting" />
|
||||
<p v-if="questionError" class="exam-form__error">{{ questionError }}</p>
|
||||
</div>
|
||||
|
||||
<div class="exam-form__divider" />
|
||||
|
||||
<div class="exam-form__actions">
|
||||
<BaseButton
|
||||
variant="transparent"
|
||||
text="منصرف شدم"
|
||||
custom-class="exam-form__btn-cancel"
|
||||
@click="onCancel"
|
||||
>
|
||||
<template #prependIcon>
|
||||
<SvgIcon name="caret-right" :size="14" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
:text="isEditMode ? 'ذخیره تغییرات' : 'تایید اطلاعات'"
|
||||
:loading="submitting"
|
||||
custom-class="exam-form__btn-submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="20" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import ToggleSwitch from '@/components/form/ToggleSwitch.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import ExamQuestionBuilder from '@/features/admin/exams/components/ExamQuestionBuilder.vue'
|
||||
import useYup from '@/composables/useYup'
|
||||
import {
|
||||
adminExamsKeys,
|
||||
useAddAdminExamMutation,
|
||||
useAdminExamQuery,
|
||||
useUpdateAdminExamMutation,
|
||||
} from '@/services/query/admin-exams'
|
||||
import { useAdminSessionsListQuery } from '@/services/query/admin-sessions'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
import { examSchema } from '@/features/admin/exams/schema'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const examId = computed(() => (route.params.id ? Number(route.params.id) : null))
|
||||
const isEditMode = computed(() => !!examId.value)
|
||||
|
||||
const form = ref({
|
||||
title: '',
|
||||
sessionId: '',
|
||||
endDate: '',
|
||||
durationMinutes: '',
|
||||
passingScore: '',
|
||||
randomize: true,
|
||||
description: '',
|
||||
})
|
||||
|
||||
const createId = (prefix) => `${prefix}-${Date.now()}-${Math.random().toString(16).slice(2)}`
|
||||
|
||||
const blankQuestion = () => ({
|
||||
id: createId('question'),
|
||||
title: '',
|
||||
score: '',
|
||||
correctAnswerId: null,
|
||||
answers: [
|
||||
{ id: createId('answer'), title: '' },
|
||||
{ id: createId('answer'), title: '' },
|
||||
],
|
||||
})
|
||||
|
||||
const questions = ref([blankQuestion()])
|
||||
const questionError = ref('')
|
||||
|
||||
const schema = examSchema
|
||||
|
||||
const { validate, validateAt, errors } = useYup(schema)
|
||||
|
||||
const sessionSearch = ref('')
|
||||
const sessionFilters = computed(() => ({ title: sessionSearch.value }))
|
||||
const sessionPagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: sessionsResponse } = useAdminSessionsListQuery(sessionFilters, sessionPagination)
|
||||
const selectedSession = ref(null)
|
||||
const sessionOptions = computed(() => {
|
||||
const base = sessionsResponse.value?.data ?? []
|
||||
if (selectedSession.value && !base.some((s) => s.id === selectedSession.value.id)) {
|
||||
return [...base, selectedSession.value]
|
||||
}
|
||||
return base
|
||||
})
|
||||
|
||||
const searchSessions = useDebounce((q) => {
|
||||
sessionSearch.value = q || ''
|
||||
}, 400)
|
||||
|
||||
const { data: existingExam } = useAdminExamQuery(examId, {
|
||||
enabled: () => !!examId.value,
|
||||
})
|
||||
|
||||
const normalizeQuestions = (raw = []) => {
|
||||
if (!Array.isArray(raw) || raw.length === 0) return [blankQuestion()]
|
||||
return raw.map((q, qIdx) => {
|
||||
const answersSrc = q.answers || q.options || q.choices || []
|
||||
const answers = (Array.isArray(answersSrc) ? answersSrc : []).map((a, aIdx) => ({
|
||||
id: a?.id || createId(`answer-${qIdx}-${aIdx}`),
|
||||
title: typeof a === 'string' ? a : a?.title || a?.text || a?.label || '',
|
||||
}))
|
||||
return {
|
||||
id: q.id || createId(`question-${qIdx}`),
|
||||
title: q.title || q.question || q.text || '',
|
||||
score: q.score ?? q.barom ?? '',
|
||||
correctAnswerId: q.correctAnswerId || q.correctOptionId || q.correctAnswer?.id || null,
|
||||
answers: answers.length > 0 ? answers : blankQuestion().answers,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
watch(existingExam, (exam) => {
|
||||
if (!exam) return
|
||||
if (exam.session) selectedSession.value = exam.session
|
||||
form.value = {
|
||||
title: exam.title || '',
|
||||
sessionId: exam.session?.id || exam.sessionId || '',
|
||||
endDate: exam.endDate || '',
|
||||
durationMinutes: exam.durationMinutes ?? '',
|
||||
passingScore: exam.passingScore ?? '',
|
||||
randomize: exam.randomize ?? true,
|
||||
description: exam.description || '',
|
||||
}
|
||||
questions.value = normalizeQuestions(exam.questions)
|
||||
})
|
||||
|
||||
const validateQuestionList = () => {
|
||||
const list = questions.value
|
||||
if (list.some((q) => !String(q.title || '').trim() || !String(q.score || '').trim())) {
|
||||
questionError.value = 'لطفا متن سوال و بارم هر سوال را وارد کنید.'
|
||||
return null
|
||||
}
|
||||
if (list.some((q) => q.answers.filter((a) => a.title?.trim()).length < 2)) {
|
||||
questionError.value = 'برای هر سوال حداقل دو گزینه وارد کنید.'
|
||||
return null
|
||||
}
|
||||
if (
|
||||
list.some((q) => {
|
||||
if (!q.correctAnswerId) return true
|
||||
return !q.answers.some((a) => String(a.id) === String(q.correctAnswerId) && a.title?.trim())
|
||||
})
|
||||
) {
|
||||
questionError.value = 'گزینه صحیح هر سوال را از گزینههای موجود انتخاب کنید.'
|
||||
return null
|
||||
}
|
||||
questionError.value = ''
|
||||
return list.map((q) => ({
|
||||
id: q.id,
|
||||
title: q.title.trim(),
|
||||
score: q.score,
|
||||
correctAnswerId: q.correctAnswerId,
|
||||
answers: q.answers.filter((a) => a.title?.trim()).map((a) => ({ id: a.id, title: a.title })),
|
||||
}))
|
||||
}
|
||||
|
||||
const addMutation = useAddAdminExamMutation()
|
||||
const updateMutation = useUpdateAdminExamMutation()
|
||||
|
||||
const submitting = computed(() => addMutation.isPending.value || updateMutation.isPending.value)
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
const cleanQuestions = validateQuestionList()
|
||||
if (!isValid || !cleanQuestions) return
|
||||
const finalPayload = {
|
||||
...payload,
|
||||
questions: cleanQuestions,
|
||||
questionsCount: cleanQuestions.length,
|
||||
}
|
||||
if (isEditMode.value) {
|
||||
await updateMutation.mutateAsync({ id: examId.value, payload: finalPayload })
|
||||
} else {
|
||||
await addMutation.mutateAsync(finalPayload)
|
||||
}
|
||||
await queryClient.invalidateQueries({ queryKey: adminExamsKeys.all })
|
||||
router.push({ name: 'admin-exams' })
|
||||
}
|
||||
|
||||
const onCancel = () => router.push({ name: 'admin-exams' })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.exam-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
&__card {
|
||||
background: rgba(255, 255, 255, 60%);
|
||||
border-radius: 1.5rem;
|
||||
padding: 1rem;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 2.5%);
|
||||
}
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: repeat(6, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__toggle-cell {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
min-height: 4.25rem;
|
||||
}
|
||||
|
||||
&__error {
|
||||
margin-top: 0.5rem;
|
||||
padding-inline: 0.5rem;
|
||||
color: var(--color-error);
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
&__btn-submit {
|
||||
min-width: 13rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,152 @@
|
||||
<template>
|
||||
<div class="exams-page">
|
||||
<BoxedIconTitleBlock
|
||||
class="exams-page__heading"
|
||||
title="مدیریت آزمونها"
|
||||
desc="در این قسمت میتوانید آزمونهای خود را مدیریت کنید"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="pencil" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<ExamsFilters v-model="filters" @apply="onFilterApply" @reset="onFilterReset" />
|
||||
|
||||
<div class="exams-page__list-header">
|
||||
<SimpleTitleIconBlock title="لیست همه آزمونها" class="exams-page__list-title">
|
||||
<template #header-icon>
|
||||
<SvgIcon name="list-bullets" :size="16" color="#bcbcbc" />
|
||||
</template>
|
||||
</SimpleTitleIconBlock>
|
||||
<BaseButton text="افزودن آزمون جدید" custom-class="exams-page__add-btn" @click="onAdd">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="plus" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="6" :cols-per-row="1" />
|
||||
<div v-else-if="exams.length > 0">
|
||||
<ExamItem
|
||||
v-for="exam in exams"
|
||||
:key="exam.id"
|
||||
:exam="exam"
|
||||
@edit="onEdit"
|
||||
@delete="onAskDelete"
|
||||
@show-details="onShowDetails"
|
||||
@show-participants="onShowParticipants"
|
||||
/>
|
||||
</div>
|
||||
<NoItems v-else title="متاسفیم" desc="آزمونی برای نمایش وجود ندارد." />
|
||||
|
||||
<PaginationBlock :pagination="paginationMeta" @update:page="setPage" />
|
||||
|
||||
<ExamParticipantsModal v-if="isModal('ExamParticipantsModal')" />
|
||||
<ExamParticipantDetailsModal v-if="isModal('ExamParticipantDetailsModal')" />
|
||||
<ExamDetailsModal v-if="isModal('ExamDetailsModal')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import ExamsFilters from '@/features/admin/exams/components/ExamsFilters.vue'
|
||||
import ExamItem from '@/features/admin/exams/components/ExamItem.vue'
|
||||
import ExamParticipantsModal from '@/features/admin/exams/components/modals/ExamParticipantsModal.vue'
|
||||
import ExamParticipantDetailsModal from '@/features/admin/exams/components/modals/ExamParticipantDetailsModal.vue'
|
||||
import ExamDetailsModal from '@/features/admin/exams/components/modals/ExamDetailsModal.vue'
|
||||
import {
|
||||
adminExamsKeys,
|
||||
useAdminExamsListQuery,
|
||||
useDeleteAdminExamMutation,
|
||||
} from '@/services/query/admin-exams'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import useModal from '@/composables/useModal'
|
||||
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
const { openModal, isModal } = useModal()
|
||||
|
||||
const filters = ref({ title: '', courseTemplateId: '', fromDate: '', toDate: '' })
|
||||
const { pagination, setPage, reset: resetPagination } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = useAdminExamsListQuery(filters, pagination, {
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
const exams = computed(() => data.value?.data ?? [])
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const onFilterApply = () => resetPagination()
|
||||
const onFilterReset = () => resetPagination()
|
||||
|
||||
const onAdd = () => {
|
||||
router.push({ name: 'admin-add-exam' }).catch(() => {})
|
||||
}
|
||||
|
||||
const onEdit = (exam) => {
|
||||
router.push({ name: 'admin-edit-exam', params: { id: exam.id } }).catch(() => {})
|
||||
}
|
||||
|
||||
const onShowDetails = (exam) => {
|
||||
openModal('ExamDetailsModal', { id: exam.id })
|
||||
}
|
||||
|
||||
const onShowParticipants = (exam) => {
|
||||
openModal('ExamParticipantsModal', { id: exam.id, title: exam.title })
|
||||
}
|
||||
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminExamsKeys.all })
|
||||
|
||||
const deleteMutation = useDeleteAdminExamMutation()
|
||||
|
||||
const onAskDelete = (exam) => {
|
||||
openModal('ConfirmModal', {
|
||||
title: `حذف ${exam.title}`,
|
||||
message: `بعد از حذف امکان بازگشت وجود ندارد، آیا مطمئن هستید که میخواهید <strong>${exam.title}</strong> را حذف کنید؟`,
|
||||
onConfirm: () => deleteMutation.mutate(exam.id, { onSuccess: invalidate }),
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.exams-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__list-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
margin-bottom: 0.375rem;
|
||||
}
|
||||
|
||||
&__list-title {
|
||||
flex: 1;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&__add-btn {
|
||||
min-width: fit-content;
|
||||
padding: 0 1.25rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,10 @@
|
||||
import { number, object, string } from 'yup'
|
||||
|
||||
export const examSchema = object().shape({
|
||||
title: string().required().min(3),
|
||||
sessionId: string().required(),
|
||||
endDate: string().required(),
|
||||
durationMinutes: number().typeError('مدت زمان باید عدد باشد').required(),
|
||||
passingScore: number().typeError('حد نصاب قبولی باید عدد باشد').required(),
|
||||
description: string().nullable().notRequired(),
|
||||
})
|
||||
@@ -0,0 +1,220 @@
|
||||
<template>
|
||||
<div class="ticket-item">
|
||||
<div class="ticket-item__user">
|
||||
<div v-if="ticket.user?.avatarUrl" class="ticket-item__avatar">
|
||||
<img :src="ticket.user.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__title">{{ ticket.title || '—' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ticket-item__meta">
|
||||
<span
|
||||
class="ticket-item__status"
|
||||
:class="`ticket-item__status--${ticket.status || 'pending'}`"
|
||||
>
|
||||
{{ statusLabel }}
|
||||
</span>
|
||||
<div class="ticket-item__pill">
|
||||
<span class="ticket-item__pill-label">تاریخ ثبت:</span>
|
||||
<span class="ticket-item__pill-value">{{ createdAt }}</span>
|
||||
</div>
|
||||
<div v-if="createdTime" class="ticket-item__pill">
|
||||
<span class="ticket-item__pill-label">ساعت:</span>
|
||||
<span class="ticket-item__pill-value">{{ createdTime }}</span>
|
||||
</div>
|
||||
</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 BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { TICKET_STATUS } from '@/enums'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
const props = defineProps({
|
||||
ticket: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['show-details'])
|
||||
|
||||
const userName = computed(() => {
|
||||
const u = props.ticket.user
|
||||
if (!u) return '—'
|
||||
return `${u.firstName || ''} ${u.lastName || ''}`.trim() || u.fullName || '—'
|
||||
})
|
||||
|
||||
const statusLabel = computed(
|
||||
() => props.ticket.statusLabel || TICKET_STATUS[props.ticket.status] || '—'
|
||||
)
|
||||
|
||||
const createdAt = computed(
|
||||
() => props.ticket.faCreatedAt || formatJalaaliDate(props.ticket.createdAt) || '—'
|
||||
)
|
||||
|
||||
const createdTime = computed(() => props.ticket.faCreatedTime || '')
|
||||
</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 33%;
|
||||
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;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 300;
|
||||
color: #8f8f8f;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 41%;
|
||||
}
|
||||
|
||||
&__status {
|
||||
padding: 0.25rem 0.875rem;
|
||||
border-radius: 0.875rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
|
||||
&--pending {
|
||||
background: rgba(204, 154, 40, 8%);
|
||||
color: #cc6f00;
|
||||
}
|
||||
|
||||
&--answered {
|
||||
background: rgba(0, 112, 116, 8%);
|
||||
color: #007074;
|
||||
}
|
||||
|
||||
&--closed {
|
||||
background: rgba(104, 104, 104, 8%);
|
||||
color: #686868;
|
||||
}
|
||||
}
|
||||
|
||||
&__pill {
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
padding: 0.25rem 1rem;
|
||||
border-radius: 0.875rem;
|
||||
line-height: 1.5;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__pill-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 300;
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__pill-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 500;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__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: 8rem;
|
||||
padding: 0 0.875rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<form class="tickets-filters" @submit.prevent="onSubmit">
|
||||
<div class="tickets-filters__grid">
|
||||
<TextField v-model="form.userName" name="userName" label="نام کاربر">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="user" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.status"
|
||||
name="status"
|
||||
label="وضعیت تیکت"
|
||||
:options="statusOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
/>
|
||||
<DatePickerField v-model="form.fromDate" name="fromDate" label="از تاریخ" :max="todayIso" />
|
||||
<DatePickerField v-model="form.toDate" name="toDate" label="تا تاریخ" :max="todayIso" />
|
||||
</div>
|
||||
|
||||
<div class="tickets-filters__actions">
|
||||
<CircleButton
|
||||
v-if="hasFilters"
|
||||
tooltip="حذف فیلتر"
|
||||
bg-color="transparent"
|
||||
size="2.5rem"
|
||||
type="button"
|
||||
@click="onReset"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="اعمال فیلتر"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
type="submit"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="funnel" :size="20" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { TICKET_STATUS } from '@/enums'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: () => ({ userName: '', status: '', fromDate: '', toDate: '' }),
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'apply', 'reset'])
|
||||
|
||||
const emptyForm = () => ({ userName: '', status: '', fromDate: '', toDate: '' })
|
||||
const form = ref({ ...emptyForm(), ...props.modelValue })
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(next) => {
|
||||
form.value = { ...emptyForm(), ...next }
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const todayIso = new Date().toISOString()
|
||||
|
||||
const statusOptions = Object.entries(TICKET_STATUS).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
|
||||
const hasFilters = computed(() =>
|
||||
Object.values(form.value).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
)
|
||||
|
||||
const onSubmit = () => {
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('apply', { ...form.value })
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
form.value = emptyForm()
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tickets-filters {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
|
||||
&__grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding-top: 1.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,512 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="64rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<div class="ticket-details">
|
||||
<LineTitleBlock title="جزئیات تیکت" title-en="Ticket Details" />
|
||||
|
||||
<div v-if="ticket" class="ticket-details__date">
|
||||
<span>{{ ticketDate }}</span>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading && !ticket" :rows="3" :cols-per-row="1" />
|
||||
<div v-else-if="messages.length > 0" class="ticket-details__thread" ref="thread">
|
||||
<div
|
||||
v-for="message in messages"
|
||||
:key="message.id"
|
||||
class="ticket-details__row"
|
||||
:class="`ticket-details__row--${senderClass(message)}`"
|
||||
>
|
||||
<div class="ticket-details__bubble">
|
||||
<p class="ticket-details__text">{{ message.text }}</p>
|
||||
<span class="ticket-details__time">{{ messageTime(message) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<NoItems v-else title="پیامی نیست" desc="هنوز پیامی در این تیکت ثبت نشده است." />
|
||||
|
||||
<div class="ticket-details__divider" />
|
||||
|
||||
<div v-if="attachment" class="ticket-details__attachment">
|
||||
<SvgIcon name="file" :size="16" color="var(--color-prim-gray)" />
|
||||
<span class="ticket-details__attachment-name">{{ attachment.name }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="ticket-details__attachment-remove"
|
||||
aria-label="حذف فایل"
|
||||
@click="removeAttachment"
|
||||
>
|
||||
<SvgIcon name="close" :size="14" color="var(--color-error)" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form class="ticket-details__compose" @submit.prevent="onSend">
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="!canSend"
|
||||
class="ticket-details__send"
|
||||
aria-label="ارسال"
|
||||
>
|
||||
<SvgIcon name="paper-plane-right" :size="22" color="var(--color-primary)" />
|
||||
</button>
|
||||
<input
|
||||
v-model="text"
|
||||
type="text"
|
||||
placeholder="ارسال پیام"
|
||||
class="ticket-details__input"
|
||||
/>
|
||||
<div class="ticket-details__compose-actions">
|
||||
<button
|
||||
ref="emojiButton"
|
||||
type="button"
|
||||
class="ticket-details__compose-btn"
|
||||
:class="{ 'ticket-details__compose-btn--active': emojiOpen }"
|
||||
aria-label="ایموجی"
|
||||
@click="toggleEmoji"
|
||||
>
|
||||
<SvgIcon name="mood" :size="30" color="currentColor" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="ticket-details__compose-btn"
|
||||
aria-label="پیوست فایل"
|
||||
@click="triggerFilePicker"
|
||||
>
|
||||
<SvgIcon name="attach-file" :size="30" color="currentColor" />
|
||||
</button>
|
||||
<input
|
||||
ref="fileInput"
|
||||
type="file"
|
||||
class="ticket-details__file-input"
|
||||
@change="onFileSelected"
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
|
||||
<Teleport to="body">
|
||||
<Transition name="emoji-pop">
|
||||
<div v-if="emojiOpen" ref="emojiPanel" class="ticket-emoji-panel" :style="emojiStyle">
|
||||
<button
|
||||
v-for="emoji in EMOJIS"
|
||||
:key="emoji"
|
||||
type="button"
|
||||
class="ticket-emoji-panel__emoji"
|
||||
@click="insertEmoji(emoji)"
|
||||
>
|
||||
{{ emoji }}
|
||||
</button>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import {
|
||||
autoUpdate,
|
||||
computePosition,
|
||||
flip,
|
||||
offset as offsetMiddleware,
|
||||
shift,
|
||||
} from '@floating-ui/dom'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import {
|
||||
adminTicketsKeys,
|
||||
useAdminTicketQuery,
|
||||
useSendAdminTicketMessageMutation,
|
||||
} from '@/services/query/admin-tickets'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||
|
||||
defineOptions({ name: 'TicketDetailsModal' })
|
||||
|
||||
const EMOJIS = [
|
||||
'😀',
|
||||
'😂',
|
||||
'😍',
|
||||
'🤔',
|
||||
'👍',
|
||||
'👎',
|
||||
'🙏',
|
||||
'👏',
|
||||
'🎉',
|
||||
'🔥',
|
||||
'✨',
|
||||
'⭐',
|
||||
'✅',
|
||||
'❌',
|
||||
'❤️',
|
||||
'💔',
|
||||
'😊',
|
||||
'😎',
|
||||
'😢',
|
||||
'😡',
|
||||
'🤝',
|
||||
'👌',
|
||||
'💡',
|
||||
'📌',
|
||||
]
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('TicketDetailsModal')?.data ?? {})
|
||||
const ticketId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const { data: ticket, isLoading } = useAdminTicketQuery(ticketId, {
|
||||
enabled: () => !!ticketId.value,
|
||||
})
|
||||
|
||||
const messages = computed(() => ticket.value?.messages ?? [])
|
||||
|
||||
const ticketDate = computed(
|
||||
() => ticket.value?.faCreatedAt || formatJalaaliDate(ticket.value?.createdAt) || '—'
|
||||
)
|
||||
|
||||
const senderClass = (message) => (message.sender === 'admin' ? 'admin' : 'user')
|
||||
|
||||
const messageTime = (message) => message.time || message.faSentAt || message.sentAt || '—'
|
||||
|
||||
const text = ref('')
|
||||
const attachment = ref(null)
|
||||
const canSend = computed(() => text.value.trim().length > 0 || !!attachment.value)
|
||||
|
||||
const fileInput = ref(null)
|
||||
const triggerFilePicker = () => fileInput.value?.click()
|
||||
const onFileSelected = (event) => {
|
||||
const file = event.target?.files?.[0]
|
||||
if (file) attachment.value = file
|
||||
if (event.target) event.target.value = ''
|
||||
}
|
||||
const removeAttachment = () => {
|
||||
attachment.value = null
|
||||
}
|
||||
|
||||
const emojiOpen = ref(false)
|
||||
const emojiButton = ref(null)
|
||||
const emojiPanel = ref(null)
|
||||
const emojiStyle = ref({ position: 'fixed', top: '0', left: '0' })
|
||||
let emojiCleanup = null
|
||||
|
||||
const toggleEmoji = () => {
|
||||
emojiOpen.value = !emojiOpen.value
|
||||
}
|
||||
const insertEmoji = (emoji) => {
|
||||
text.value += emoji
|
||||
}
|
||||
|
||||
const mountEmoji = async () => {
|
||||
await nextTick()
|
||||
if (!emojiButton.value || !emojiPanel.value) return
|
||||
emojiCleanup = autoUpdate(emojiButton.value, emojiPanel.value, () => {
|
||||
computePosition(emojiButton.value, emojiPanel.value, {
|
||||
placement: 'top-end',
|
||||
strategy: 'fixed',
|
||||
middleware: [offsetMiddleware(8), flip(), shift({ padding: 8 })],
|
||||
}).then(({ x, y }) => {
|
||||
emojiStyle.value = { position: 'fixed', top: `${y}px`, left: `${x}px` }
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const unmountEmoji = () => {
|
||||
emojiCleanup?.()
|
||||
emojiCleanup = null
|
||||
}
|
||||
|
||||
watch(emojiOpen, (open) => {
|
||||
if (open) mountEmoji()
|
||||
else unmountEmoji()
|
||||
})
|
||||
|
||||
const onDocumentClick = (event) => {
|
||||
if (!emojiOpen.value) return
|
||||
if (emojiPanel.value?.contains(event.target)) return
|
||||
if (emojiButton.value?.contains(event.target)) return
|
||||
emojiOpen.value = false
|
||||
}
|
||||
document.addEventListener('mousedown', onDocumentClick)
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('mousedown', onDocumentClick)
|
||||
unmountEmoji()
|
||||
})
|
||||
|
||||
const sendMutation = useSendAdminTicketMessageMutation()
|
||||
|
||||
const onSend = async () => {
|
||||
if (!canSend.value || !ticketId.value) return
|
||||
const value = text.value.trim()
|
||||
const file = attachment.value
|
||||
text.value = ''
|
||||
attachment.value = null
|
||||
emojiOpen.value = false
|
||||
const payload = file ? objectToFormData({ text: value, attachment: file }) : { text: value }
|
||||
await sendMutation.mutateAsync({ id: ticketId.value, payload })
|
||||
await queryClient.invalidateQueries({ queryKey: adminTicketsKeys.all })
|
||||
}
|
||||
|
||||
const thread = ref(null)
|
||||
|
||||
watch(messages, async () => {
|
||||
await nextTick()
|
||||
if (thread.value) {
|
||||
thread.value.scrollTop = thread.value.scrollHeight
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.ticket-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: calc(100dvh - 8rem);
|
||||
min-height: 28rem;
|
||||
|
||||
&__date {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin: 0.5rem 0 0.875rem;
|
||||
}
|
||||
|
||||
&__date span {
|
||||
background: #f7f7f7;
|
||||
color: #9c9c9c;
|
||||
border-radius: 9999px;
|
||||
padding: 0.5rem 1.25rem;
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
&__thread {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
padding-block: 0.5rem 1rem;
|
||||
padding-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
|
||||
&--admin {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&--user {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
&__bubble {
|
||||
max-width: 72%;
|
||||
border-radius: 1rem;
|
||||
padding: 0.75rem 1.25rem;
|
||||
|
||||
.ticket-details__row--admin & {
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
border-end-start-radius: 0;
|
||||
}
|
||||
|
||||
.ticket-details__row--user & {
|
||||
background: #f8f8f8;
|
||||
color: #5d5d5d;
|
||||
border-end-end-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&__text {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.7;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__time {
|
||||
display: block;
|
||||
margin-top: 0.375rem;
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.7rem;
|
||||
|
||||
.ticket-details__row--admin & {
|
||||
color: rgba(255, 255, 255, 80%);
|
||||
}
|
||||
|
||||
.ticket-details__row--user & {
|
||||
color: #b1b1b1;
|
||||
}
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 0.75rem;
|
||||
}
|
||||
|
||||
&__compose {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
&__send {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: 9999px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--color-primary);
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.2s ease;
|
||||
|
||||
&:hover:enabled {
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
&__input {
|
||||
flex: 1;
|
||||
height: 2.5rem;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 1.5rem;
|
||||
padding: 0 1rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
color: #4b4b4b;
|
||||
outline: none;
|
||||
|
||||
&:focus {
|
||||
border-color: var(--color-thd-gray);
|
||||
}
|
||||
}
|
||||
|
||||
&__compose-actions {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__compose-btn {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: 9999px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: #d1d1d1;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.15s ease, color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 0, 0, 4%);
|
||||
color: var(--color-prim-gray);
|
||||
}
|
||||
|
||||
&--active {
|
||||
color: var(--color-primary);
|
||||
background: rgba(0, 0, 0, 4%);
|
||||
}
|
||||
}
|
||||
|
||||
&__file-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&__attachment {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
padding: 0.375rem 0.625rem;
|
||||
margin-bottom: 0.5rem;
|
||||
background: #f7f7f7;
|
||||
border-radius: 9999px;
|
||||
align-self: flex-start;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #4b4b4b;
|
||||
max-width: 18rem;
|
||||
}
|
||||
|
||||
&__attachment-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__attachment-remove {
|
||||
border: none;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.ticket-emoji-panel {
|
||||
width: 17rem;
|
||||
background: #fff;
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 10px 25px -8px rgba(0, 0, 0, 12%), 0 4px 10px -4px rgba(0, 0, 0, 8%);
|
||||
padding: 0.5rem;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(8, 1fr);
|
||||
gap: 0.125rem;
|
||||
z-index: 1000;
|
||||
|
||||
&__emoji {
|
||||
height: 2rem;
|
||||
border: none;
|
||||
background: transparent;
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
font-size: 1.125rem;
|
||||
line-height: 1;
|
||||
|
||||
&:hover {
|
||||
background: #f3f4f6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.emoji-pop-enter-active,
|
||||
.emoji-pop-leave-active {
|
||||
transition: opacity 0.12s ease, transform 0.12s ease;
|
||||
}
|
||||
|
||||
.emoji-pop-enter-from,
|
||||
.emoji-pop-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(6px);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,92 @@
|
||||
<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>
|
||||
|
||||
<TicketsFilters v-model="filters" @apply="onFilterApply" @reset="onFilterReset" />
|
||||
|
||||
<SimpleTitleIconBlock title="لیست تمام تیکتها" class="tickets-page__list-title">
|
||||
<template #header-icon>
|
||||
<SvgIcon name="list-bullets" :size="16" color="#bcbcbc" />
|
||||
</template>
|
||||
</SimpleTitleIconBlock>
|
||||
|
||||
<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')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import TicketsFilters from '@/features/admin/messages/components/TicketsFilters.vue'
|
||||
import TicketItem from '@/features/admin/messages/components/TicketItem.vue'
|
||||
import TicketDetailsModal from '@/features/admin/messages/components/modals/TicketDetailsModal.vue'
|
||||
import { useAdminTicketsListQuery } from '@/services/query/admin-tickets'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import useModal from '@/composables/useModal'
|
||||
|
||||
const { openModal, isModal } = useModal()
|
||||
|
||||
const filters = ref({ userName: '', status: '', fromDate: '', toDate: '' })
|
||||
const { pagination, setPage, reset: resetPagination } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = useAdminTicketsListQuery(filters, pagination, {
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
const tickets = computed(() => data.value?.data ?? [])
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const onFilterApply = () => resetPagination()
|
||||
const onFilterReset = () => resetPagination()
|
||||
|
||||
const onShowDetails = (ticket) => {
|
||||
openModal('TicketDetailsModal', { id: ticket.id })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tickets-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__list-title {
|
||||
margin-bottom: 0.375rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<div class="admin-dashboard">
|
||||
<header class="admin-dashboard__heading">
|
||||
<p class="admin-dashboard__title">پنل مدیریت</p>
|
||||
<p class="admin-dashboard__subtitle">آخرین اطلاعات موسسه شما</p>
|
||||
</header>
|
||||
|
||||
<p class="admin-dashboard__placeholder">این بخش در مراحل بعدی توسعه مییابد.</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup></script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.admin-dashboard {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
|
||||
&__heading {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 500;
|
||||
font-size: 1.25rem;
|
||||
margin: 0;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__subtitle {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
color: var(--color-prim-gray);
|
||||
margin: 0.25rem 0 0;
|
||||
}
|
||||
|
||||
&__placeholder {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
color: var(--color-prim-gray);
|
||||
text-align: center;
|
||||
padding: 3rem 0;
|
||||
background: #fff;
|
||||
border-radius: 1rem;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,128 @@
|
||||
export default [
|
||||
{
|
||||
path: '/main-dashboard',
|
||||
name: 'admin-dashboard',
|
||||
component: () => import('@/features/admin/pages/AdminDashboardPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'پیشخوان' },
|
||||
},
|
||||
{
|
||||
path: '/users',
|
||||
name: 'admin-users',
|
||||
component: () => import('@/features/admin/users/pages/UsersListPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'مدیریت کاربران' },
|
||||
},
|
||||
{
|
||||
path: '/add-user',
|
||||
name: 'admin-add-user',
|
||||
component: () => import('@/features/admin/users/pages/UserFormPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'افزودن کاربر جدید' },
|
||||
},
|
||||
{
|
||||
path: '/edit-user/:id',
|
||||
name: 'admin-edit-user',
|
||||
component: () => import('@/features/admin/users/pages/UserFormPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'ویرایش کاربر' },
|
||||
},
|
||||
{
|
||||
path: '/user-verification',
|
||||
name: 'admin-user-verification',
|
||||
component: () => import('@/features/admin/users/pages/UserVerificationPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'تایید هویت کاربران' },
|
||||
},
|
||||
{
|
||||
path: '/terms',
|
||||
name: 'admin-terms',
|
||||
component: () => import('@/features/admin/terms/pages/TermsListPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'مدیریت ترم' },
|
||||
},
|
||||
{
|
||||
path: '/add-term',
|
||||
name: 'admin-add-term',
|
||||
component: () => import('@/features/admin/terms/pages/TermFormPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'افزودن ترم جدید' },
|
||||
},
|
||||
{
|
||||
path: '/edit-term/:id',
|
||||
name: 'admin-edit-term',
|
||||
component: () => import('@/features/admin/terms/pages/TermFormPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'ویرایش ترم' },
|
||||
},
|
||||
{
|
||||
path: '/courses',
|
||||
name: 'admin-courses',
|
||||
component: () => import('@/features/admin/courses/pages/CoursesListPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'مدیریت دوره' },
|
||||
},
|
||||
{
|
||||
path: '/add-course-template',
|
||||
name: 'admin-add-course-template',
|
||||
component: () => import('@/features/admin/courses/pages/CourseTemplateFormPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'افزودن دوره الگو' },
|
||||
},
|
||||
{
|
||||
path: '/edit-course-template/:id',
|
||||
name: 'admin-edit-course-template',
|
||||
component: () => import('@/features/admin/courses/pages/CourseTemplateFormPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'ویرایش دوره الگو' },
|
||||
},
|
||||
{
|
||||
path: '/sessions',
|
||||
name: 'admin-sessions',
|
||||
component: () => import('@/features/admin/sessions/pages/SessionsListPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'مدیریت جلسات' },
|
||||
},
|
||||
{
|
||||
path: '/add-session',
|
||||
name: 'admin-add-session',
|
||||
component: () => import('@/features/admin/sessions/pages/SessionFormPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'افزودن جلسه جدید' },
|
||||
},
|
||||
{
|
||||
path: '/edit-session/:id',
|
||||
name: 'admin-edit-session',
|
||||
component: () => import('@/features/admin/sessions/pages/SessionFormPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'ویرایش جلسه' },
|
||||
},
|
||||
{
|
||||
path: '/exams',
|
||||
name: 'admin-exams',
|
||||
component: () => import('@/features/admin/exams/pages/ExamsListPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'مدیریت آزمونها' },
|
||||
},
|
||||
{
|
||||
path: '/add-exam',
|
||||
name: 'admin-add-exam',
|
||||
component: () => import('@/features/admin/exams/pages/ExamFormPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'افزودن آزمون جدید' },
|
||||
},
|
||||
{
|
||||
path: '/edit-exam/:id',
|
||||
name: 'admin-edit-exam',
|
||||
component: () => import('@/features/admin/exams/pages/ExamFormPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'ویرایش آزمون' },
|
||||
},
|
||||
{
|
||||
path: '/assignments',
|
||||
name: 'admin-assignments',
|
||||
component: () => import('@/features/admin/assignments/pages/AssignmentsListPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'مدیریت تکالیف' },
|
||||
},
|
||||
{
|
||||
path: '/messages',
|
||||
name: 'admin-messages',
|
||||
component: () => import('@/features/admin/messages/pages/TicketsListPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'مدیریت پیامها' },
|
||||
},
|
||||
{
|
||||
path: '/services',
|
||||
name: 'admin-services',
|
||||
component: () => import('@/features/admin/services/pages/ServicesListPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'مدیریت خدمات' },
|
||||
},
|
||||
{
|
||||
path: '/consultations',
|
||||
name: 'admin-consultations',
|
||||
component: () => import('@/features/admin/consultations/pages/ConsultationsListPage.vue'),
|
||||
meta: { layout: 'admin', role: 'admin', title: 'مدیریت مشاوره' },
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,296 @@
|
||||
<template>
|
||||
<div class="service-item">
|
||||
<div class="service-item__user">
|
||||
<div v-if="service.user?.avatarUrl" class="service-item__avatar">
|
||||
<img :src="service.user.avatarUrl" :alt="userName" />
|
||||
</div>
|
||||
<div v-else class="service-item__avatar service-item__avatar--placeholder">
|
||||
<SvgIcon name="user" :size="24" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="service-item__info">
|
||||
<p class="service-item__name">{{ userName }}</p>
|
||||
<p class="service-item__request-id">
|
||||
<span class="service-item__request-id-label">شماره درخواست:</span>
|
||||
<span class="service-item__request-id-value">{{ service.requestId || '—' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="service-item__meta">
|
||||
<div class="service-item__pill">
|
||||
<SvgIcon name="file" :size="14" color="#535353" />
|
||||
<span class="service-item__pill-label">نوع خدمت :</span>
|
||||
<span class="service-item__pill-value">{{ typeLabel }}</span>
|
||||
</div>
|
||||
<div class="service-item__pill">
|
||||
<SvgIcon name="calendar" :size="14" color="#535353" />
|
||||
<span class="service-item__pill-label">تاریخ پیام :</span>
|
||||
<span class="service-item__pill-value">{{ createdAt }}</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="service-item__status"
|
||||
:class="`service-item__status--${service.status || 'pending'}`"
|
||||
@click="onStatusClick"
|
||||
>
|
||||
<span class="service-item__status-dot" />
|
||||
<span>{{ statusLabel }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="service-item__actions">
|
||||
<BaseButton
|
||||
text="جزئیات درخواست"
|
||||
custom-class="service-item__details-btn"
|
||||
@click="emit('show-details', service)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<DropdownMenu
|
||||
v-model="menuOpen"
|
||||
:reference="menuTrigger"
|
||||
:items="menuItems"
|
||||
placement="bottom-end"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import DropdownMenu from '@/components/DropdownMenu.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { SERVICE_STATUS, SERVICE_TYPE } from '@/enums'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
const props = defineProps({
|
||||
service: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['show-details', 'change-status'])
|
||||
|
||||
const userName = computed(() => {
|
||||
const u = props.service.user
|
||||
if (!u) return '—'
|
||||
return `${u.firstName || ''} ${u.lastName || ''}`.trim() || u.fullName || '—'
|
||||
})
|
||||
|
||||
const typeLabel = computed(() => props.service.typeLabel || SERVICE_TYPE[props.service.type] || '—')
|
||||
|
||||
const statusLabel = computed(
|
||||
() => props.service.statusLabel || SERVICE_STATUS[props.service.status] || '—'
|
||||
)
|
||||
|
||||
const createdAt = computed(() => {
|
||||
if (props.service.faCreatedAt) {
|
||||
return props.service.faCreatedTime
|
||||
? `${props.service.faCreatedTime}، ${props.service.faCreatedAt}`
|
||||
: props.service.faCreatedAt
|
||||
}
|
||||
return formatJalaaliDate(props.service.createdAt) || '—'
|
||||
})
|
||||
|
||||
const menuOpen = ref(false)
|
||||
const menuTrigger = ref(null)
|
||||
|
||||
const onStatusClick = (event) => {
|
||||
const trigger = event.currentTarget
|
||||
if (menuOpen.value && menuTrigger.value === trigger) {
|
||||
menuOpen.value = false
|
||||
return
|
||||
}
|
||||
menuTrigger.value = trigger
|
||||
menuOpen.value = true
|
||||
}
|
||||
|
||||
const menuItems = computed(() =>
|
||||
Object.entries(SERVICE_STATUS)
|
||||
.filter(([value]) => value !== props.service.status)
|
||||
.map(([value, label]) => ({
|
||||
key: `status-${value}`,
|
||||
label: `تغییر به ${label}`,
|
||||
icon: 'arrows-clockwise',
|
||||
onClick: () => emit('change-status', { service: props.service, status: value }),
|
||||
}))
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.service-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%;
|
||||
}
|
||||
|
||||
&__pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
padding: 0.375rem 0.875rem;
|
||||
border-radius: 0.875rem;
|
||||
line-height: 1.5;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__pill-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 300;
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__pill-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 500;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
padding: 0.375rem 0.875rem;
|
||||
border-radius: 0.875rem;
|
||||
border: none;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
transition: filter 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
filter: brightness(0.96);
|
||||
}
|
||||
|
||||
&--approved {
|
||||
background: rgba(0, 153, 76, 10%);
|
||||
color: #00994c;
|
||||
}
|
||||
|
||||
&--pending {
|
||||
background: rgba(204, 154, 40, 10%);
|
||||
color: #cc6f00;
|
||||
}
|
||||
|
||||
&--in_progress {
|
||||
background: rgba(0, 112, 116, 10%);
|
||||
color: #007074;
|
||||
}
|
||||
|
||||
&--completed {
|
||||
background: rgba(104, 104, 104, 10%);
|
||||
color: #686868;
|
||||
}
|
||||
}
|
||||
|
||||
&__status-dot {
|
||||
width: 0.45rem;
|
||||
height: 0.45rem;
|
||||
border-radius: 9999px;
|
||||
background: currentcolor;
|
||||
}
|
||||
|
||||
&__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,125 @@
|
||||
<template>
|
||||
<form class="services-filters" @submit.prevent="onSubmit">
|
||||
<div class="services-filters__grid">
|
||||
<TextField v-model="form.userName" name="userName" label="جستجو اسم کاربر">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="user" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.status"
|
||||
name="status"
|
||||
label="دسته بندی"
|
||||
:options="statusOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
/>
|
||||
<DatePickerField v-model="form.fromDate" name="fromDate" label="از تاریخ" :max="todayIso" />
|
||||
<DatePickerField v-model="form.toDate" name="toDate" label="تا تاریخ" :max="todayIso" />
|
||||
</div>
|
||||
|
||||
<div class="services-filters__actions">
|
||||
<CircleButton
|
||||
v-if="hasFilters"
|
||||
tooltip="حذف فیلتر"
|
||||
bg-color="transparent"
|
||||
size="2.5rem"
|
||||
type="button"
|
||||
@click="onReset"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="اعمال فیلتر"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
type="submit"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="funnel" :size="20" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { SERVICE_STATUS } from '@/enums'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: () => ({ userName: '', status: '', fromDate: '', toDate: '' }),
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'apply', 'reset'])
|
||||
|
||||
const emptyForm = () => ({ userName: '', status: '', fromDate: '', toDate: '' })
|
||||
const form = ref({ ...emptyForm(), ...props.modelValue })
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(next) => {
|
||||
form.value = { ...emptyForm(), ...next }
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const todayIso = new Date().toISOString()
|
||||
|
||||
const statusOptions = Object.entries(SERVICE_STATUS).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
|
||||
const hasFilters = computed(() =>
|
||||
Object.values(form.value).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
)
|
||||
|
||||
const onSubmit = () => {
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('apply', { ...form.value })
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
form.value = emptyForm()
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.services-filters {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
|
||||
&__grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding-top: 1.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,163 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="ارسال پیام"
|
||||
title-en="Send message"
|
||||
width="95%"
|
||||
max-width="58rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ close }">
|
||||
<form class="send-message" @submit.prevent="onSubmit(close)">
|
||||
<div class="send-message__row send-message__row--two">
|
||||
<SelectField
|
||||
v-model="form.category"
|
||||
name="category"
|
||||
label="دسته بندی"
|
||||
placeholder="انتخاب کنید"
|
||||
:options="categoryOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
/>
|
||||
<SelectField
|
||||
v-model="form.priority"
|
||||
name="priority"
|
||||
label="اولویت پیام"
|
||||
placeholder="انتخاب کنید"
|
||||
:options="priorityOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="send-message__row">
|
||||
<TextareaField
|
||||
v-model="form.description"
|
||||
name="description"
|
||||
label="توضیحات خود را وارد کنید"
|
||||
placeholder="لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است."
|
||||
:row="4"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="send-message__divider" />
|
||||
|
||||
<footer class="send-message__footer">
|
||||
<button type="button" class="send-message__cancel" @click="close">
|
||||
<span>منصرف شدم</span>
|
||||
<SvgIcon name="caret-down" :size="16" color="currentColor" />
|
||||
</button>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
text="ارسال"
|
||||
custom-class="send-message__submit"
|
||||
:disabled="!canSubmit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</footer>
|
||||
</form>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { toast } from 'vue3-toastify'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { SERVICE_STATUS } from '@/enums'
|
||||
|
||||
defineOptions({ name: 'SendMessageModal' })
|
||||
|
||||
const categoryOptions = Object.entries(SERVICE_STATUS).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
|
||||
const priorityOptions = [
|
||||
{ value: 'very_urgent', label: 'بسیار فوری' },
|
||||
{ value: 'urgent', label: 'فوری' },
|
||||
{ value: 'normal', label: 'عادی' },
|
||||
{ value: 'low', label: 'کم اهمیت' },
|
||||
]
|
||||
|
||||
const form = ref({
|
||||
category: '',
|
||||
priority: '',
|
||||
description: '',
|
||||
})
|
||||
|
||||
const canSubmit = computed(
|
||||
() => form.value.category && form.value.priority && form.value.description.trim().length > 0
|
||||
)
|
||||
|
||||
const onSubmit = (close) => {
|
||||
if (!canSubmit.value) return
|
||||
toast.success('پیام با موفقیت ارسال شد')
|
||||
close?.()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.send-message {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
text-align: start;
|
||||
padding-block: 0.5rem;
|
||||
|
||||
&__row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.75rem;
|
||||
|
||||
&--two {
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid #dddddd;
|
||||
margin-block: 0.5rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
&__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: 17rem;
|
||||
padding: 0 1.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="جزئیات خدمت"
|
||||
title-en="Service Detail"
|
||||
width="95%"
|
||||
max-width="64rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ data }">
|
||||
<div class="service-details">
|
||||
<div class="service-details__row service-details__row--two">
|
||||
<LineInfoBlock title="عنوان خدمت" :desc="serviceTitle(data)" />
|
||||
<LineInfoBlock title="نوع خدمت" :desc="serviceTypeLabel(data)" />
|
||||
</div>
|
||||
|
||||
<div class="service-details__row">
|
||||
<LineInfoBlock title="درخواست" :desc="requestText(data)" />
|
||||
</div>
|
||||
|
||||
<div class="service-details__divider" />
|
||||
|
||||
<footer class="service-details__footer">
|
||||
<BaseButton
|
||||
text="ارسال پیام"
|
||||
custom-class="service-details__send-btn"
|
||||
@click="onSendMessage(data)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { SERVICE_TYPE } from '@/enums'
|
||||
import useModal from '@/composables/useModal'
|
||||
|
||||
defineOptions({ name: 'ServiceDetailsModal' })
|
||||
|
||||
const { openModal } = useModal()
|
||||
|
||||
const serviceTitle = (data) => data?.title || data?.serviceTitle || '—'
|
||||
|
||||
const serviceTypeLabel = (data) => data?.typeLabel || SERVICE_TYPE[data?.type] || '—'
|
||||
|
||||
const requestText = (data) => data?.requestText || data?.description || '—'
|
||||
|
||||
const onSendMessage = (data) => {
|
||||
openModal('SendMessageModal', { service: data })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.service-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
text-align: start;
|
||||
padding-block: 0.5rem;
|
||||
|
||||
&__row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
&--two {
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid #dddddd;
|
||||
margin-block: 0.5rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
&__send-btn {
|
||||
min-width: 17rem;
|
||||
padding: 0 1.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<div class="services-page">
|
||||
<BoxedIconTitleBlock
|
||||
class="services-page__heading"
|
||||
title="مدیریت خدمات"
|
||||
desc="در این قسمت میتوانید خدمت های خواسته شده را مدیریت کنید"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="users-three" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<ServicesFilters v-model="filters" @apply="onFilterApply" @reset="onFilterReset" />
|
||||
|
||||
<SimpleTitleIconBlock title="لیست تمام خدمات خواسته شده" class="services-page__list-title">
|
||||
<template #header-icon>
|
||||
<SvgIcon name="list-bullets" :size="16" color="#bcbcbc" />
|
||||
</template>
|
||||
</SimpleTitleIconBlock>
|
||||
|
||||
<div v-if="services.length > 0">
|
||||
<ServiceItem
|
||||
v-for="service in services"
|
||||
:key="service.id"
|
||||
:service="service"
|
||||
@show-details="onShowDetails"
|
||||
@change-status="onChangeStatus"
|
||||
/>
|
||||
</div>
|
||||
<NoItems v-else title="متاسفیم" desc="درخواست خدمتی برای نمایش وجود ندارد." />
|
||||
|
||||
<ServiceDetailsModal v-if="isModal('ServiceDetailsModal')" />
|
||||
<SendMessageModal v-if="isModal('SendMessageModal')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import ServicesFilters from '@/features/admin/services/components/ServicesFilters.vue'
|
||||
import ServiceItem from '@/features/admin/services/components/ServiceItem.vue'
|
||||
import ServiceDetailsModal from '@/features/admin/services/components/modals/ServiceDetailsModal.vue'
|
||||
import SendMessageModal from '@/features/admin/services/components/modals/SendMessageModal.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
|
||||
const { openModal, isModal } = useModal()
|
||||
|
||||
const filters = ref({ userName: '', status: '', fromDate: '', toDate: '' })
|
||||
|
||||
const allServices = ref([
|
||||
{
|
||||
id: 1,
|
||||
requestId: '387',
|
||||
user: { firstName: 'علیرضا', lastName: 'محمدی' },
|
||||
title: 'گفتگو درباره وام',
|
||||
type: 'loan',
|
||||
status: 'approved',
|
||||
requestText:
|
||||
'من علاقهمند به دنیای تکنولوژی، طراحی رابط کاربری و توسعه نرمافزار هستم. در کنار کار حرفهای، به یادگیری موضوعات جدید، مطالعه و موسیقی هم علاقه دارم. هدفم ساختن محصولاتی است.',
|
||||
faCreatedAt: '1404/05/12',
|
||||
faCreatedTime: '13:54',
|
||||
},
|
||||
])
|
||||
|
||||
const services = computed(() => {
|
||||
const f = filters.value
|
||||
return allServices.value.filter((s) => {
|
||||
if (f.status && s.status !== f.status) return false
|
||||
if (f.userName) {
|
||||
const fullName = `${s.user?.firstName || ''} ${s.user?.lastName || ''}`.trim()
|
||||
if (!fullName.includes(f.userName)) return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
})
|
||||
|
||||
const onFilterApply = () => {}
|
||||
const onFilterReset = () => {}
|
||||
|
||||
const onShowDetails = (service) => {
|
||||
openModal('ServiceDetailsModal', service)
|
||||
}
|
||||
|
||||
const onChangeStatus = ({ service, status }) => {
|
||||
const idx = allServices.value.findIndex((s) => s.id === service.id)
|
||||
if (idx !== -1) allServices.value[idx] = { ...allServices.value[idx], status }
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.services-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__list-title {
|
||||
margin-bottom: 0.375rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,197 @@
|
||||
<template>
|
||||
<div class="session-item">
|
||||
<div class="session-item__main">
|
||||
<div v-if="session.image" class="session-item__image">
|
||||
<img :src="session.image" :alt="session.title" />
|
||||
</div>
|
||||
<div v-else class="session-item__image session-item__image--placeholder">
|
||||
<SvgIcon name="book" :size="22" color="#bcbcbc" />
|
||||
</div>
|
||||
<p class="session-item__title">{{ session.title }}</p>
|
||||
</div>
|
||||
|
||||
<div class="session-item__meta">
|
||||
<div class="session-item__pill">
|
||||
<span class="session-item__pill-label">متعلق به دوره:</span>
|
||||
<span class="session-item__pill-value">{{ session.courseTemplate?.title || '—' }}</span>
|
||||
</div>
|
||||
<div class="session-item__pill">
|
||||
<span class="session-item__pill-label">مدت جلسه:</span>
|
||||
<span class="session-item__pill-value">{{ session.durationMinutes ?? '—' }}</span>
|
||||
</div>
|
||||
<div class="session-item__pill">
|
||||
<span class="session-item__pill-label">نوع جلسه:</span>
|
||||
<span class="session-item__pill-value">{{ sessionTypeLabel }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="session-item__actions">
|
||||
<CircleButton
|
||||
v-if="hasUsedTerms"
|
||||
tooltip="لیست حضور و غیاب"
|
||||
bg-color="rgba(0, 112, 116, 0.08)"
|
||||
size="2.5rem"
|
||||
@click="emit('show-attendance', session)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="users" :size="18" color="#007074" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="حذف"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('delete', session)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="18" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="ویرایش"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('edit', session)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="pencil" :size="18" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<BaseButton
|
||||
text="جزئیات جلسه"
|
||||
custom-class="session-item__details-btn"
|
||||
@click="emit('show-details', session)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { SESSION_TYPE } from '@/enums'
|
||||
|
||||
const props = defineProps({
|
||||
session: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['edit', 'delete', 'show-details', 'show-attendance'])
|
||||
|
||||
const sessionTypeLabel = computed(
|
||||
() => props.session.sessionTypeFa || SESSION_TYPE[props.session.sessionType] || '—'
|
||||
)
|
||||
|
||||
const hasUsedTerms = computed(() => (props.session.usedInTerms?.length ?? 0) > 0)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.session-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;
|
||||
}
|
||||
|
||||
&__main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
flex: 1 1 25%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__image {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
min-width: 3rem;
|
||||
border-radius: 0.375rem;
|
||||
border: 1px solid #eee;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 41%;
|
||||
}
|
||||
|
||||
&__pill {
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
padding: 0.25rem 1rem;
|
||||
border-radius: 0.875rem;
|
||||
line-height: 1.5;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__pill-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 300;
|
||||
font-size: 0.75rem;
|
||||
color: #848484;
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__pill-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 100%;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
}
|
||||
|
||||
&__details-btn {
|
||||
min-width: 8rem;
|
||||
padding: 0 0.875rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,167 @@
|
||||
<template>
|
||||
<form class="sessions-filters" @submit.prevent="onSubmit">
|
||||
<div class="sessions-filters__grid">
|
||||
<TextField v-model="form.title" name="title" label="عنوان جلسه">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="book" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.courseTemplateId"
|
||||
name="courseTemplateId"
|
||||
label="دوره الگو"
|
||||
:options="templateOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchTemplates"
|
||||
/>
|
||||
<SelectField
|
||||
v-model="form.sessionType"
|
||||
name="sessionType"
|
||||
label="نوع جلسه"
|
||||
:options="sessionTypeOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
/>
|
||||
<DatePickerField v-model="form.fromDate" name="fromDate" label="از تاریخ" :max="todayIso" />
|
||||
<DatePickerField v-model="form.toDate" name="toDate" label="تا تاریخ" :max="todayIso" />
|
||||
</div>
|
||||
|
||||
<div class="sessions-filters__actions">
|
||||
<CircleButton
|
||||
v-if="hasFilters"
|
||||
tooltip="حذف فیلتر"
|
||||
bg-color="transparent"
|
||||
size="2.5rem"
|
||||
type="button"
|
||||
@click="onReset"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="اعمال فیلتر"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
type="submit"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="funnel" :size="20" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { useAdminCourseTemplatesListQuery } from '@/services/query/admin-course-templates'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
import { SESSION_TYPE } from '@/enums'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
title: '',
|
||||
courseTemplateId: '',
|
||||
sessionType: '',
|
||||
fromDate: '',
|
||||
toDate: '',
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'apply', 'reset'])
|
||||
|
||||
const emptyForm = () => ({
|
||||
title: '',
|
||||
courseTemplateId: '',
|
||||
sessionType: '',
|
||||
fromDate: '',
|
||||
toDate: '',
|
||||
})
|
||||
|
||||
const form = ref({ ...emptyForm(), ...props.modelValue })
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(next) => {
|
||||
form.value = { ...emptyForm(), ...next }
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const todayIso = new Date().toISOString()
|
||||
|
||||
const sessionTypeOptions = Object.entries(SESSION_TYPE).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: templatesResponse } = useAdminCourseTemplatesListQuery(
|
||||
templateFilters,
|
||||
templatePagination
|
||||
)
|
||||
const templateOptions = computed(() => templatesResponse.value?.data ?? [])
|
||||
|
||||
const searchTemplates = useDebounce((q) => {
|
||||
templateSearch.value = q || ''
|
||||
}, 400)
|
||||
|
||||
const hasFilters = computed(() =>
|
||||
Object.values(form.value).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
)
|
||||
|
||||
const onSubmit = () => {
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('apply', { ...form.value })
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
form.value = emptyForm()
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.sessions-filters {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
|
||||
&__grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding-top: 1.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,299 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="60rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ data, close }">
|
||||
<div class="session-attendance">
|
||||
<LineTitleBlock title="حضور و غیاب" title-en="Attendance" />
|
||||
|
||||
<div class="session-attendance__filters">
|
||||
<SelectField
|
||||
v-model="filters.termId"
|
||||
name="termId"
|
||||
label="ترم"
|
||||
:options="termOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchTerms"
|
||||
/>
|
||||
<SelectField
|
||||
v-model="filters.courseId"
|
||||
name="courseId"
|
||||
label="دوره"
|
||||
:options="courseOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:disabled="!filters.termId"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="4" :cols-per-row="1" />
|
||||
<div v-else-if="attendance.length > 0" class="session-attendance__list">
|
||||
<div v-for="row in attendance" :key="rowKey(row)" class="session-attendance__row">
|
||||
<div class="session-attendance__user">
|
||||
<div v-if="row.user?.avatarUrl" class="session-attendance__avatar">
|
||||
<img :src="row.user.avatarUrl" :alt="userName(row.user)" />
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="session-attendance__avatar session-attendance__avatar--placeholder"
|
||||
>
|
||||
<SvgIcon name="user" :size="20" color="#bcbcbc" />
|
||||
</div>
|
||||
<div>
|
||||
<p class="session-attendance__name">{{ userName(row.user) }}</p>
|
||||
<p class="session-attendance__meta">
|
||||
<span>{{ row.user?.address?.province?.name || '—' }}</span>
|
||||
<span class="session-attendance__sep">،</span>
|
||||
<span>{{ row.user?.address?.city?.name || '—' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="session-attendance__status"
|
||||
:class="`session-attendance__status--${row.status || 'unknown'}`"
|
||||
>
|
||||
<span class="session-attendance__status-dot" />
|
||||
{{ statusLabel(row.status) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<NoItems v-else title="موردی یافت نشد" desc="لیست حضور و غیابی برای نمایش وجود ندارد." />
|
||||
|
||||
<PaginationBlock :pagination="paginationMeta" @update:page="setPage" />
|
||||
|
||||
<div class="session-attendance__divider" />
|
||||
|
||||
<div class="session-attendance__footer">
|
||||
<BaseButton text="بستن" custom-class="session-attendance__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import { useAdminSessionAttendanceQuery } from '@/services/query/admin-sessions'
|
||||
import { useAdminTermsListQuery } from '@/services/query/admin-terms'
|
||||
import { useAdminCoursesListQuery } from '@/services/query/admin-courses'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
|
||||
defineOptions({ name: 'SessionAttendanceModal' })
|
||||
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('SessionAttendanceModal')?.data ?? {})
|
||||
const sessionId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const filters = ref({ termId: '', courseId: '' })
|
||||
const filtersRef = computed(() => ({
|
||||
termId: filters.value.termId,
|
||||
courseId: filters.value.courseId,
|
||||
}))
|
||||
const { pagination, setPage } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = useAdminSessionAttendanceQuery(sessionId, filtersRef, pagination, {
|
||||
enabled: () => !!sessionId.value,
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
const attendance = computed(() => data.value?.data ?? [])
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const termSearch = ref('')
|
||||
const termListFilters = computed(() => ({ title: termSearch.value }))
|
||||
const termPagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: termsResponse } = useAdminTermsListQuery(termListFilters, termPagination)
|
||||
const termOptions = computed(() => termsResponse.value?.data ?? [])
|
||||
|
||||
const courseListFilters = computed(() => ({ termId: filters.value.termId }))
|
||||
const coursePagination = ref({ page: 1, perPage: 50 })
|
||||
const { data: coursesResponse } = useAdminCoursesListQuery(courseListFilters, coursePagination, {
|
||||
enabled: () => !!filters.value.termId,
|
||||
})
|
||||
const courseOptions = computed(() => coursesResponse.value?.data ?? [])
|
||||
|
||||
const searchTerms = useDebounce((q) => {
|
||||
termSearch.value = q || ''
|
||||
}, 400)
|
||||
|
||||
watch(
|
||||
() => filters.value.termId,
|
||||
() => {
|
||||
filters.value.courseId = ''
|
||||
}
|
||||
)
|
||||
|
||||
const userName = (user) =>
|
||||
`${user?.firstName || ''} ${user?.lastName || ''}`.trim() || user?.fullName || '—'
|
||||
|
||||
const rowKey = (row) => row.id || `${row.userId}-${row.sessionId}`
|
||||
|
||||
const statusLabel = (status) => {
|
||||
if (status === 'present') return 'حاضر'
|
||||
if (status === 'absent') return 'غایب'
|
||||
if (status === 'late') return 'با تاخیر'
|
||||
if (status === 'leave') return 'مرخصی'
|
||||
return 'نامشخص'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.session-attendance {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__filters {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
margin-block: 0.75rem;
|
||||
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: rgba(255, 255, 255, 85%);
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
}
|
||||
|
||||
&__user {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #eee;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 300;
|
||||
color: #848484;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: #c4c4c4;
|
||||
margin-inline: 0.25rem;
|
||||
}
|
||||
|
||||
&__status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
padding: 0.25rem 0.875rem;
|
||||
border-radius: 0.875rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
|
||||
&--present {
|
||||
background: rgba(0, 154, 18, 8%);
|
||||
color: #009a12;
|
||||
}
|
||||
|
||||
&--absent {
|
||||
background: rgba(204, 40, 49, 8%);
|
||||
color: var(--color-error);
|
||||
}
|
||||
|
||||
&--late {
|
||||
background: rgba(255, 165, 0, 8%);
|
||||
color: #cc6f00;
|
||||
}
|
||||
|
||||
&--leave {
|
||||
background: rgba(104, 104, 104, 8%);
|
||||
color: #686868;
|
||||
}
|
||||
|
||||
&--unknown {
|
||||
background: rgba(180, 180, 180, 10%);
|
||||
color: #848484;
|
||||
}
|
||||
}
|
||||
|
||||
&__status-dot {
|
||||
width: 0.375rem;
|
||||
height: 0.375rem;
|
||||
border-radius: 9999px;
|
||||
background: currentcolor;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,262 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="60rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<div class="session-details">
|
||||
<LineTitleBlock title="جزئیات جلسه" title-en="Session Details" />
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="3" :cols-per-row="1" />
|
||||
<template v-else-if="session">
|
||||
<div class="session-details__hero">
|
||||
<div class="session-details__image">
|
||||
<img v-if="session.image" :src="session.image" :alt="session.title" />
|
||||
<SvgIcon v-else name="book" :size="36" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="session-details__hero-info">
|
||||
<p class="session-details__title">{{ session.title || '—' }}</p>
|
||||
<p v-if="session.courseTemplate?.title" class="session-details__sub">
|
||||
دوره: {{ session.courseTemplate.title }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="session-details__grid">
|
||||
<LineInfoBlock title="نوع جلسه" :desc="sessionTypeLabel" />
|
||||
<LineInfoBlock title="مدت زمان" :numeric-desc="durationLabel" />
|
||||
<LineInfoBlock title="ترتیب" :numeric-desc="session.order ?? '—'" />
|
||||
<LineInfoBlock title="درسهای مرتبط" :numeric-desc="usedInTermsCount" />
|
||||
</div>
|
||||
|
||||
<div v-if="hasConfig" class="session-details__config">
|
||||
<LineTitleBlock title="تنظیمات جلسه" title-en="Session Config" />
|
||||
<div class="session-details__grid">
|
||||
<LineInfoBlock
|
||||
v-if="session.sessionConfig?.startTime"
|
||||
title="تاریخ و ساعت شروع"
|
||||
:numeric-desc="
|
||||
formatJalaaliDate(session.sessionConfig.startTime) ||
|
||||
session.sessionConfig.startTime
|
||||
"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
v-if="session.sessionConfig?.location"
|
||||
title="مکان"
|
||||
:desc="session.sessionConfig.location"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
v-if="session.sessionConfig?.meetingLink"
|
||||
title="لینک جلسه"
|
||||
:desc="session.sessionConfig.meetingLink"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
v-if="session.sessionConfig?.platform"
|
||||
title="پلتفرم"
|
||||
:desc="
|
||||
SESSION_PLATFORM[session.sessionConfig.platform] || session.sessionConfig.platform
|
||||
"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
v-if="session.sessionConfig?.minWatchedPercent != null"
|
||||
title="حداقل درصد مشاهده"
|
||||
:numeric-desc="`${session.sessionConfig.minWatchedPercent}%`"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
v-if="session.sessionConfig?.minReadPercent != null"
|
||||
title="حداقل درصد مطالعه"
|
||||
:numeric-desc="`${session.sessionConfig.minReadPercent}%`"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
v-if="session.sessionConfig?.mustCompleteBeforeNext != null"
|
||||
title="الزام تکمیل قبل از جلسه بعدی"
|
||||
:desc="session.sessionConfig.mustCompleteBeforeNext ? 'بله' : 'خیر'"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="session.description" class="session-details__desc">
|
||||
<LineInfoBlock title="توضیحات" :desc="session.description" />
|
||||
</div>
|
||||
|
||||
<div v-if="session.materials?.length" class="session-details__materials">
|
||||
<LineTitleBlock title="فایلهای جلسه" title-en="Materials" />
|
||||
<ul class="session-details__materials-list">
|
||||
<li v-for="material in session.materials" :key="material.id">
|
||||
<a
|
||||
:href="material.filePath || material.fileUrl || '#'"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="session-details__file"
|
||||
>
|
||||
<SvgIcon name="file" :size="16" color="var(--color-prim-gray)" />
|
||||
<span>{{ material.title || `فایل ${material.id}` }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
<NoItems v-else title="یافت نشد" desc="اطلاعات این جلسه در دسترس نیست." />
|
||||
|
||||
<div class="session-details__divider" />
|
||||
|
||||
<div class="session-details__footer">
|
||||
<BaseButton text="بستن" custom-class="session-details__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { useAdminSessionQuery } from '@/services/query/admin-sessions'
|
||||
import { SESSION_PLATFORM, SESSION_TYPE } from '@/enums'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'SessionDetailsModal' })
|
||||
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('SessionDetailsModal')?.data ?? {})
|
||||
const sessionId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const { data: session, isLoading } = useAdminSessionQuery(sessionId, {
|
||||
enabled: () => !!sessionId.value,
|
||||
})
|
||||
|
||||
const sessionTypeLabel = computed(
|
||||
() => session.value?.sessionTypeFa || SESSION_TYPE[session.value?.sessionType] || '—'
|
||||
)
|
||||
|
||||
const durationLabel = computed(() =>
|
||||
session.value?.durationMinutes == null ? '—' : `${session.value.durationMinutes} دقیقه`
|
||||
)
|
||||
|
||||
const usedInTermsCount = computed(() => session.value?.usedInTerms?.length ?? 0)
|
||||
|
||||
const hasConfig = computed(() => {
|
||||
const c = session.value?.sessionConfig
|
||||
if (!c) return false
|
||||
return Object.values(c).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.session-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__hero {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
&__image {
|
||||
width: 5rem;
|
||||
height: 5rem;
|
||||
border-radius: 0.5rem;
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
&__hero-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1.1rem;
|
||||
font-weight: 500;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.375rem;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.8rem;
|
||||
color: #838383;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.25rem;
|
||||
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__config,
|
||||
&__desc,
|
||||
&__materials {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
&__materials-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
&__file {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
color: var(--color-primary);
|
||||
text-decoration: none;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 10rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,531 @@
|
||||
<template>
|
||||
<div class="session-form">
|
||||
<BoxedIconTitleBlock
|
||||
class="session-form__heading"
|
||||
:title="isEditMode ? 'ویرایش جلسه' : 'افزودن جلسه جدید'"
|
||||
desc="در این قسمت میتوانید جلسه خود را مدیریت کنید."
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="book" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<form class="session-form__form" @submit.prevent="onSubmit">
|
||||
<div class="session-form__grid">
|
||||
<div class="session-form__image-col">
|
||||
<ImageCropper
|
||||
v-model="image"
|
||||
name="image"
|
||||
bg-color="#eeeeee"
|
||||
@crop="onImageCropped"
|
||||
@error="onImageError"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="session-form__main-col">
|
||||
<LineTitleBlock title="اطلاعات جلسه" title-en="Session Details" />
|
||||
<div class="session-form__row">
|
||||
<div class="session-form__cell session-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.title"
|
||||
name="title"
|
||||
label="عنوان جلسه"
|
||||
:error="errors.title"
|
||||
@blur="validateAt('title', form.title)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="book" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
</div>
|
||||
<div class="session-form__cell session-form__cell--third">
|
||||
<SelectField
|
||||
v-model="form.courseTemplateId"
|
||||
name="courseTemplateId"
|
||||
label="دوره الگو"
|
||||
:options="templateOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchTemplates"
|
||||
:error="errors.courseTemplateId"
|
||||
/>
|
||||
</div>
|
||||
<div class="session-form__cell session-form__cell--third">
|
||||
<SelectField
|
||||
v-model="form.sessionType"
|
||||
name="sessionType"
|
||||
label="نوع جلسه"
|
||||
:options="sessionTypeOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:error="errors.sessionType"
|
||||
/>
|
||||
</div>
|
||||
<div class="session-form__cell session-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.durationMinutes"
|
||||
name="durationMinutes"
|
||||
label="مدت زمان (دقیقه)"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
:error="errors.durationMinutes"
|
||||
@blur="validateAt('durationMinutes', form.durationMinutes)"
|
||||
/>
|
||||
</div>
|
||||
<div class="session-form__cell session-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.order"
|
||||
name="order"
|
||||
label="ترتیب"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
:error="errors.order"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<template v-if="form.sessionType === 'online'">
|
||||
<div class="session-form__cell session-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.sessionConfig.meetingLink"
|
||||
name="meetingLink"
|
||||
label="لینک جلسه"
|
||||
/>
|
||||
</div>
|
||||
<div class="session-form__cell session-form__cell--third">
|
||||
<SelectField
|
||||
v-model="form.sessionConfig.platform"
|
||||
name="platform"
|
||||
label="پلتفرم"
|
||||
:options="platformOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
/>
|
||||
</div>
|
||||
<div class="session-form__cell session-form__cell--third">
|
||||
<DatePickerField
|
||||
v-model="form.sessionConfig.startTime"
|
||||
name="startTime"
|
||||
label="تاریخ و ساعت شروع"
|
||||
type="datetime"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="form.sessionType === 'in_person'">
|
||||
<div class="session-form__cell session-form__cell--third">
|
||||
<DatePickerField
|
||||
v-model="form.sessionConfig.startTime"
|
||||
name="startTime"
|
||||
label="تاریخ و ساعت شروع"
|
||||
type="datetime"
|
||||
/>
|
||||
</div>
|
||||
<div class="session-form__cell session-form__cell--full">
|
||||
<TextField
|
||||
v-model="form.sessionConfig.location"
|
||||
name="location"
|
||||
label="مکان جلسه"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="['video', 'audio'].includes(form.sessionType)">
|
||||
<div class="session-form__cell session-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.sessionConfig.minWatchedPercent"
|
||||
name="minWatchedPercent"
|
||||
label="حداقل درصد مشاهده (%)"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
/>
|
||||
</div>
|
||||
<div class="session-form__cell session-form__cell--third session-form__toggle-cell">
|
||||
<ToggleSwitch
|
||||
v-model="form.sessionConfig.mustCompleteBeforeNext"
|
||||
label="الزام تکمیل قبل از جلسه بعدی"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="['text', 'slide', 'pdf'].includes(form.sessionType)">
|
||||
<div class="session-form__cell session-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.sessionConfig.minReadPercent"
|
||||
name="minReadPercent"
|
||||
label="حداقل درصد مطالعه (%)"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
/>
|
||||
</div>
|
||||
<div class="session-form__cell session-form__cell--third session-form__toggle-cell">
|
||||
<ToggleSwitch
|
||||
v-model="form.sessionConfig.mustCompleteBeforeNext"
|
||||
label="الزام تکمیل قبل از جلسه بعدی"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="session-form__cell session-form__cell--full">
|
||||
<TextareaField
|
||||
v-model="form.description"
|
||||
name="description"
|
||||
label="توضیحات"
|
||||
:row="5"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="session-form__materials">
|
||||
<LineTitleBlock title="فایلهای جلسه" title-en="Session Materials" />
|
||||
<FileUploader
|
||||
v-model="materials"
|
||||
accept=".mp4,.mov,.avi,.mp3,.wav,.jpg,.jpeg,.png,.pdf,.txt,.doc,.docx"
|
||||
:multiple="true"
|
||||
:max-files="10"
|
||||
context="session"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="session-form__divider" />
|
||||
|
||||
<div class="session-form__actions">
|
||||
<BaseButton
|
||||
variant="transparent"
|
||||
text="منصرف شدم"
|
||||
custom-class="session-form__btn-cancel"
|
||||
@click="onCancel"
|
||||
>
|
||||
<template #prependIcon>
|
||||
<SvgIcon name="caret-right" :size="14" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
:text="isEditMode ? 'ذخیره تغییرات' : 'تایید اطلاعات'"
|
||||
:loading="submitting"
|
||||
custom-class="session-form__btn-submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="20" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { toast } from 'vue3-toastify'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import ToggleSwitch from '@/components/form/ToggleSwitch.vue'
|
||||
import ImageCropper from '@/components/form/ImageCropper.vue'
|
||||
import FileUploader from '@/components/form/FileUploader.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useYup from '@/composables/useYup'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
import {
|
||||
adminSessionsKeys,
|
||||
useAddAdminSessionMutation,
|
||||
useAdminSessionQuery,
|
||||
useUpdateAdminSessionMutation,
|
||||
} from '@/services/query/admin-sessions'
|
||||
import { useUploadTemporaryMutation } from '@/services/query/auth'
|
||||
import { useAdminCourseTemplatesListQuery } from '@/services/query/admin-course-templates'
|
||||
import { SESSION_PLATFORM, SESSION_TYPE } from '@/enums'
|
||||
import { sessionSchema } from '@/features/admin/sessions/schema'
|
||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const sessionId = computed(() => (route.params.id ? Number(route.params.id) : null))
|
||||
const isEditMode = computed(() => !!sessionId.value)
|
||||
|
||||
const sessionTypeOptions = Object.entries(SESSION_TYPE).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
const platformOptions = Object.entries(SESSION_PLATFORM).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
|
||||
const emptySessionConfig = () => ({
|
||||
meetingLink: '',
|
||||
platform: '',
|
||||
startTime: '',
|
||||
location: '',
|
||||
minWatchedPercent: '',
|
||||
minReadPercent: '',
|
||||
mustCompleteBeforeNext: false,
|
||||
})
|
||||
|
||||
const form = ref({
|
||||
title: '',
|
||||
courseTemplateId: '',
|
||||
sessionType: '',
|
||||
durationMinutes: '',
|
||||
order: '',
|
||||
description: '',
|
||||
imageId: null,
|
||||
sessionConfig: emptySessionConfig(),
|
||||
})
|
||||
|
||||
const image = ref(null)
|
||||
const materials = ref([])
|
||||
|
||||
const schema = sessionSchema
|
||||
|
||||
const { validate, validateAt, errors } = useYup(schema)
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: templatesResponse } = useAdminCourseTemplatesListQuery(
|
||||
templateFilters,
|
||||
templatePagination
|
||||
)
|
||||
const selectedTemplate = ref(null)
|
||||
const templateOptions = computed(() => {
|
||||
const base = templatesResponse.value?.data ?? []
|
||||
if (selectedTemplate.value && !base.some((t) => t.id === selectedTemplate.value.id)) {
|
||||
return [...base, selectedTemplate.value]
|
||||
}
|
||||
return base
|
||||
})
|
||||
|
||||
const searchTemplates = useDebounce((q) => {
|
||||
templateSearch.value = q || ''
|
||||
}, 400)
|
||||
|
||||
const { data: existingSession } = useAdminSessionQuery(sessionId, {
|
||||
enabled: () => !!sessionId.value,
|
||||
})
|
||||
|
||||
watch(existingSession, (session) => {
|
||||
if (!session) return
|
||||
if (session.courseTemplate) {
|
||||
selectedTemplate.value = session.courseTemplate
|
||||
}
|
||||
form.value = {
|
||||
title: session.title || '',
|
||||
courseTemplateId: session.courseTemplate?.id || session.courseTemplateId || '',
|
||||
sessionType: session.sessionType || '',
|
||||
durationMinutes: session.durationMinutes ?? '',
|
||||
order: session.order ?? '',
|
||||
description: session.description || '',
|
||||
imageId: session.imageId || null,
|
||||
sessionConfig: { ...emptySessionConfig(), ...session.sessionConfig },
|
||||
}
|
||||
if (session.image) image.value = { url: session.image }
|
||||
if (Array.isArray(session.materials)) {
|
||||
materials.value = session.materials.map((m) => ({
|
||||
id: m.id,
|
||||
name: m.title || `فایل ${m.id}`,
|
||||
url: m.filePath || '',
|
||||
type: m.type,
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
const uploadMutation = useUploadTemporaryMutation()
|
||||
|
||||
const onImageCropped = async (file) => {
|
||||
try {
|
||||
const formData = objectToFormData({ file, subType: 'avatar', context: 'session' })
|
||||
const response = await uploadMutation.mutateAsync(formData)
|
||||
const payload = response?.data ?? response
|
||||
image.value = { url: payload?.url, uploadId: payload?.uploadId, ...payload }
|
||||
form.value.imageId = payload?.uploadId || payload?.id
|
||||
} catch {
|
||||
/* handled globally */
|
||||
}
|
||||
}
|
||||
|
||||
const onImageError = (msg) => toast.error(msg)
|
||||
|
||||
const cleanSessionConfig = (config, type) => {
|
||||
const result = {}
|
||||
const allow = (key) => {
|
||||
if (type === 'online') return ['meetingLink', 'platform', 'startTime'].includes(key)
|
||||
if (type === 'in_person') return ['startTime', 'location'].includes(key)
|
||||
if (['video', 'audio'].includes(type))
|
||||
return ['minWatchedPercent', 'mustCompleteBeforeNext'].includes(key)
|
||||
if (['text', 'slide', 'pdf'].includes(type))
|
||||
return ['minReadPercent', 'mustCompleteBeforeNext'].includes(key)
|
||||
return false
|
||||
}
|
||||
Object.entries(config || {}).forEach(([k, v]) => {
|
||||
if (!allow(k)) return
|
||||
if (v === '' || v === null || v === undefined) return
|
||||
result[k] = v
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
const buildPayload = (values) => {
|
||||
const sessionConfig = cleanSessionConfig(values.sessionConfig, values.sessionType)
|
||||
const payload = {
|
||||
title: values.title,
|
||||
courseTemplateId: values.courseTemplateId,
|
||||
sessionType: values.sessionType,
|
||||
durationMinutes: values.durationMinutes,
|
||||
order: values.order,
|
||||
description: values.description,
|
||||
imageId: values.imageId,
|
||||
}
|
||||
if (Object.keys(sessionConfig).length > 0) payload.sessionConfig = sessionConfig
|
||||
payload.materials = materials.value.map((m, index) => ({
|
||||
fileId: m.id,
|
||||
isRequired: false,
|
||||
type: m.type,
|
||||
title: m.name,
|
||||
order: index + 1,
|
||||
}))
|
||||
Object.keys(payload).forEach((key) => {
|
||||
if (payload[key] === undefined || payload[key] === '') delete payload[key]
|
||||
})
|
||||
return payload
|
||||
}
|
||||
|
||||
const addMutation = useAddAdminSessionMutation()
|
||||
const updateMutation = useUpdateAdminSessionMutation()
|
||||
|
||||
const submitting = computed(() => addMutation.isPending.value || updateMutation.isPending.value)
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
const payload = buildPayload(form.value)
|
||||
if (isEditMode.value) {
|
||||
await updateMutation.mutateAsync({ id: sessionId.value, payload })
|
||||
} else {
|
||||
await addMutation.mutateAsync(payload)
|
||||
}
|
||||
await queryClient.invalidateQueries({ queryKey: adminSessionsKeys.all })
|
||||
router.push({ name: 'admin-sessions' })
|
||||
}
|
||||
|
||||
const onCancel = () => router.push({ name: 'admin-sessions' })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.session-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__form {
|
||||
background: rgba(255, 255, 255, 60%);
|
||||
padding: 1rem;
|
||||
border-radius: 1rem;
|
||||
}
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 1rem;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: 4fr 8fr;
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: 3fr 9fr;
|
||||
}
|
||||
}
|
||||
|
||||
&__image-col {
|
||||
order: 2;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
order: 1;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__main-col {
|
||||
order: 1;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
order: 2;
|
||||
padding-inline-start: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
flex-flow: column wrap;
|
||||
gap: 0.5rem;
|
||||
align-items: stretch;
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
flex-direction: row;
|
||||
}
|
||||
}
|
||||
|
||||
&__cell {
|
||||
width: 100%;
|
||||
|
||||
&--third {
|
||||
@media (min-width: 768px) {
|
||||
width: 49%;
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
width: 32.3%;
|
||||
}
|
||||
}
|
||||
|
||||
&--full {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&__toggle-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__materials {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.5rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
&__btn-submit {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,156 @@
|
||||
<template>
|
||||
<div class="sessions-page">
|
||||
<BoxedIconTitleBlock
|
||||
class="sessions-page__heading"
|
||||
title="مدیریت جلسات"
|
||||
desc="در این قسمت میتوانید جلسات خود را مدیریت کنید"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="book" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<SessionsFilters v-model="filters" @apply="onFilterApply" @reset="onFilterReset" />
|
||||
|
||||
<div class="sessions-page__list-header">
|
||||
<SimpleTitleIconBlock title="لیست همه جلسات" class="sessions-page__list-title">
|
||||
<template #header-icon>
|
||||
<SvgIcon name="list-bullets" :size="16" color="#bcbcbc" />
|
||||
</template>
|
||||
</SimpleTitleIconBlock>
|
||||
<BaseButton text="افزودن جلسه جدید" custom-class="sessions-page__add-btn" @click="onAdd">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="plus" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="6" :cols-per-row="1" />
|
||||
<div v-else-if="sessions.length > 0">
|
||||
<SessionItem
|
||||
v-for="session in sessions"
|
||||
:key="session.id"
|
||||
:session="session"
|
||||
@edit="onEdit"
|
||||
@delete="onAskDelete"
|
||||
@show-details="onShowDetails"
|
||||
@show-attendance="onShowAttendance"
|
||||
/>
|
||||
</div>
|
||||
<NoItems v-else title="متاسفیم" desc="جلسهای برای نمایش وجود ندارد." />
|
||||
|
||||
<PaginationBlock :pagination="paginationMeta" @update:page="setPage" />
|
||||
|
||||
<SessionAttendanceModal v-if="isModal('SessionAttendanceModal')" />
|
||||
<SessionDetailsModal v-if="isModal('SessionDetailsModal')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import SessionsFilters from '@/features/admin/sessions/components/SessionsFilters.vue'
|
||||
import SessionItem from '@/features/admin/sessions/components/SessionItem.vue'
|
||||
import SessionAttendanceModal from '@/features/admin/sessions/components/modals/SessionAttendanceModal.vue'
|
||||
import SessionDetailsModal from '@/features/admin/sessions/components/modals/SessionDetailsModal.vue'
|
||||
import {
|
||||
adminSessionsKeys,
|
||||
useAdminSessionsListQuery,
|
||||
useDeleteAdminSessionMutation,
|
||||
} from '@/services/query/admin-sessions'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import useModal from '@/composables/useModal'
|
||||
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
const { openModal, isModal } = useModal()
|
||||
|
||||
const filters = ref({
|
||||
title: '',
|
||||
courseTemplateId: '',
|
||||
sessionType: '',
|
||||
fromDate: '',
|
||||
toDate: '',
|
||||
})
|
||||
const { pagination, setPage, reset: resetPagination } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = useAdminSessionsListQuery(filters, pagination, {
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
const sessions = computed(() => data.value?.data ?? [])
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const onFilterApply = () => resetPagination()
|
||||
const onFilterReset = () => resetPagination()
|
||||
|
||||
const onAdd = () => {
|
||||
router.push({ name: 'admin-add-session' }).catch(() => {})
|
||||
}
|
||||
|
||||
const onEdit = (session) => {
|
||||
router.push({ name: 'admin-edit-session', params: { id: session.id } }).catch(() => {})
|
||||
}
|
||||
|
||||
const onShowDetails = (session) => {
|
||||
openModal('SessionDetailsModal', { id: session.id })
|
||||
}
|
||||
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminSessionsKeys.all })
|
||||
|
||||
const deleteMutation = useDeleteAdminSessionMutation()
|
||||
|
||||
const onAskDelete = (session) => {
|
||||
openModal('ConfirmModal', {
|
||||
title: `حذف ${session.title}`,
|
||||
message: `بعد از حذف امکان بازگشت وجود ندارد، آیا مطمئن هستید که میخواهید <strong>${session.title}</strong> را حذف کنید؟`,
|
||||
onConfirm: () => deleteMutation.mutate(session.id, { onSuccess: invalidate }),
|
||||
})
|
||||
}
|
||||
|
||||
const onShowAttendance = (session) => {
|
||||
openModal('SessionAttendanceModal', { id: session.id, title: session.title })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.sessions-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__list-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
margin-bottom: 0.375rem;
|
||||
}
|
||||
|
||||
&__list-title {
|
||||
flex: 1;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&__add-btn {
|
||||
min-width: fit-content;
|
||||
padding: 0 1.25rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,10 @@
|
||||
import { number, object, string } from 'yup'
|
||||
|
||||
export const sessionSchema = object().shape({
|
||||
courseTemplateId: string().required(),
|
||||
title: string().required().min(3),
|
||||
sessionType: string().required(),
|
||||
durationMinutes: number().typeError('مدت زمان باید عدد باشد').required(),
|
||||
order: number().typeError('ترتیب باید عدد باشد').nullable().notRequired(),
|
||||
description: string().nullable().notRequired(),
|
||||
})
|
||||
@@ -0,0 +1,227 @@
|
||||
<template>
|
||||
<div class="term-item">
|
||||
<div class="term-item__main">
|
||||
<div v-if="term.image" class="term-item__image">
|
||||
<img :src="term.image" :alt="term.title" />
|
||||
</div>
|
||||
<div v-else class="term-item__image term-item__image--placeholder">
|
||||
<SvgIcon name="book" :size="24" color="#bcbcbc" />
|
||||
</div>
|
||||
<p class="term-item__title">{{ term.title }}</p>
|
||||
</div>
|
||||
|
||||
<div class="term-item__dates">
|
||||
<div class="term-item__date">
|
||||
<span class="term-item__date-label">تاریخ شروع:</span>
|
||||
<span class="term-item__date-value">{{ startDate || '—' }}</span>
|
||||
</div>
|
||||
<div class="term-item__date">
|
||||
<span class="term-item__date-label">تاریخ پایان:</span>
|
||||
<span class="term-item__date-value">{{ endDate || '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!term.isActive" class="term-item__status">
|
||||
<span class="term-item__status-badge">
|
||||
<span class="term-item__status-dot" />
|
||||
غیرفعال
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="term-item__actions">
|
||||
<ToggleSwitch
|
||||
:model-value="!!term.isActive"
|
||||
@update:model-value="emit('change-status', { id: term.id, isActive: !term.isActive })"
|
||||
/>
|
||||
<CircleButton
|
||||
tooltip="حذف"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('delete', term)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="18" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="کپی"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('clone', term)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="copy" :size="18" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="ویرایش"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('edit', term)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="pencil" :size="18" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<BaseButton
|
||||
text="جزئیات ترم"
|
||||
custom-class="term-item__details-btn"
|
||||
@click="emit('show-details', term)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import ToggleSwitch from '@/components/form/ToggleSwitch.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
const props = defineProps({
|
||||
term: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['edit', 'delete', 'clone', 'change-status', 'show-details'])
|
||||
|
||||
const startDate = computed(
|
||||
() => props.term.faStartDate || formatJalaaliDate(props.term.startDate) || ''
|
||||
)
|
||||
const endDate = computed(() => props.term.faEndDate || formatJalaaliDate(props.term.endDate) || '')
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.term-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: 768px) {
|
||||
flex-flow: row wrap;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
min-width: 0;
|
||||
flex: 1 1 33%;
|
||||
}
|
||||
|
||||
&__image {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
min-width: 3rem;
|
||||
border-radius: 0.375rem;
|
||||
border: 1px solid #eee;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&__dates {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 33%;
|
||||
}
|
||||
|
||||
&__date {
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
padding: 0.25rem 1rem;
|
||||
border-radius: 0.875rem;
|
||||
line-height: 1.5;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__date-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 300;
|
||||
font-size: 0.75rem;
|
||||
color: #848484;
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__date-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
&__status {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
&__status-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
padding: 0.25rem 1rem;
|
||||
border-radius: 0.875rem;
|
||||
background: rgba(204, 40, 49, 6%);
|
||||
color: var(--color-error);
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
|
||||
&__status-dot {
|
||||
width: 0.375rem;
|
||||
height: 0.375rem;
|
||||
border-radius: 9999px;
|
||||
background: currentcolor;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 100%;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
}
|
||||
|
||||
&__details-btn {
|
||||
min-width: 8rem;
|
||||
padding: 0 0.875rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<form class="terms-filters" @submit.prevent="onSubmit">
|
||||
<div class="terms-filters__grid">
|
||||
<TextField v-model="form.title" name="title" label="عنوان">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="book" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.status"
|
||||
name="status"
|
||||
label="وضعیت"
|
||||
:options="statusOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
/>
|
||||
<DatePickerField v-model="form.fromDate" name="fromDate" label="از تاریخ" :max="todayIso" />
|
||||
<DatePickerField v-model="form.toDate" name="toDate" label="تا تاریخ" :max="todayIso" />
|
||||
</div>
|
||||
|
||||
<div class="terms-filters__actions">
|
||||
<CircleButton
|
||||
v-if="hasFilters"
|
||||
tooltip="حذف فیلتر"
|
||||
bg-color="transparent"
|
||||
size="2.5rem"
|
||||
type="button"
|
||||
@click="onReset"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="اعمال فیلتر"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
type="submit"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="funnel" :size="20" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: () => ({ title: '', status: '', fromDate: '', toDate: '' }),
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'apply', 'reset'])
|
||||
|
||||
const emptyForm = () => ({ title: '', status: '', fromDate: '', toDate: '' })
|
||||
const form = ref({ ...emptyForm(), ...props.modelValue })
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(next) => {
|
||||
form.value = { ...emptyForm(), ...next }
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const todayIso = new Date().toISOString()
|
||||
|
||||
const statusOptions = [
|
||||
{ value: 1, label: 'فعال' },
|
||||
{ value: 0, label: 'غیرفعال' },
|
||||
]
|
||||
|
||||
const hasFilters = computed(() =>
|
||||
Object.values(form.value).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
)
|
||||
|
||||
const onSubmit = () => {
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('apply', { ...form.value })
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
form.value = emptyForm()
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.terms-filters {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
|
||||
&__grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding-top: 1.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,304 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="42rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<div class="add-term-student">
|
||||
<LineTitleBlock title="افزودن دانشجو" title-en="Add Student" />
|
||||
|
||||
<div class="add-term-student__search">
|
||||
<SvgIcon name="user" :size="18" color="var(--color-thd-gray)" />
|
||||
<input
|
||||
v-model="searchInput"
|
||||
type="text"
|
||||
class="add-term-student__search-input"
|
||||
placeholder="اسم دانشجو را وارد نمایید"
|
||||
@input="onSearchInput"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="4" :cols-per-row="1" />
|
||||
|
||||
<div v-else-if="users.length > 0" class="add-term-student__list">
|
||||
<div v-for="user in users" :key="user.id" class="add-term-student__row">
|
||||
<div class="add-term-student__main">
|
||||
<div v-if="user.avatarUrl" class="add-term-student__avatar">
|
||||
<img :src="user.avatarUrl" :alt="userLabel(user)" />
|
||||
</div>
|
||||
<div v-else class="add-term-student__avatar add-term-student__avatar--placeholder">
|
||||
<SvgIcon name="user" :size="20" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="add-term-student__text">
|
||||
<p class="add-term-student__name">{{ userLabel(user) }}</p>
|
||||
<p class="add-term-student__meta">
|
||||
<span>{{ user.address?.province?.name || '—' }}</span>
|
||||
<span class="add-term-student__sep">،</span>
|
||||
<span>{{ user.address?.city?.name || '—' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CircleButton
|
||||
v-if="isAttached(user.id)"
|
||||
tooltip="حذف از ترم"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.25rem"
|
||||
type="button"
|
||||
:loading="pendingId === user.id"
|
||||
@click="onDetach(user)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="16" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
v-else
|
||||
tooltip="افزودن به ترم"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.25rem"
|
||||
type="button"
|
||||
:loading="pendingId === user.id"
|
||||
@click="onAttach(user)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="plus" :size="16" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<NoItems v-else title="بدون نتیجه" desc="دانشجویی یافت نشد." />
|
||||
|
||||
<div class="add-term-student__divider" />
|
||||
|
||||
<div class="add-term-student__footer">
|
||||
<BaseButton text="تایید" custom-class="add-term-student__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
import {
|
||||
adminTermsKeys,
|
||||
useAddAdminTermStudentsMutation,
|
||||
useAdminTermStudentsQuery,
|
||||
useRemoveAdminTermStudentMutation,
|
||||
} from '@/services/query/admin-terms'
|
||||
import { useAdminUsersListQuery } from '@/services/query/admin-users'
|
||||
|
||||
defineOptions({ name: 'AddTermStudentModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('AddTermStudentModal')?.data ?? {})
|
||||
const termId = computed(() => modalData.value.termId ?? null)
|
||||
|
||||
const searchInput = ref('')
|
||||
const searchQuery = ref('')
|
||||
const userFilters = computed(() => ({ name: searchQuery.value }))
|
||||
const userPagination = ref({ page: 1, perPage: 20 })
|
||||
|
||||
const { data: usersResponse, isLoading } = useAdminUsersListQuery(userFilters, userPagination)
|
||||
const users = computed(() => usersResponse.value?.data ?? [])
|
||||
|
||||
const attachedFilters = computed(() => ({}))
|
||||
const attachedPagination = ref({ page: 1, perPage: 200 })
|
||||
const { data: attachedResponse } = useAdminTermStudentsQuery(
|
||||
termId,
|
||||
attachedFilters,
|
||||
attachedPagination,
|
||||
{ enabled: () => !!termId.value }
|
||||
)
|
||||
const attachedIds = computed(() => new Set((attachedResponse.value?.data ?? []).map((u) => u.id)))
|
||||
|
||||
const isAttached = (id) => attachedIds.value.has(id)
|
||||
|
||||
const userLabel = (user) =>
|
||||
`${user.firstName || ''} ${user.lastName || ''}`.trim() ||
|
||||
user.fullName ||
|
||||
user.phoneNumber ||
|
||||
'—'
|
||||
|
||||
const onSearchInput = useDebounce(() => {
|
||||
searchQuery.value = searchInput.value || ''
|
||||
userPagination.value = { ...userPagination.value, page: 1 }
|
||||
}, 400)
|
||||
|
||||
const pendingId = ref(null)
|
||||
|
||||
const addMutation = useAddAdminTermStudentsMutation()
|
||||
const removeMutation = useRemoveAdminTermStudentMutation()
|
||||
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminTermsKeys.all })
|
||||
|
||||
const onAttach = async (user) => {
|
||||
if (!termId.value) return
|
||||
pendingId.value = user.id
|
||||
try {
|
||||
await addMutation.mutateAsync({
|
||||
termId: termId.value,
|
||||
payload: { userIds: [user.id] },
|
||||
})
|
||||
invalidate()
|
||||
} finally {
|
||||
pendingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const onDetach = async (user) => {
|
||||
if (!termId.value) return
|
||||
pendingId.value = user.id
|
||||
try {
|
||||
await removeMutation.mutateAsync({ termId: termId.value, userId: user.id })
|
||||
invalidate()
|
||||
} finally {
|
||||
pendingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
watch(termId, () => {
|
||||
searchInput.value = ''
|
||||
searchQuery.value = ''
|
||||
pendingId.value = null
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.add-term-student {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
padding: 0.5rem 0.25rem;
|
||||
|
||||
&__search {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-block: 1rem;
|
||||
padding: 0 1rem;
|
||||
height: 2.75rem;
|
||||
border: 1px solid var(--color-thd-gray);
|
||||
border-radius: 9999px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
&__search-input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
color: #4b4b4b;
|
||||
text-align: start;
|
||||
|
||||
&::placeholder {
|
||||
color: var(--color-prim-gray);
|
||||
}
|
||||
}
|
||||
|
||||
&__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
max-height: 22rem;
|
||||
overflow-y: auto;
|
||||
padding-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: rgba(255, 255, 255, 85%);
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
}
|
||||
|
||||
&__main {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #eee;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__text {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 300;
|
||||
color: #848484;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: #c4c4c4;
|
||||
margin-inline: 0.25rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,315 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="افزودن دوره"
|
||||
title-en="Add Course"
|
||||
width="95%"
|
||||
max-width="42rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ close }">
|
||||
<div class="attach-course">
|
||||
<div class="attach-course__search">
|
||||
<SvgIcon name="book" :size="18" color="var(--color-thd-gray)" />
|
||||
<input
|
||||
v-model="searchQuery"
|
||||
type="text"
|
||||
class="attach-course__search-input"
|
||||
placeholder="عنوان دوره مورد نظر را جستوجو کنید"
|
||||
@input="onSearch"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="4" :cols-per-row="1" />
|
||||
|
||||
<div v-else-if="templates.length > 0" class="attach-course__list">
|
||||
<div v-for="template in templates" :key="template.id" class="attach-course__row">
|
||||
<div class="attach-course__main">
|
||||
<div class="attach-course__image">
|
||||
<img v-if="template.image" :src="template.image" :alt="template.title" />
|
||||
<SvgIcon v-else name="book" :size="20" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="attach-course__text">
|
||||
<p class="attach-course__title">{{ template.title }}</p>
|
||||
<p class="attach-course__teacher">
|
||||
<SvgIcon name="user" :size="11" color="#bcbcbc" />
|
||||
<span class="attach-course__teacher-label">استاد:</span>
|
||||
<span class="attach-course__teacher-name">{{ teacherName(template) }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CircleButton
|
||||
v-if="attachedCourseByTemplate(template.id)"
|
||||
tooltip="حذف از ترم"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.25rem"
|
||||
type="button"
|
||||
:loading="pendingId === template.id"
|
||||
@click="onDetach(template)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="16" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
v-else
|
||||
tooltip="افزودن به ترم"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.25rem"
|
||||
type="button"
|
||||
:loading="pendingId === template.id"
|
||||
@click="onAttach(template)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="plus" :size="16" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<NoItems v-else title="بدون نتیجه" desc="دوره الگویی یافت نشد." />
|
||||
|
||||
<div class="attach-course__divider" />
|
||||
|
||||
<div class="attach-course__footer">
|
||||
<BaseButton text="تایید" custom-class="attach-course__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
import { useAdminCourseTemplatesListQuery } from '@/services/query/admin-course-templates'
|
||||
import {
|
||||
adminCoursesKeys,
|
||||
useAddAdminCourseMutation,
|
||||
useAdminCoursesListQuery,
|
||||
useDeleteAdminCourseMutation,
|
||||
} from '@/services/query/admin-courses'
|
||||
import { adminTermsKeys } from '@/services/query/admin-terms'
|
||||
|
||||
defineOptions({ name: 'AttachCourseToTermModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('AttachCourseToTermModal')?.data ?? {})
|
||||
const termId = computed(() => modalData.value.termId ?? null)
|
||||
|
||||
const searchQuery = ref('')
|
||||
const templateFilters = computed(() => ({ title: searchQuery.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 20 })
|
||||
|
||||
const { data: templatesResponse, isLoading } = useAdminCourseTemplatesListQuery(
|
||||
templateFilters,
|
||||
templatePagination
|
||||
)
|
||||
|
||||
const templates = computed(() => templatesResponse.value?.data ?? [])
|
||||
|
||||
const courseFilters = computed(() => ({ termId: termId.value }))
|
||||
const coursePagination = ref({ page: 1, perPage: 100 })
|
||||
const { data: coursesResponse } = useAdminCoursesListQuery(courseFilters, coursePagination, {
|
||||
enabled: () => !!termId.value,
|
||||
})
|
||||
|
||||
const attachedCourses = computed(() => coursesResponse.value?.data ?? [])
|
||||
|
||||
const attachedCourseByTemplate = (templateId) =>
|
||||
attachedCourses.value.find((c) => c.template?.id === templateId || c.templateId === templateId)
|
||||
|
||||
const teacherName = (template) => {
|
||||
const t = template.defaultTeacher || template.teacher
|
||||
if (!t) return '—'
|
||||
return `${t.firstName || ''} ${t.lastName || ''}`.trim() || t.fullName || '—'
|
||||
}
|
||||
|
||||
const onSearch = useDebounce((event) => {
|
||||
searchQuery.value = event.target?.value || ''
|
||||
templatePagination.value = { ...templatePagination.value, page: 1 }
|
||||
}, 400)
|
||||
|
||||
const pendingId = ref(null)
|
||||
|
||||
const addMutation = useAddAdminCourseMutation()
|
||||
const deleteMutation = useDeleteAdminCourseMutation()
|
||||
|
||||
const invalidate = () => {
|
||||
queryClient.invalidateQueries({ queryKey: adminCoursesKeys.all })
|
||||
queryClient.invalidateQueries({ queryKey: adminTermsKeys.all })
|
||||
}
|
||||
|
||||
const onAttach = async (template) => {
|
||||
if (!termId.value) return
|
||||
pendingId.value = template.id
|
||||
try {
|
||||
await addMutation.mutateAsync({
|
||||
termId: termId.value,
|
||||
templateId: template.id,
|
||||
title: template.title,
|
||||
capacity: template.defaultCapacity ?? null,
|
||||
isActive: template.isActiveByDefault ?? true,
|
||||
})
|
||||
invalidate()
|
||||
} finally {
|
||||
pendingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const onDetach = async (template) => {
|
||||
const offered = attachedCourseByTemplate(template.id)
|
||||
if (!offered) return
|
||||
pendingId.value = template.id
|
||||
try {
|
||||
await deleteMutation.mutateAsync(offered.id)
|
||||
invalidate()
|
||||
} finally {
|
||||
pendingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
watch(termId, () => {
|
||||
searchQuery.value = ''
|
||||
pendingId.value = null
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.attach-course {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
padding: 0.5rem 0.25rem;
|
||||
|
||||
&__search {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-block: 1rem;
|
||||
padding: 0 1rem;
|
||||
height: 2.75rem;
|
||||
border: 1px solid var(--color-thd-gray);
|
||||
border-radius: 9999px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
&__search-input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
color: #4b4b4b;
|
||||
text-align: start;
|
||||
|
||||
&::placeholder {
|
||||
color: var(--color-prim-gray);
|
||||
}
|
||||
}
|
||||
|
||||
&__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
max-height: 22rem;
|
||||
overflow-y: auto;
|
||||
padding-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: rgba(255, 255, 255, 85%);
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
}
|
||||
|
||||
&__main {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__image {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: 0.5rem;
|
||||
overflow: hidden;
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
&__text {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__teacher {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #848484;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__teacher-label {
|
||||
color: #b7b7b7;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,465 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="80rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ data, close }">
|
||||
<div v-if="!term" class="term-details">
|
||||
<p class="term-details__loading">در حال بارگذاری…</p>
|
||||
</div>
|
||||
<div v-else class="term-details">
|
||||
<section class="term-details__section">
|
||||
<LineTitleBlock title="جزئیات ترم" title-en="Term Details" />
|
||||
<div class="term-details__overview">
|
||||
<div class="term-details__image">
|
||||
<img v-if="term.image" :src="term.image" :alt="term.title" />
|
||||
<SvgIcon v-else name="book" :size="32" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="term-details__overview-grid">
|
||||
<LineInfoBlock title="عنوان ترم" :desc="term.title || '-'" />
|
||||
<LineInfoBlock
|
||||
title="تاریخ شروع"
|
||||
:numeric-desc="term.faStartDate || formatJalaaliDate(term.startDate) || '-'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="تاریخ پایان"
|
||||
:numeric-desc="term.faEndDate || formatJalaaliDate(term.endDate) || '-'"
|
||||
/>
|
||||
<LineInfoBlock title="تعداد دانشجویان" :numeric-desc="term.studentsCount ?? 0" />
|
||||
<LineInfoBlock title="تعداد دورهها" :numeric-desc="term.coursesCount ?? 0" />
|
||||
<LineInfoBlock title="وضعیت" :desc="term.isActive ? 'فعال' : 'غیرفعال'" />
|
||||
<div v-if="term.description" class="term-details__cell--full">
|
||||
<LineInfoBlock title="توضیحات" :desc="term.description" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<TabsBlock :tabs="tabs" v-model="activeTab">
|
||||
<template #students>
|
||||
<div class="term-details__panel-header">
|
||||
<LineTitleBlock title="لیست دانشجویان این ترم" title-en="Students List" />
|
||||
<BaseButton
|
||||
text="افزودن دانشجو"
|
||||
custom-class="term-details__panel-btn"
|
||||
@click="onOpenAddStudent"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="studentsPending" :rows="4" :cols-per-row="1" />
|
||||
<div v-else-if="students.length > 0">
|
||||
<div v-for="student in students" :key="student.id" class="term-details__student-row">
|
||||
<div class="term-details__student-main">
|
||||
<div v-if="student.avatarUrl" class="term-details__avatar">
|
||||
<img :src="student.avatarUrl" :alt="studentName(student)" />
|
||||
</div>
|
||||
<div v-else class="term-details__avatar term-details__avatar--placeholder">
|
||||
<SvgIcon name="user" :size="20" color="#bcbcbc" />
|
||||
</div>
|
||||
<div>
|
||||
<p class="term-details__student-name">{{ studentName(student) }}</p>
|
||||
<p class="term-details__student-meta">
|
||||
<span>{{ student.address?.province?.name || '—' }}</span>
|
||||
<span class="term-details__sep">،</span>
|
||||
<span>{{ student.address?.city?.name || '—' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="term-details__student-actions">
|
||||
<ToggleSwitch
|
||||
:model-value="!!student.isOnLeave"
|
||||
@update:model-value="onToggleLeave(student, $event)"
|
||||
/>
|
||||
<CircleButton
|
||||
tooltip="حذف از ترم"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="onAskRemoveStudent(student)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="18" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<NoItems v-else title="متاسفیم" desc="دانشجویی برای نمایش وجود ندارد." />
|
||||
|
||||
<PaginationBlock :pagination="studentPaginationMeta" @update:page="setStudentPage" />
|
||||
</template>
|
||||
|
||||
<template #courses>
|
||||
<div class="term-details__panel-header">
|
||||
<LineTitleBlock title="لیست دورههای این ترم" title-en="Courses List" />
|
||||
<BaseButton
|
||||
text="افزودن دوره"
|
||||
custom-class="term-details__panel-btn"
|
||||
@click="onOpenAddCourse"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="coursesPending" :rows="4" :cols-per-row="1" />
|
||||
<div v-else-if="termCourses.length > 0">
|
||||
<CourseItem
|
||||
v-for="course in termCourses"
|
||||
:key="course.id"
|
||||
:course="course"
|
||||
@edit="onEditCourse"
|
||||
@delete="onAskDeleteCourse"
|
||||
@change-status="onChangeCourseStatus"
|
||||
@show-details="onShowCourseDetails"
|
||||
/>
|
||||
</div>
|
||||
<NoItems v-else title="متاسفیم" desc="دورهای برای نمایش وجود ندارد." />
|
||||
|
||||
<PaginationBlock :pagination="coursePaginationMeta" @update:page="setCoursePage" />
|
||||
</template>
|
||||
</TabsBlock>
|
||||
|
||||
<div class="term-details__divider" />
|
||||
|
||||
<div class="term-details__footer">
|
||||
<BaseButton text="بستن" custom-class="term-details__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
<span class="term-details__data-tap" v-if="false">{{ data }}</span>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import TabsBlock from '@/components/blocks/TabsBlock.vue'
|
||||
import ToggleSwitch from '@/components/form/ToggleSwitch.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import CourseItem from '@/features/admin/courses/components/CourseItem.vue'
|
||||
import {
|
||||
adminTermsKeys,
|
||||
useAdminTermQuery,
|
||||
useAdminTermStudentsQuery,
|
||||
useRemoveAdminTermStudentMutation,
|
||||
useToggleAdminTermStudentLeaveMutation,
|
||||
} from '@/services/query/admin-terms'
|
||||
import {
|
||||
adminCoursesKeys,
|
||||
useAdminCoursesListQuery,
|
||||
useChangeAdminCourseStatusMutation,
|
||||
useDeleteAdminCourseMutation,
|
||||
} from '@/services/query/admin-courses'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'TermDetailsModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { openModal, getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('TermDetailsModal')?.data ?? {})
|
||||
const termId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const { data: term } = useAdminTermQuery(termId, {
|
||||
enabled: () => !!termId.value,
|
||||
})
|
||||
|
||||
const tabs = [
|
||||
{ name: 'students', label: 'دانشجویان', icon: 'users' },
|
||||
{ name: 'courses', label: 'دورهها', icon: 'list-bullets' },
|
||||
]
|
||||
const activeTab = ref('students')
|
||||
|
||||
const studentFilters = ref({})
|
||||
const {
|
||||
pagination: studentPagination,
|
||||
setPage: setStudentPage,
|
||||
reset: resetStudentPagination,
|
||||
} = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data: studentsData, isLoading: studentsPending } = useAdminTermStudentsQuery(
|
||||
termId,
|
||||
studentFilters,
|
||||
studentPagination,
|
||||
{
|
||||
enabled: () => !!termId.value && activeTab.value === 'students',
|
||||
keepPreviousData: true,
|
||||
}
|
||||
)
|
||||
|
||||
const students = computed(() => studentsData.value?.data ?? [])
|
||||
const studentPaginationMeta = computed(() => ({
|
||||
page: studentPagination.value.page,
|
||||
perPage: studentPagination.value.perPage,
|
||||
...studentsData.value?.meta,
|
||||
}))
|
||||
|
||||
const studentName = (student) =>
|
||||
`${student.firstName || ''} ${student.lastName || ''}`.trim() || student.fullName || '—'
|
||||
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminTermsKeys.all })
|
||||
|
||||
const toggleLeaveMutation = useToggleAdminTermStudentLeaveMutation()
|
||||
const removeStudentMutation = useRemoveAdminTermStudentMutation()
|
||||
|
||||
const onToggleLeave = (student, isOnLeave) => {
|
||||
toggleLeaveMutation.mutate(
|
||||
{
|
||||
termId: termId.value,
|
||||
userId: student.id,
|
||||
payload: { setLeave: isOnLeave },
|
||||
},
|
||||
{ onSuccess: invalidate }
|
||||
)
|
||||
}
|
||||
|
||||
const onAskRemoveStudent = (student) => {
|
||||
openModal('ConfirmModal', {
|
||||
title: `حذف ${studentName(student)}`,
|
||||
message: `آیا از حذف <strong>${studentName(student)}</strong> از این ترم اطمینان دارید؟`,
|
||||
onConfirm: () =>
|
||||
removeStudentMutation.mutate(
|
||||
{ termId: termId.value, userId: student.id },
|
||||
{ onSuccess: invalidate }
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
const courseFilters = computed(() => ({ termId: termId.value }))
|
||||
const { pagination: coursePagination, setPage: setCoursePage } = usePagination({
|
||||
page: 1,
|
||||
perPage: 10,
|
||||
})
|
||||
|
||||
const { data: coursesData, isLoading: coursesPending } = useAdminCoursesListQuery(
|
||||
courseFilters,
|
||||
coursePagination,
|
||||
{
|
||||
enabled: () => !!termId.value && activeTab.value === 'courses',
|
||||
keepPreviousData: true,
|
||||
}
|
||||
)
|
||||
|
||||
const termCourses = computed(() => coursesData.value?.data ?? [])
|
||||
const coursePaginationMeta = computed(() => ({
|
||||
page: coursePagination.value.page,
|
||||
perPage: coursePagination.value.perPage,
|
||||
...coursesData.value?.meta,
|
||||
}))
|
||||
|
||||
const invalidateCourses = () => queryClient.invalidateQueries({ queryKey: adminCoursesKeys.all })
|
||||
|
||||
const deleteCourseMutation = useDeleteAdminCourseMutation()
|
||||
const changeCourseStatusMutation = useChangeAdminCourseStatusMutation()
|
||||
|
||||
const onOpenAddCourse = () => {
|
||||
openModal('AttachCourseToTermModal', { termId: termId.value })
|
||||
}
|
||||
|
||||
const onEditCourse = (course) => {
|
||||
openModal('AddOfferedCourseModal', { mode: 'edit', courseId: course.id })
|
||||
}
|
||||
|
||||
const onShowCourseDetails = (course) => {
|
||||
openModal('CourseDetailsModal', { id: course.id })
|
||||
}
|
||||
|
||||
const onAskDeleteCourse = (course) => {
|
||||
openModal('ConfirmModal', {
|
||||
title: `حذف ${course.title}`,
|
||||
message: `بعد از حذف امکان بازگشت وجود ندارد، آیا از حذف <strong>${course.title}</strong> اطمینان دارید؟`,
|
||||
onConfirm: () => deleteCourseMutation.mutate(course.id, { onSuccess: invalidateCourses }),
|
||||
})
|
||||
}
|
||||
|
||||
const onChangeCourseStatus = ({ id, isActive }) => {
|
||||
changeCourseStatusMutation.mutate({ id, payload: { isActive } }, { onSuccess: invalidateCourses })
|
||||
}
|
||||
|
||||
const onOpenAddStudent = () => {
|
||||
openModal('AddTermStudentModal', { termId: termId.value })
|
||||
resetStudentPagination()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.term-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__loading {
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
color: var(--color-prim-gray);
|
||||
}
|
||||
|
||||
&__section {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
&__overview {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: flex-start;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
&__image {
|
||||
width: 5rem;
|
||||
height: 5rem;
|
||||
border-radius: 0.5rem;
|
||||
background: #f5f5f5;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
&__overview-grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.25rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__cell--full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
&__panel-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
&__panel-btn {
|
||||
min-width: 11rem;
|
||||
padding: 0 1rem;
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
&__placeholder {
|
||||
text-align: center;
|
||||
color: var(--color-prim-gray);
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
&__student-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: rgba(255, 255, 255, 85%);
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
&__student-main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #eee;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__student-name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__student-meta {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 300;
|
||||
color: #848484;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: #c4c4c4;
|
||||
margin-inline: 0.25rem;
|
||||
}
|
||||
|
||||
&__student-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.5rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,298 @@
|
||||
<template>
|
||||
<div class="term-form">
|
||||
<BoxedIconTitleBlock
|
||||
class="term-form__heading"
|
||||
:title="isEditMode ? 'ویرایش ترم' : 'افزودن ترم جدید'"
|
||||
:desc="
|
||||
isEditMode ? 'اطلاعات ترم را بهروز کنید' : 'در این قسمت میتوانید ترم جدید اضافه کنید'
|
||||
"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="book" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<form class="term-form__form" @submit.prevent="onSubmit">
|
||||
<div class="term-form__grid">
|
||||
<div class="term-form__image-col">
|
||||
<ImageCropper
|
||||
v-model="image"
|
||||
name="image"
|
||||
bg-color="#eeeeee"
|
||||
@crop="onImageCropped"
|
||||
@error="onImageError"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="term-form__main-col">
|
||||
<LineTitleBlock title="اطلاعات ترم" title-en="Term Details" />
|
||||
<div class="term-form__row">
|
||||
<div class="term-form__cell term-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.title"
|
||||
name="title"
|
||||
label="عنوان ترم"
|
||||
:error="errors.title"
|
||||
@blur="validateAt('title', form.title)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="book" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
</div>
|
||||
<div class="term-form__cell term-form__cell--third">
|
||||
<DatePickerField
|
||||
v-model="form.startDate"
|
||||
name="startDate"
|
||||
label="تاریخ شروع"
|
||||
:min="todayIso"
|
||||
:error="errors.startDate"
|
||||
/>
|
||||
</div>
|
||||
<div class="term-form__cell term-form__cell--third">
|
||||
<DatePickerField
|
||||
v-model="form.endDate"
|
||||
name="endDate"
|
||||
label="تاریخ پایان"
|
||||
:min="todayIso"
|
||||
:error="errors.endDate"
|
||||
/>
|
||||
</div>
|
||||
<div class="term-form__cell term-form__cell--full">
|
||||
<TextareaField
|
||||
v-model="form.description"
|
||||
name="description"
|
||||
label="توضیحات"
|
||||
:row="5"
|
||||
:error="errors.description"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="term-form__divider" />
|
||||
|
||||
<div class="term-form__actions">
|
||||
<BaseButton
|
||||
variant="transparent"
|
||||
text="منصرف شدم"
|
||||
custom-class="term-form__btn-cancel"
|
||||
@click="onCancel"
|
||||
>
|
||||
<template #prependIcon>
|
||||
<SvgIcon name="caret-right" :size="14" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
:text="isEditMode ? 'ذخیره تغییرات' : 'تایید اطلاعات'"
|
||||
:loading="submitting"
|
||||
custom-class="term-form__btn-submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="20" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { toast } from 'vue3-toastify'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import ImageCropper from '@/components/form/ImageCropper.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useYup from '@/composables/useYup'
|
||||
import {
|
||||
adminTermsKeys,
|
||||
useAddAdminTermMutation,
|
||||
useAdminTermQuery,
|
||||
useUpdateAdminTermMutation,
|
||||
} from '@/services/query/admin-terms'
|
||||
import { useUploadTemporaryMutation } from '@/services/query/auth'
|
||||
import { termSchema } from '@/features/admin/terms/schema'
|
||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const termId = computed(() => (route.params.id ? Number(route.params.id) : null))
|
||||
const isEditMode = computed(() => !!termId.value)
|
||||
|
||||
const todayIso = new Date().toISOString()
|
||||
|
||||
const form = ref({
|
||||
title: '',
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
description: '',
|
||||
imageId: null,
|
||||
})
|
||||
|
||||
const image = ref(null)
|
||||
|
||||
const schema = termSchema
|
||||
|
||||
const { validate, validateAt, errors } = useYup(schema)
|
||||
|
||||
const { data: existingTerm } = useAdminTermQuery(termId, {
|
||||
enabled: () => !!termId.value,
|
||||
})
|
||||
|
||||
watch(existingTerm, (term) => {
|
||||
if (!term) return
|
||||
form.value = {
|
||||
title: term.title || '',
|
||||
startDate: term.startDate || '',
|
||||
endDate: term.endDate || '',
|
||||
description: term.description || '',
|
||||
imageId: term.imageId || null,
|
||||
}
|
||||
if (term.image) image.value = { url: term.image }
|
||||
})
|
||||
|
||||
const uploadMutation = useUploadTemporaryMutation()
|
||||
|
||||
const onImageCropped = async (file) => {
|
||||
try {
|
||||
const formData = objectToFormData({ file, subType: 'avatar', context: 'term' })
|
||||
const response = await uploadMutation.mutateAsync(formData)
|
||||
const payload = response?.data ?? response
|
||||
image.value = { url: payload?.url, uploadId: payload?.uploadId, ...payload }
|
||||
form.value.imageId = payload?.uploadId || payload?.id
|
||||
} catch {
|
||||
/* handled globally */
|
||||
}
|
||||
}
|
||||
|
||||
const onImageError = (msg) => toast.error(msg)
|
||||
|
||||
const addMutation = useAddAdminTermMutation()
|
||||
const updateMutation = useUpdateAdminTermMutation()
|
||||
|
||||
const submitting = computed(() => addMutation.isPending.value || updateMutation.isPending.value)
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
if (isEditMode.value) {
|
||||
await updateMutation.mutateAsync({ id: termId.value, payload })
|
||||
} else {
|
||||
await addMutation.mutateAsync(payload)
|
||||
}
|
||||
await queryClient.invalidateQueries({ queryKey: adminTermsKeys.all })
|
||||
router.push({ name: 'admin-terms' })
|
||||
}
|
||||
|
||||
const onCancel = () => router.push({ name: 'admin-terms' })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.term-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__form {
|
||||
background: rgba(255, 255, 255, 60%);
|
||||
padding: 1rem;
|
||||
border-radius: 1rem;
|
||||
}
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 1rem;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: 4fr 8fr;
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: 3fr 9fr;
|
||||
}
|
||||
}
|
||||
|
||||
&__image-col {
|
||||
order: 2;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
order: 1;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__main-col {
|
||||
order: 1;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
order: 2;
|
||||
padding-inline-start: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
flex-flow: column wrap;
|
||||
gap: 0.5rem;
|
||||
align-items: stretch;
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
flex-direction: row;
|
||||
}
|
||||
}
|
||||
|
||||
&__cell {
|
||||
width: 100%;
|
||||
|
||||
&--third {
|
||||
@media (min-width: 768px) {
|
||||
width: 49%;
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
width: 32.3%;
|
||||
}
|
||||
}
|
||||
|
||||
&--full {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.5rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
&__btn-submit {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,165 @@
|
||||
<template>
|
||||
<div class="terms-page">
|
||||
<BoxedIconTitleBlock
|
||||
class="terms-page__heading"
|
||||
title="مدیریت ترم"
|
||||
desc="در این قسمت میتوانید ترمهای خود را مدیریت کنید"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="book" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<TermsFilters v-model="filters" @apply="onFilterApply" @reset="onFilterReset" />
|
||||
|
||||
<div class="terms-page__list-header">
|
||||
<SimpleTitleIconBlock title="لیست همه ترمها" class="terms-page__list-title">
|
||||
<template #header-icon>
|
||||
<SvgIcon name="list-bullets" :size="16" color="#bcbcbc" />
|
||||
</template>
|
||||
</SimpleTitleIconBlock>
|
||||
<BaseButton text="افزودن ترم جدید" custom-class="terms-page__add-btn" @click="onAdd">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="plus" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="6" :cols-per-row="1" />
|
||||
<div v-else-if="terms.length > 0">
|
||||
<TermItem
|
||||
v-for="term in terms"
|
||||
:key="term.id"
|
||||
:term="term"
|
||||
@edit="onEdit"
|
||||
@delete="onAskDelete"
|
||||
@clone="onClone"
|
||||
@change-status="onChangeStatus"
|
||||
@show-details="onShowDetails"
|
||||
/>
|
||||
</div>
|
||||
<NoItems v-else title="متاسفیم" desc="ترمی برای نمایش وجود ندارد." />
|
||||
|
||||
<PaginationBlock :pagination="paginationMeta" @update:page="setPage" />
|
||||
|
||||
<TermDetailsModal v-if="isModal('TermDetailsModal')" />
|
||||
<AddTermStudentModal v-if="isModal('AddTermStudentModal')" />
|
||||
<AttachCourseToTermModal v-if="isModal('AttachCourseToTermModal')" />
|
||||
<AddOfferedCourseModal v-if="isModal('AddOfferedCourseModal')" />
|
||||
<CourseDetailsModal v-if="isModal('CourseDetailsModal')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import TermsFilters from '@/features/admin/terms/components/TermsFilters.vue'
|
||||
import TermItem from '@/features/admin/terms/components/TermItem.vue'
|
||||
import TermDetailsModal from '@/features/admin/terms/components/modals/TermDetailsModal.vue'
|
||||
import AddTermStudentModal from '@/features/admin/terms/components/modals/AddTermStudentModal.vue'
|
||||
import AttachCourseToTermModal from '@/features/admin/terms/components/modals/AttachCourseToTermModal.vue'
|
||||
import AddOfferedCourseModal from '@/features/admin/courses/components/modals/AddOfferedCourseModal.vue'
|
||||
import CourseDetailsModal from '@/features/admin/courses/components/modals/CourseDetailsModal.vue'
|
||||
import {
|
||||
adminTermsKeys,
|
||||
useAdminTermsListQuery,
|
||||
useChangeAdminTermStatusMutation,
|
||||
useCloneAdminTermMutation,
|
||||
useDeleteAdminTermMutation,
|
||||
} from '@/services/query/admin-terms'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import useModal from '@/composables/useModal'
|
||||
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
const { openModal, isModal } = useModal()
|
||||
|
||||
const filters = ref({ title: '', status: '', fromDate: '', toDate: '' })
|
||||
const { pagination, setPage, reset: resetPagination } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = useAdminTermsListQuery(filters, pagination, {
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
const terms = computed(() => data.value?.data ?? [])
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const onFilterApply = () => resetPagination()
|
||||
const onFilterReset = () => resetPagination()
|
||||
|
||||
const onAdd = () => {
|
||||
router.push({ name: 'admin-add-term' }).catch(() => {})
|
||||
}
|
||||
|
||||
const onEdit = (term) => {
|
||||
router.push({ name: 'admin-edit-term', params: { id: term.id } }).catch(() => {})
|
||||
}
|
||||
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminTermsKeys.all })
|
||||
|
||||
const deleteMutation = useDeleteAdminTermMutation()
|
||||
const cloneMutation = useCloneAdminTermMutation()
|
||||
const changeStatusMutation = useChangeAdminTermStatusMutation()
|
||||
|
||||
const onAskDelete = (term) => {
|
||||
openModal('ConfirmModal', {
|
||||
title: `حذف ${term.title}`,
|
||||
message: `بعد از حذف امکان بازگشت وجود ندارد، آیا مطمئن هستید که میخواهید <strong>${term.title}</strong> را حذف کنید؟`,
|
||||
onConfirm: () => deleteMutation.mutate(term.id, { onSuccess: invalidate }),
|
||||
})
|
||||
}
|
||||
|
||||
const onClone = (term) => {
|
||||
cloneMutation.mutate(term.id, { onSuccess: invalidate })
|
||||
}
|
||||
|
||||
const onChangeStatus = ({ id, isActive }) => {
|
||||
changeStatusMutation.mutate({ id, payload: { isActive } }, { onSuccess: invalidate })
|
||||
}
|
||||
|
||||
const onShowDetails = (term) => {
|
||||
openModal('TermDetailsModal', { id: term.id })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.terms-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__list-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
margin-bottom: 0.375rem;
|
||||
}
|
||||
|
||||
&__list-title {
|
||||
flex: 1;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&__add-btn {
|
||||
min-width: fit-content;
|
||||
padding: 0 1.25rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,12 @@
|
||||
import { array, mixed, object, string } from 'yup'
|
||||
|
||||
export const termSchema = object().shape({
|
||||
title: string().required().min(3),
|
||||
startDate: string().required(),
|
||||
endDate: string().required(),
|
||||
description: string().nullable().notRequired(),
|
||||
})
|
||||
|
||||
export const addTermStudentSchema = object().shape({
|
||||
studentIds: array().of(mixed()).min(1, 'حداقل یک دانشجو را انتخاب کنید').required(),
|
||||
})
|
||||
@@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<form class="users-filters" @submit.prevent="onSubmit">
|
||||
<div class="users-filters__grid">
|
||||
<TextField v-model="form.name" name="name" label="جستجو اسم کاربر">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="user" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.roleId"
|
||||
name="roleId"
|
||||
label="نقش کاربر"
|
||||
:options="roleOptions"
|
||||
option-label="label"
|
||||
option-value="id"
|
||||
/>
|
||||
<TextField
|
||||
v-model="form.nationalCode"
|
||||
name="nationalCode"
|
||||
label="کد ملی کاربر"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="user" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<TextField
|
||||
v-model="form.phoneNumber"
|
||||
name="phoneNumber"
|
||||
label="شماره همراه کاربر"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="phone" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
</div>
|
||||
|
||||
<div class="users-filters__actions">
|
||||
<CircleButton
|
||||
v-if="hasFilters"
|
||||
tooltip="حذف فیلتر"
|
||||
bg-color="transparent"
|
||||
size="2.5rem"
|
||||
type="button"
|
||||
@click="onReset"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="اعمال فیلتر"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
type="submit"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="funnel" :size="20" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { useAdminRolesListQuery } from '@/services/query/admin-users'
|
||||
import { ROLE_LABELS } from '@/enums'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: () => ({ name: '', nationalCode: '', phoneNumber: '', roleId: '' }),
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'apply', 'reset'])
|
||||
|
||||
const form = ref({ ...props.modelValue })
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(next) => {
|
||||
form.value = { ...next }
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const { data: roles = ref([]) } = useAdminRolesListQuery()
|
||||
const roleOptions = computed(() =>
|
||||
(roles.value ?? []).map((r) => ({ ...r, label: ROLE_LABELS[r.name] || r.name }))
|
||||
)
|
||||
|
||||
const hasFilters = computed(() =>
|
||||
Object.values(form.value).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
)
|
||||
|
||||
const onSubmit = () => {
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('apply', { ...form.value })
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
form.value = { name: '', nationalCode: '', phoneNumber: '', roleId: '' }
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.users-filters {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
|
||||
&__grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding-top: 1.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,366 @@
|
||||
<template>
|
||||
<div class="users-table">
|
||||
<div v-for="user in users" :key="user.id" class="users-table__row">
|
||||
<div class="users-table__avatar">
|
||||
<img v-if="user.avatarUrl" :src="user.avatarUrl" :alt="fullName(user)" />
|
||||
<SvgIcon v-else name="user" :size="36" color="#cbd5e1" />
|
||||
</div>
|
||||
<div class="users-table__info">
|
||||
<p class="users-table__name">{{ fullName(user) || '—' }}</p>
|
||||
<div class="users-table__meta">
|
||||
<span v-if="user.phoneNumber">{{ user.phoneNumber }}</span>
|
||||
<span v-if="user.nationalCode" class="users-table__sep">|</span>
|
||||
<span v-if="user.nationalCode">کد ملی: {{ user.nationalCode }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="users-table__role-badge"
|
||||
:class="`users-table__role-badge--${roleName(user) || 'unknown'}`"
|
||||
:disabled="updateRoleMutation.isPending.value && activeUser?.id === user.id"
|
||||
@click="onRoleClick($event, user)"
|
||||
>
|
||||
<span class="users-table__role-dot" />
|
||||
<span>{{ roleLabel(user) || 'بدون نقش' }}</span>
|
||||
<SvgIcon name="caret-down" :size="12" color="currentColor" />
|
||||
</button>
|
||||
|
||||
<div class="users-table__actions">
|
||||
<button
|
||||
type="button"
|
||||
class="users-table__more"
|
||||
aria-label="گزینههای بیشتر"
|
||||
@click="onMoreClick($event, user)"
|
||||
>
|
||||
<span class="users-table__more-dot" />
|
||||
<span class="users-table__more-dot" />
|
||||
<span class="users-table__more-dot" />
|
||||
</button>
|
||||
<BaseButton
|
||||
text="جزئیات کاربر"
|
||||
custom-class="users-table__details-btn"
|
||||
@click="emit('show-details', user)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DropdownMenu
|
||||
v-model="menuOpen"
|
||||
:reference="menuTrigger"
|
||||
:items="menuItems"
|
||||
placement="bottom-end"
|
||||
/>
|
||||
|
||||
<DropdownMenu
|
||||
v-model="roleMenuOpen"
|
||||
:reference="roleMenuTrigger"
|
||||
:items="roleMenuItems"
|
||||
placement="bottom-end"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import DropdownMenu from '@/components/DropdownMenu.vue'
|
||||
import { CHANGEABLE_ROLES, ROLE_LABELS } from '@/enums'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import {
|
||||
adminUsersKeys,
|
||||
useAdminRolesListQuery,
|
||||
useUpdateAdminUserRoleMutation,
|
||||
} from '@/services/query/admin-users'
|
||||
|
||||
defineProps({
|
||||
users: { type: Array, required: true },
|
||||
})
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const emit = defineEmits([
|
||||
'edit',
|
||||
'delete',
|
||||
'block',
|
||||
'show-details',
|
||||
'show-assignments',
|
||||
'show-exams',
|
||||
'export-pdf',
|
||||
])
|
||||
|
||||
const fullName = (user) => `${user.firstName || ''} ${user.lastName || ''}`.trim()
|
||||
|
||||
const roleName = (user) => {
|
||||
const first = user.roles?.[0]
|
||||
return typeof first === 'string' ? first : first?.name
|
||||
}
|
||||
|
||||
const roleLabel = (user) => {
|
||||
const name = roleName(user)
|
||||
return name ? ROLE_LABELS[name] || name : ''
|
||||
}
|
||||
|
||||
const menuOpen = ref(false)
|
||||
const menuTrigger = ref(null)
|
||||
const activeUser = ref(null)
|
||||
|
||||
const onMoreClick = (event, user) => {
|
||||
const trigger = event.currentTarget
|
||||
if (menuOpen.value && menuTrigger.value === trigger) {
|
||||
menuOpen.value = false
|
||||
return
|
||||
}
|
||||
activeUser.value = user
|
||||
menuTrigger.value = trigger
|
||||
menuOpen.value = true
|
||||
}
|
||||
|
||||
const roleMenuOpen = ref(false)
|
||||
const roleMenuTrigger = ref(null)
|
||||
|
||||
const { data: rolesList = ref([]) } = useAdminRolesListQuery()
|
||||
const roleIdByName = computed(() => {
|
||||
const map = {}
|
||||
;(rolesList.value ?? []).forEach((r) => {
|
||||
if (r?.name) map[r.name] = r.id
|
||||
})
|
||||
return map
|
||||
})
|
||||
|
||||
const updateRoleMutation = useUpdateAdminUserRoleMutation()
|
||||
|
||||
const invalidateUsers = () => queryClient.invalidateQueries({ queryKey: adminUsersKeys.all })
|
||||
|
||||
const onRoleClick = (event, user) => {
|
||||
const trigger = event.currentTarget
|
||||
if (roleMenuOpen.value && roleMenuTrigger.value === trigger) {
|
||||
roleMenuOpen.value = false
|
||||
return
|
||||
}
|
||||
activeUser.value = user
|
||||
roleMenuTrigger.value = trigger
|
||||
roleMenuOpen.value = true
|
||||
}
|
||||
|
||||
const onChangeRole = (targetRoleName) => {
|
||||
const user = activeUser.value
|
||||
if (!user) return
|
||||
const roleId = roleIdByName.value[targetRoleName]
|
||||
const payload = roleId ? { roleId } : { role: targetRoleName }
|
||||
updateRoleMutation.mutate({ id: user.id, payload }, { onSuccess: invalidateUsers })
|
||||
}
|
||||
|
||||
const roleMenuItems = computed(() => {
|
||||
const current = activeUser.value ? roleName(activeUser.value) : null
|
||||
return CHANGEABLE_ROLES.filter((r) => r !== current).map((r) => ({
|
||||
key: `role-${r}`,
|
||||
label: `تغییر به ${ROLE_LABELS[r]}`,
|
||||
icon: 'arrows-clockwise',
|
||||
onClick: () => onChangeRole(r),
|
||||
}))
|
||||
})
|
||||
|
||||
const menuItems = computed(() => [
|
||||
{
|
||||
key: 'edit',
|
||||
label: 'ویرایش',
|
||||
icon: 'pencil',
|
||||
onClick: () => emit('edit', activeUser.value),
|
||||
},
|
||||
{
|
||||
key: 'delete',
|
||||
label: 'حذف',
|
||||
icon: 'trash',
|
||||
onClick: () => emit('delete', activeUser.value),
|
||||
},
|
||||
{
|
||||
key: 'block',
|
||||
label: 'مسدود کردن کاربر',
|
||||
icon: 'close',
|
||||
danger: true,
|
||||
onClick: () => emit('block', activeUser.value),
|
||||
},
|
||||
{
|
||||
key: 'show-assignments',
|
||||
label: 'جزئیات تکلیف',
|
||||
icon: 'file',
|
||||
onClick: () => emit('show-assignments', activeUser.value),
|
||||
},
|
||||
{
|
||||
key: 'show-exams',
|
||||
label: 'جزئیات آزمون',
|
||||
icon: 'file',
|
||||
onClick: () => emit('show-exams', activeUser.value),
|
||||
},
|
||||
{
|
||||
key: 'export-pdf',
|
||||
label: 'خروجی PDF',
|
||||
icon: 'upload',
|
||||
onClick: () => emit('export-pdf', activeUser.value),
|
||||
},
|
||||
])
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.users-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.875rem;
|
||||
padding: 0.75rem 1rem;
|
||||
background: rgba(255, 255, 255, 85%);
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
height: 3rem;
|
||||
width: 3rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
background: #f3f4f6;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
img {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
&__info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 500;
|
||||
font-size: 0.95rem;
|
||||
color: #1f2937;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.375rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: var(--color-prim-gray);
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: var(--color-thd-gray);
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__more {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 3px;
|
||||
width: 2.25rem;
|
||||
height: 2.25rem;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 9999px;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background-color: #f3f4f6;
|
||||
}
|
||||
}
|
||||
|
||||
&__more-dot {
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
border-radius: 9999px;
|
||||
background-color: var(--color-prim-gray);
|
||||
}
|
||||
|
||||
&__details-btn {
|
||||
min-width: fit-content;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
&__role-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
padding: 0.375rem 0.875rem;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 9999px;
|
||||
background: rgba(0, 0, 0, 4%);
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.8rem;
|
||||
color: #4b4b4b;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: background-color 0.15s ease, border-color 0.15s ease;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: rgba(0, 0, 0, 7%);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&--student {
|
||||
color: var(--color-primary);
|
||||
background: rgba(var(--color-primary-rgb, 204, 40, 49), 8%);
|
||||
}
|
||||
|
||||
&--teacher {
|
||||
color: #ff9d00;
|
||||
background: rgba(255, 157, 0, 10%);
|
||||
}
|
||||
|
||||
&--counselor {
|
||||
color: #0048ff;
|
||||
background: rgba(0, 72, 255, 8%);
|
||||
}
|
||||
|
||||
&--missionary {
|
||||
color: var(--color-secondary, #6b6b6b);
|
||||
background: rgba(107, 107, 107, 8%);
|
||||
}
|
||||
|
||||
&--admin {
|
||||
color: #1f2937;
|
||||
background: rgba(31, 41, 55, 8%);
|
||||
}
|
||||
}
|
||||
|
||||
&__role-dot {
|
||||
width: 0.5rem;
|
||||
height: 0.5rem;
|
||||
border-radius: 9999px;
|
||||
background: currentcolor;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,30 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="تکالیف"
|
||||
title-en="Assignments"
|
||||
width="95%"
|
||||
max-width="65rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default>
|
||||
<div class="user-assignments">
|
||||
<NoItems title="بدون تکلیف" desc="این کاربر هنوز تکلیفی ارائه نکرده است." />
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
|
||||
defineOptions({ name: 'UserAssignmentsModal' })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.user-assignments {
|
||||
width: 100%;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,295 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="جزئیات کاربر"
|
||||
title-en="User details"
|
||||
width="95%"
|
||||
max-width="70rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ close }">
|
||||
<div class="user-details">
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="4" :cols-per-row="1" />
|
||||
|
||||
<template v-else-if="user">
|
||||
<div class="user-details__section">
|
||||
<div v-if="isStudent && !user.profileCompleted" class="user-details__notice">
|
||||
<SvgIcon name="warning" :size="20" color="var(--color-primary)" />
|
||||
<span>اطلاعات ثبت نام این دانشجو کامل نیست.</span>
|
||||
</div>
|
||||
|
||||
<div class="user-details__head">
|
||||
<div class="user-details__avatar">
|
||||
<img v-if="user.avatarUrl" :src="user.avatarUrl" :alt="fullName" />
|
||||
<SvgIcon v-else name="user" :size="48" color="#cbd5e1" />
|
||||
</div>
|
||||
<div class="user-details__identity">
|
||||
<div class="user-details__status" :class="statusModifier">
|
||||
<span class="user-details__status-dot" />
|
||||
<span>{{ user.status === 'blocked' ? 'غیر فعال' : 'فعال' }}</span>
|
||||
</div>
|
||||
<p class="user-details__label">نام و نام خانوادگی</p>
|
||||
<p class="user-details__name">{{ fullName || '—' }}</p>
|
||||
<p class="user-details__role">
|
||||
<span class="user-details__role-key">نقش:</span>
|
||||
<span class="user-details__role-val">{{ roleText }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="user-details__grid">
|
||||
<LineInfoBlock
|
||||
title="تاریخ تولد"
|
||||
:numeric-desc="user.faBirthDate || formatJalaaliDate(user.birthDate) || '—'"
|
||||
/>
|
||||
<LineInfoBlock title="شماره تماس" :numeric-desc="user.phoneNumber || '—'" />
|
||||
<LineInfoBlock title="کد ملی" :numeric-desc="user.nationalCode || '—'" />
|
||||
<LineInfoBlock title="وضعیت تاهل" :desc="MARITAL_STATUS[user.maritalStatus] || '—'" />
|
||||
<LineInfoBlock title="جنسیت" :desc="GENDER[user.gender] || '—'" />
|
||||
<LineInfoBlock title="استان" :desc="user.address?.province?.name || '—'" />
|
||||
<LineInfoBlock title="شهر" :desc="user.address?.city?.name || '—'" />
|
||||
</div>
|
||||
|
||||
<LineInfoBlock title="آدرس" :desc="user.address?.address || '—'" />
|
||||
<LineInfoBlock title="بیوگرافی" :desc="user.bio || '—'" />
|
||||
</div>
|
||||
|
||||
<div v-if="isStudent && user.profileCompleted" class="user-details__section">
|
||||
<LineTitleBlock title="اطلاعات تحصیلی و شغلی" title-en="Academic information" />
|
||||
<div class="user-details__grid">
|
||||
<LineInfoBlock
|
||||
title="وضعیت تحصیلی"
|
||||
:desc="EDUCATION_STATUS[user.educationStatus] || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="آخرین مدرک حوزوی"
|
||||
:desc="SEMINARY_LEVEL[user.seminaryLevel] || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="آخرین مدرک دانشگاهی"
|
||||
:desc="UNIVERSITY_LEVEL[user.universityLevel] || '—'"
|
||||
/>
|
||||
<LineInfoBlock title="نام حوزه/دانشگاه" :desc="user.universityName || '—'" />
|
||||
</div>
|
||||
<LineInfoBlock title="گرایش/رشته تحصیلی" :desc="user.fieldOfStudy || '—'" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<NoItems v-else title="یافت نشد" desc="اطلاعات این کاربر در دسترس نیست." />
|
||||
|
||||
<div class="user-details__divider" />
|
||||
<div class="user-details__footer">
|
||||
<BaseButton text="تایید" custom-class="user-details__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { useAdminUserQuery } from '@/services/query/admin-users'
|
||||
import {
|
||||
EDUCATION_STATUS,
|
||||
GENDER,
|
||||
MARITAL_STATUS,
|
||||
ROLE_LABELS,
|
||||
SEMINARY_LEVEL,
|
||||
UNIVERSITY_LEVEL,
|
||||
} from '@/enums'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'UserDetailsModal' })
|
||||
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('UserDetailsModal')?.data ?? {})
|
||||
const userId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const { data: user, isLoading } = useAdminUserQuery(userId, {
|
||||
enabled: () => !!userId.value,
|
||||
})
|
||||
|
||||
const fullName = computed(() =>
|
||||
`${user.value?.firstName || ''} ${user.value?.lastName || ''}`.trim()
|
||||
)
|
||||
|
||||
const roleName = computed(() => {
|
||||
const first = user.value?.roles?.[0]
|
||||
return typeof first === 'string' ? first : first?.name
|
||||
})
|
||||
|
||||
const roleText = computed(() => {
|
||||
const name = roleName.value
|
||||
return name ? ROLE_LABELS[name] || name : 'بدون نقش'
|
||||
})
|
||||
|
||||
const isStudent = computed(() => roleName.value === 'student')
|
||||
|
||||
const statusModifier = computed(() =>
|
||||
user.value?.status === 'blocked'
|
||||
? 'user-details__status--blocked'
|
||||
: 'user-details__status--active'
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.user-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__section {
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
&__notice {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 1rem;
|
||||
margin-bottom: 0.625rem;
|
||||
border-radius: 0.5rem;
|
||||
background-color: rgba(var(--color-primary-rgb, 0, 0, 0), 5%);
|
||||
color: var(--color-primary);
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.875rem;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 5rem;
|
||||
height: 5rem;
|
||||
border-radius: 9999px;
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
&__identity {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.125rem;
|
||||
}
|
||||
|
||||
&__status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
|
||||
&--active {
|
||||
color: #35c245;
|
||||
|
||||
.user-details__status-dot {
|
||||
background-color: #35c245;
|
||||
}
|
||||
}
|
||||
|
||||
&--blocked {
|
||||
color: var(--color-error);
|
||||
|
||||
.user-details__status-dot {
|
||||
background-color: var(--color-error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__status-dot {
|
||||
width: 0.5rem;
|
||||
height: 0.5rem;
|
||||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #b7b7b7;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
font-weight: 500;
|
||||
color: #4b4b4b;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__role {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
margin: 0.25rem 0 0;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 0.375rem;
|
||||
background-color: rgba(0, 0, 0, 4%);
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
&__role-key {
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
&__role-val {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.25rem;
|
||||
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 10rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,30 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="آزمون ها"
|
||||
title-en="Exams"
|
||||
width="95%"
|
||||
max-width="65rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default>
|
||||
<div class="user-exams">
|
||||
<NoItems title="بدون آزمون" desc="این کاربر هنوز در آزمونی شرکت نکرده است." />
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
|
||||
defineOptions({ name: 'UserExamsModal' })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.user-exams {
|
||||
width: 100%;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,252 @@
|
||||
<template>
|
||||
<div class="verification-item">
|
||||
<div class="verification-item__user">
|
||||
<div v-if="user.avatarUrl" class="verification-item__avatar">
|
||||
<img :src="user.avatarUrl" :alt="fullName" />
|
||||
</div>
|
||||
<div v-else class="verification-item__avatar verification-item__avatar--placeholder">
|
||||
<SvgIcon name="user" :size="24" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="verification-item__info">
|
||||
<p class="verification-item__name">{{ fullName }}</p>
|
||||
<p class="verification-item__location">
|
||||
<span>{{ user.address?.province?.name || '—' }}</span>
|
||||
<span class="verification-item__sep">،</span>
|
||||
<span>{{ user.address?.city?.name || '—' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="verification-item__meta">
|
||||
<div class="verification-item__date">
|
||||
<span class="verification-item__date-label">تاریخ ثبت نام:</span>
|
||||
<span class="verification-item__date-value">
|
||||
{{ user.faSubmittedAt || formatJalaaliDate(user.submittedAt) || '—' }}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="user.status === 'pending'"
|
||||
class="verification-item__badge verification-item__badge--pending"
|
||||
>
|
||||
<span class="verification-item__dot" />
|
||||
<span>در انتظار تایید</span>
|
||||
</div>
|
||||
<button
|
||||
v-else-if="user.status === 'rejected'"
|
||||
type="button"
|
||||
class="verification-item__badge verification-item__badge--rejected"
|
||||
@click="emit('show-reject-reason', user)"
|
||||
>
|
||||
<span class="verification-item__dot" />
|
||||
<span>رد شده</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="verification-item__actions">
|
||||
<CircleButton
|
||||
tooltip="تایید"
|
||||
bg-color="rgba(0, 154, 18, 0.08)"
|
||||
size="2.5rem"
|
||||
@click="emit('verify-user', { id: user.id, status: 'approved' })"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="check" :size="20" color="var(--color-secondary)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
v-if="user.status !== 'rejected'"
|
||||
tooltip="عدم تایید"
|
||||
bg-color="rgba(204, 40, 49, 0.08)"
|
||||
size="2.5rem"
|
||||
@click="emit('verify-user', { id: user.id, status: 'rejected' })"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<BaseButton
|
||||
custom-class="verification-item__details-btn"
|
||||
text="جزئیات احراز هویت"
|
||||
:loading="detailsLoading"
|
||||
@click="emit('show-details', user.id)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
const props = defineProps({
|
||||
user: { type: Object, required: true },
|
||||
detailsLoading: { type: Boolean, default: false },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['show-details', 'show-reject-reason', 'verify-user'])
|
||||
|
||||
const fullName = computed(
|
||||
() => `${props.user.firstName || ''} ${props.user.lastName || ''}`.trim() || '—'
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.verification-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: 768px) {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__user {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
flex: 1 1 33%;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
height: 3rem;
|
||||
width: 3rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #eee;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 400;
|
||||
font-size: 1rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__location {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 300;
|
||||
color: #848484;
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: #c4c4c4;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 33%;
|
||||
}
|
||||
|
||||
&__date {
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
padding: 0.25rem 1rem;
|
||||
border-radius: 0.875rem;
|
||||
white-space: nowrap;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
&__date-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 300;
|
||||
font-size: 0.75rem;
|
||||
color: #848484;
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__date-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
&__badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
padding: 0.25rem 1rem;
|
||||
border-radius: 0.875rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
line-height: 1.5;
|
||||
border: none;
|
||||
cursor: default;
|
||||
|
||||
&--pending {
|
||||
background: rgba(0, 255, 68, 6%);
|
||||
color: #009a12;
|
||||
}
|
||||
|
||||
&--rejected {
|
||||
background: rgba(204, 40, 49, 6%);
|
||||
color: var(--color-error);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
&__dot {
|
||||
width: 0.375rem;
|
||||
height: 0.375rem;
|
||||
border-radius: 9999px;
|
||||
background: currentcolor;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 33%;
|
||||
}
|
||||
|
||||
&__details-btn {
|
||||
min-width: 9rem;
|
||||
padding: 0 0.625rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<form class="verifications-filters" @submit.prevent="onSubmit">
|
||||
<div class="verifications-filters__grid">
|
||||
<TextField v-model="form.name" name="name" label="جستجو اسم کاربر">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="user" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<TextField
|
||||
v-model="form.nationalCode"
|
||||
name="nationalCode"
|
||||
label="کد ملی کاربر"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="user" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<DatePickerField v-model="form.fromDate" name="fromDate" label="از تاریخ" :max="todayIso" />
|
||||
<DatePickerField v-model="form.toDate" name="toDate" label="تا تاریخ" :max="todayIso" />
|
||||
</div>
|
||||
|
||||
<div class="verifications-filters__actions">
|
||||
<CircleButton
|
||||
v-if="hasFilters"
|
||||
tooltip="حذف فیلتر"
|
||||
bg-color="transparent"
|
||||
size="2.5rem"
|
||||
type="button"
|
||||
@click="onReset"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="اعمال فیلتر"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
type="submit"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="funnel" :size="20" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: () => ({ name: '', nationalCode: '', fromDate: '', toDate: '' }),
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'apply', 'reset'])
|
||||
|
||||
const emptyForm = () => ({ name: '', nationalCode: '', fromDate: '', toDate: '' })
|
||||
|
||||
const form = ref({ ...emptyForm(), ...props.modelValue })
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(next) => {
|
||||
form.value = { ...emptyForm(), ...next }
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const todayIso = new Date().toISOString()
|
||||
|
||||
const hasFilters = computed(() =>
|
||||
Object.values(form.value).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
)
|
||||
|
||||
const onSubmit = () => {
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('apply', { ...form.value })
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
form.value = emptyForm()
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.verifications-filters {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
|
||||
&__grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding-top: 1.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="جزئیات رد"
|
||||
title-en="Details for Rejection"
|
||||
width="95%"
|
||||
max-width="50rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ data, close }">
|
||||
<div class="reject-reason-details">
|
||||
<div class="reject-reason-details__grid">
|
||||
<div class="reject-reason-details__cell--full">
|
||||
<LineInfoBlock title="توضیحات" :desc="verification(data).adminNote || ''" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="reject-reason-details__actions">
|
||||
<BaseButton text="بسیار خب" custom-class="reject-reason-details__btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
|
||||
defineOptions({ name: 'RejectReasonDetailsModal' })
|
||||
|
||||
const verification = (data) => data?.verification || {}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.reject-reason-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.25rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__cell--full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
&__btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,154 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="علت رد"
|
||||
title-en="Reason for Rejection"
|
||||
width="95%"
|
||||
max-width="50rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ data, close }">
|
||||
<form class="reject-reason-modal" @submit.prevent="onSubmit(data, close)">
|
||||
<div class="reject-reason-modal__row">
|
||||
<TextField
|
||||
v-model="form.rejectionReason"
|
||||
name="rejectionReason"
|
||||
label="علت رد"
|
||||
:error="errors.rejectionReason"
|
||||
@blur="validateAt('rejectionReason', form.rejectionReason)"
|
||||
/>
|
||||
<SelectField
|
||||
:model-value="form.priority?.id"
|
||||
name="priority"
|
||||
label="وضعیت تیکت"
|
||||
:options="statusOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:error="errors.priority"
|
||||
@update:model-value="(e) => handleChange('priority', { id: e })"
|
||||
/>
|
||||
</div>
|
||||
<TextareaField
|
||||
v-model="form.adminNote"
|
||||
name="adminNote"
|
||||
label="لطفا علت رد را توضیح دهید"
|
||||
:row="4"
|
||||
:error="errors.adminNote"
|
||||
/>
|
||||
|
||||
<div class="reject-reason-modal__divider" />
|
||||
|
||||
<div class="reject-reason-modal__actions">
|
||||
<BaseButton
|
||||
variant="transparent"
|
||||
text="منصرف شدم"
|
||||
custom-class="reject-reason-modal__btn-cancel"
|
||||
@click="close"
|
||||
>
|
||||
<template #prependIcon>
|
||||
<SvgIcon name="caret-right" :size="14" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
text="ارسال"
|
||||
:loading="changeStatusMutation.isPending.value"
|
||||
custom-class="reject-reason-modal__btn-submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useYup from '@/composables/useYup'
|
||||
import {
|
||||
adminPendingStudentsKeys,
|
||||
useChangePendingStudentStatusMutation,
|
||||
} from '@/services/query/admin-pending-students'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import { PRIORITY_STATUS } from '@/enums'
|
||||
import { rejectionReasonSchema } from '../../../schema'
|
||||
|
||||
defineOptions({ name: 'RejectReasonModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const changeStatusMutation = useChangePendingStudentStatusMutation()
|
||||
|
||||
const DEFAULT_FORM = { rejectionReason: '', adminNote: '' }
|
||||
|
||||
const { validate, validateAt, errors, resetErrors } = useYup(rejectionReasonSchema)
|
||||
|
||||
const form = ref(structuredClone({ ...DEFAULT_FORM }))
|
||||
|
||||
const statusOptions = Object.entries(PRIORITY_STATUS).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
|
||||
const handleChange = (key, value) => {
|
||||
form.value = { ...form.value, [key]: value }
|
||||
validateAt(key, value)
|
||||
}
|
||||
|
||||
const onSubmit = async (data, close) => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
console.log(errors)
|
||||
|
||||
if (!isValid) return
|
||||
const id = data?.id
|
||||
if (!id) return
|
||||
await changeStatusMutation.mutateAsync({
|
||||
id,
|
||||
payload: { status: 'rejected', ...payload },
|
||||
})
|
||||
await queryClient.invalidateQueries({ queryKey: adminPendingStudentsKeys.all })
|
||||
form.value = structuredClone({ ...DEFAULT_FORM })
|
||||
resetErrors()
|
||||
close()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.reject-reason-modal {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
padding: 0.5rem;
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
&__btn-submit {
|
||||
min-width: 9rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+491
@@ -0,0 +1,491 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="اطلاعات شخصی"
|
||||
title-en="Personal information"
|
||||
width="95%"
|
||||
max-width="80rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ data, close }">
|
||||
<div v-if="!user" class="user-verification-details">
|
||||
<p class="user-verification-details__loading">در حال بارگذاری…</p>
|
||||
</div>
|
||||
<div v-else class="user-verification-details">
|
||||
<section class="user-verification-details__section">
|
||||
<div class="user-verification-details__grid user-verification-details__grid--6">
|
||||
<LineInfoBlock title="نام و نام خانوادگی" :numeric-desc="fullName" />
|
||||
<LineInfoBlock
|
||||
title="تاریخ تولد"
|
||||
:numeric-desc="profile.faBirthDate || formatJalaaliDate(profile.birthDate) || ''"
|
||||
/>
|
||||
<LineInfoBlock title="شماره تماس" :numeric-desc="user.phoneNumber" />
|
||||
<LineInfoBlock title="کد ملی" :numeric-desc="user.nationalCode" />
|
||||
<LineInfoBlock
|
||||
title="وضعیت تاهل"
|
||||
:desc="profile.faMaritalStatus || MARITAL_STATUS[profile.maritalStatus] || ''"
|
||||
/>
|
||||
<LineInfoBlock title="جنسیت" :desc="profile.faGender || GENDER[profile.gender] || ''" />
|
||||
<LineInfoBlock title="استان" :desc="user.address?.province?.name || '-'" />
|
||||
<LineInfoBlock title="شهر" :desc="user.address?.city?.name || '-'" />
|
||||
<div class="user-verification-details__cell user-verification-details__cell--span-3">
|
||||
<LineInfoBlock title="آدرس" :desc="user.address?.address || '-'" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="user-verification-details__section">
|
||||
<LineTitleBlock title="اطلاعات تحصیلی" title-en="Academic information" />
|
||||
<div class="user-verification-details__grid user-verification-details__grid--4">
|
||||
<LineInfoBlock
|
||||
title="وضعیت تحصیلی"
|
||||
:desc="profile.faEducationStatus || EDUCATION_STATUS[profile.educationStatus] || ''"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="آخرین مدرک تحصیلی (طلبه)"
|
||||
:desc="profile.faSeminaryLevel || SEMINARY_LEVEL[profile.seminaryLevel] || ''"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="آخرین مدرک تحصیلی"
|
||||
:desc="profile.faUniversityLevel || UNIVERSITY_LEVEL[profile.universityLevel] || ''"
|
||||
/>
|
||||
<LineInfoBlock title="نام حوزه علمیه/دانشگاه" :desc="profile.universityName || ''" />
|
||||
<div class="user-verification-details__cell user-verification-details__cell--full">
|
||||
<LineInfoBlock
|
||||
title="گرایش تخصصی حوزوی / رشته تحصیلی دانشگاهی"
|
||||
:desc="profile.fieldOfStudy || ''"
|
||||
/>
|
||||
</div>
|
||||
<div class="user-verification-details__cell user-verification-details__cell--full">
|
||||
<LineInfoBlock
|
||||
title="خلاصهای از سوابق شغلی"
|
||||
:desc="profile.workExperienceSummary || ''"
|
||||
/>
|
||||
</div>
|
||||
<div class="user-verification-details__cell user-verification-details__cell--full">
|
||||
<LineInfoBlock
|
||||
title="خلاصهای از فعالیتها در موقعیتهای شغلی"
|
||||
:desc="profile.activitySummary || ''"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="user-verification-details__section">
|
||||
<LineTitleBlock title="اطلاعات شغلی" title-en="Job information" />
|
||||
<div class="user-verification-details__grid user-verification-details__grid--4">
|
||||
<div class="user-verification-details__cell user-verification-details__cell--full">
|
||||
<LineInfoBlock
|
||||
title="گرایش تخصصی حوزوی / رشته تحصیلی دانشگاهی"
|
||||
:desc="profile.fieldOfStudy || ''"
|
||||
/>
|
||||
</div>
|
||||
<div class="user-verification-details__cell user-verification-details__cell--full">
|
||||
<LineInfoBlock
|
||||
title="خلاصهای از سوابق شغلی"
|
||||
:desc="profile.workExperienceSummary || ''"
|
||||
/>
|
||||
</div>
|
||||
<div class="user-verification-details__cell user-verification-details__cell--full">
|
||||
<LineInfoBlock
|
||||
title="خلاصهای از فعالیتها در موقعیتهای شغلی"
|
||||
:desc="profile.activitySummary || ''"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="user-verification-details__section">
|
||||
<LineTitleBlock
|
||||
title="اطلاعات فعالیت تبلیغاتی و حرفهای"
|
||||
title-en="Advertising and professional activity information"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="سابقه فعالیت تبلیغی شما چند سال میباشد؟"
|
||||
:numeric-desc="profile.propagationExperienceYears ?? ''"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="توضیحات مدل فعالیت تبلیغی"
|
||||
:desc="profile.propagationMethodDescription || ''"
|
||||
/>
|
||||
<LineInfoBlock title="موضوعات تخصصی تبلیغی" :desc="profile.specializedTopics || ''" />
|
||||
<LineInfoBlock title="بسترهای فعالیت تبلیغی" :desc="platformsLabel" />
|
||||
<LineInfoBlock
|
||||
v-if="otherPlatformDetails"
|
||||
title="توضیح فعالیت در سایر فضاهای تبلیغی"
|
||||
:desc="otherPlatformDetails"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
v-if="onlinePlatformDetails"
|
||||
title="نام شبکه و مدل فعالیت تبلیغی"
|
||||
:desc="onlinePlatformDetails"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section class="user-verification-details__section">
|
||||
<LineTitleBlock title="مهارتها و تخصصها (1)" title-en="Skills and Specialties" />
|
||||
<LineInfoBlock
|
||||
title="عملکرد در شرایط رضایت پایین مخاطبین"
|
||||
:desc="LOW_SATISFACTION_RESPONSE[profile.responseToLowSatisfaction] || ''"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
v-if="profile.responseToLowSatisfactionDescription"
|
||||
title="توضیح گزینه «سایر»"
|
||||
:desc="profile.responseToLowSatisfactionDescription"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section class="user-verification-details__section">
|
||||
<LineTitleBlock title="مهارتها و تخصصها (2)" title-en="Skills and Specialties" />
|
||||
<LineInfoBlock
|
||||
title="مواجهه با تعطیلی جلسه به دلیل هزینه"
|
||||
:desc="SESSION_CANCELLATION_RESPONSE[profile.responseToSessionCancellation] || ''"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
v-if="profile.responseToSessionCancellationDescription"
|
||||
title="توضیح گزینه «سایر»"
|
||||
:desc="profile.responseToSessionCancellationDescription"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section class="user-verification-details__section">
|
||||
<LineTitleBlock title="مهارتها و تخصصها (3)" title-en="Skills and Specialties" />
|
||||
<LineInfoBlock
|
||||
title="مواجهه با تناقض درخواست مخاطبین"
|
||||
:desc="AUDIENCE_CONFLICT_RESPONSE[profile.responseToAudienceConflict] || ''"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
v-if="profile.responseToAudienceConflictDescription"
|
||||
title="توضیح گزینه «سایر»"
|
||||
:desc="profile.responseToAudienceConflictDescription"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section class="user-verification-details__section">
|
||||
<LineTitleBlock title="مهارتها و تخصصها (4)" title-en="Skills and Specialties" />
|
||||
<LineInfoBlock
|
||||
title="مواجهه با مبلغه رقیب"
|
||||
:desc="COMPETING_PROPAGATOR_RESPONSE[profile.responseToCompetingPropagator] || ''"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
v-if="profile.responseToCompetingPropagatorDescription"
|
||||
title="توضیح گزینه «سایر»"
|
||||
:desc="profile.responseToCompetingPropagatorDescription"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section class="user-verification-details__section">
|
||||
<LineTitleBlock title="مهارتها و تخصصها (5)" title-en="Skills and Specialties" />
|
||||
<LineInfoBlock
|
||||
title="مواجهه با مدعیان نسخههای دینی"
|
||||
:desc="profile.responseToUnqualifiedAdvisors || ''"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="مدارک و گواهینامههای مرتبط"
|
||||
:desc="profile.relevantCertificates || ''"
|
||||
/>
|
||||
<LineInfoBlock title="مواجهه با موضوع حجاب" :desc="profile.hijabApproach || ''" />
|
||||
</section>
|
||||
|
||||
<section v-if="faithProduction?.url" class="user-verification-details__section">
|
||||
<LineTitleBlock title="بخش صوت" title-en="Audio section" />
|
||||
<LineInfoBlock title="نظر و تحلیل از ویدئو ارائه شده" />
|
||||
<audio :src="faithProduction.url" controls class="user-verification-details__audio" />
|
||||
</section>
|
||||
|
||||
<section v-if="leaderMessage?.url" class="user-verification-details__section">
|
||||
<LineTitleBlock title="بخش تصویر" title-en="Video section" />
|
||||
<LineInfoBlock title="درک و برداشت از پیام رهبری" />
|
||||
<video
|
||||
:src="leaderMessage.url"
|
||||
controls
|
||||
playsinline
|
||||
class="user-verification-details__video"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<div class="user-verification-details__divider" />
|
||||
|
||||
<div class="user-verification-details__actions">
|
||||
<BaseButton
|
||||
text="ذخیره به صورت PDF"
|
||||
:loading="pdfLoading"
|
||||
custom-class="user-verification-details__pdf-btn"
|
||||
@click="onSaveAsPdf(data, close)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import {
|
||||
AUDIENCE_CONFLICT_RESPONSE,
|
||||
COMPETING_PROPAGATOR_RESPONSE,
|
||||
EDUCATION_STATUS,
|
||||
GENDER,
|
||||
LOW_SATISFACTION_RESPONSE,
|
||||
MARITAL_STATUS,
|
||||
PROPAGATION_PLATFORM,
|
||||
SEMINARY_LEVEL,
|
||||
SESSION_CANCELLATION_RESPONSE,
|
||||
UNIVERSITY_LEVEL,
|
||||
USER_STATUS,
|
||||
VERIFICATION_MEDIA_TYPE,
|
||||
} from '@/enums'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
import {
|
||||
usePendingStudentQuery,
|
||||
useDownloadPendingStudentPdfMutation,
|
||||
} from '@/services/query/admin-pending-students'
|
||||
|
||||
defineOptions({ name: 'UserVerificationDetailsModal' })
|
||||
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('UserVerificationDetailsModal')?.data ?? {})
|
||||
const userId = computed(() => modalData.value.id ?? null)
|
||||
const userIdRef = computed(() => userId.value)
|
||||
|
||||
const { data: fetched } = usePendingStudentQuery(userIdRef, {
|
||||
enabled: () => !!userIdRef.value,
|
||||
})
|
||||
|
||||
const user = computed(() => modalData.value.user || fetched.value || null)
|
||||
const profile = computed(() => user.value?.profile || {})
|
||||
const fullName = computed(
|
||||
() => `${user.value?.firstName || ''} ${user.value?.lastName || ''}`.trim() || '—'
|
||||
)
|
||||
|
||||
const platforms = computed(() =>
|
||||
Array.isArray(profile.value.propagationPlatforms) ? profile.value.propagationPlatforms : []
|
||||
)
|
||||
|
||||
const platformsLabel = computed(() =>
|
||||
platforms.value
|
||||
.map((p) => PROPAGATION_PLATFORM[p.platform] || p.platform)
|
||||
.filter(Boolean)
|
||||
.join(' ، ')
|
||||
)
|
||||
|
||||
const otherPlatformDetails = computed(
|
||||
() => platforms.value.find((p) => p.platform === 'other')?.platformDetails || ''
|
||||
)
|
||||
const onlinePlatformDetails = computed(
|
||||
() => platforms.value.find((p) => p.platform === 'online')?.platformDetails || ''
|
||||
)
|
||||
|
||||
const verificationMedia = computed(() => user.value?.verification?.media || [])
|
||||
const faithProduction = computed(() =>
|
||||
verificationMedia.value.find((m) => m.type === VERIFICATION_MEDIA_TYPE.FAITH_PRODUCTION)
|
||||
)
|
||||
const leaderMessage = computed(() =>
|
||||
verificationMedia.value.find((m) => m.type === VERIFICATION_MEDIA_TYPE.LEADER_MESSAGE)
|
||||
)
|
||||
|
||||
const statusLabel = (status) => {
|
||||
if (status === 'pending') return 'در انتظار تایید'
|
||||
if (status === 'rejected') return 'رد شده'
|
||||
return USER_STATUS[status] || status || ''
|
||||
}
|
||||
|
||||
const pdfLoading = ref(false)
|
||||
const pdfMutation = useDownloadPendingStudentPdfMutation()
|
||||
|
||||
const onSaveAsPdf = async (data, close) => {
|
||||
if (!user.value?.id) return
|
||||
pdfLoading.value = true
|
||||
try {
|
||||
const response = await pdfMutation.mutateAsync(user.value.id)
|
||||
const url = response?.data?.downloadUrl || response?.downloadUrl
|
||||
if (url) {
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.target = '_blank'
|
||||
link.download = 'profile.pdf'
|
||||
document.body.append(link)
|
||||
link.click()
|
||||
link.remove()
|
||||
}
|
||||
close()
|
||||
} finally {
|
||||
pdfLoading.value = false
|
||||
}
|
||||
data
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.user-verification-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__loading {
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
color: var(--color-prim-gray);
|
||||
}
|
||||
|
||||
&__section {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.25rem;
|
||||
|
||||
&--4 {
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&--6 {
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(6, 1fr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__cell {
|
||||
&--span-2 {
|
||||
@media (min-width: 768px) {
|
||||
grid-column: span 2;
|
||||
}
|
||||
}
|
||||
|
||||
&--span-3 {
|
||||
@media (min-width: 768px) {
|
||||
grid-column: span 3;
|
||||
}
|
||||
}
|
||||
|
||||
&--full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
}
|
||||
|
||||
&__person {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
height: 6rem;
|
||||
width: 6rem;
|
||||
min-width: 6rem;
|
||||
border-radius: 9999px;
|
||||
border: 1px solid #eee;
|
||||
overflow: hidden;
|
||||
|
||||
img {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__person-info {
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
&__person-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #b7b7b7;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__person-name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 500;
|
||||
font-size: 0.875rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0.25rem 0;
|
||||
}
|
||||
|
||||
&__status-badge {
|
||||
display: inline-block;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 0.375rem;
|
||||
font-size: 0.75rem;
|
||||
margin: 0;
|
||||
|
||||
&--pending {
|
||||
background: rgba(0, 255, 68, 6%);
|
||||
}
|
||||
|
||||
&--rejected {
|
||||
background: rgba(204, 40, 49, 6%);
|
||||
}
|
||||
}
|
||||
|
||||
&__status-label {
|
||||
color: #808080;
|
||||
padding-inline: 0.125rem;
|
||||
}
|
||||
|
||||
&__status-value {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 500;
|
||||
font-size: 0.875rem;
|
||||
padding-inline: 0.125rem;
|
||||
|
||||
/* stylelint-disable-next-line selector-class-pattern */
|
||||
.user-verification-details__status-badge--pending & {
|
||||
color: #009a12;
|
||||
}
|
||||
|
||||
/* stylelint-disable-next-line selector-class-pattern */
|
||||
.user-verification-details__status-badge--rejected & {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
&__audio,
|
||||
&__video {
|
||||
width: 100%;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.5rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__pdf-btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,486 @@
|
||||
<template>
|
||||
<div class="user-form">
|
||||
<BoxedIconTitleBlock
|
||||
class="user-form__heading"
|
||||
:title="isEditMode ? 'ویرایش کاربر' : 'افزودن کاربر جدید'"
|
||||
:desc="
|
||||
isEditMode ? 'اطلاعات کاربر را بهروز کنید' : 'در این قسمت میتوانید کاربر جدید اضافه کنید'
|
||||
"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="user" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<form class="user-form__form" @submit.prevent="onSubmit">
|
||||
<div class="user-form__grid">
|
||||
<div class="user-form__avatar-col">
|
||||
<ImageCropper
|
||||
v-model="avatar"
|
||||
name="avatar"
|
||||
bg-color="#eeeeee"
|
||||
@crop="onAvatarCropped"
|
||||
@error="onAvatarError"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="user-form__main-col">
|
||||
<LineTitleBlock title="مشخصات فردی" title-en="Personal Details" />
|
||||
<div class="user-form__row">
|
||||
<div class="user-form__cell user-form__cell--third">
|
||||
<SelectField
|
||||
v-model="form.roleId"
|
||||
name="roleId"
|
||||
label="نقش"
|
||||
:options="roleOptions"
|
||||
option-label="label"
|
||||
option-value="id"
|
||||
:error="errors.roleId"
|
||||
@change="validateAt('roleId', form.roleId)"
|
||||
/>
|
||||
</div>
|
||||
<div class="user-form__cell user-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.firstName"
|
||||
name="firstName"
|
||||
label="نام"
|
||||
:error="errors.firstName"
|
||||
@blur="validateAt('firstName', form.firstName)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="user" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
</div>
|
||||
<div class="user-form__cell user-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.lastName"
|
||||
name="lastName"
|
||||
label="نام خانوادگی"
|
||||
:error="errors.lastName"
|
||||
@blur="validateAt('lastName', form.lastName)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="user" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
</div>
|
||||
<div class="user-form__cell user-form__cell--third">
|
||||
<DatePickerField
|
||||
v-model="form.birthDate"
|
||||
name="birthDate"
|
||||
label="تاریخ تولد"
|
||||
:max="todayIso"
|
||||
:error="errors.birthDate"
|
||||
/>
|
||||
</div>
|
||||
<div class="user-form__cell user-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.nationalCode"
|
||||
name="nationalCode"
|
||||
label="کد ملی"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
:disabled="isEditMode && !!initialNationalCode"
|
||||
:error="errors.nationalCode"
|
||||
@blur="validateAt('nationalCode', form.nationalCode)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="user" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
</div>
|
||||
<div class="user-form__cell user-form__cell--third">
|
||||
<SelectField
|
||||
v-model="form.maritalStatus"
|
||||
name="maritalStatus"
|
||||
label="وضعیت تاهل"
|
||||
:options="maritalStatusOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
/>
|
||||
</div>
|
||||
<div class="user-form__cell user-form__cell--third">
|
||||
<SelectField
|
||||
v-model="form.gender"
|
||||
name="gender"
|
||||
label="جنسیت"
|
||||
:options="genderOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
/>
|
||||
</div>
|
||||
<div class="user-form__cell user-form__cell--full">
|
||||
<TextareaField
|
||||
v-model="form.bio"
|
||||
name="bio"
|
||||
label="زندگی نامه"
|
||||
:row="3"
|
||||
:error="errors.bio"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<LineTitleBlock title="اطلاعات تماس" title-en="Contact Details" />
|
||||
<div class="user-form__row">
|
||||
<div class="user-form__cell user-form__cell--third">
|
||||
<TextField
|
||||
v-model="form.phoneNumber"
|
||||
name="phoneNumber"
|
||||
label="شماره تلفن همراه"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
:error="errors.phoneNumber"
|
||||
@blur="validateAt('phoneNumber', form.phoneNumber)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="phone" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
</div>
|
||||
<div class="user-form__cell user-form__cell--third">
|
||||
<SelectField
|
||||
v-model="form.provinceId"
|
||||
name="provinceId"
|
||||
label="استان"
|
||||
:options="provinces"
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
@change="onProvinceChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="user-form__cell user-form__cell--third">
|
||||
<SelectField
|
||||
v-model="form.cityId"
|
||||
name="cityId"
|
||||
label="شهر"
|
||||
:options="cities"
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
:disabled="!form.provinceId"
|
||||
/>
|
||||
</div>
|
||||
<div class="user-form__cell user-form__cell--full">
|
||||
<TextareaField
|
||||
v-model="form.address"
|
||||
name="address"
|
||||
label="آدرس محل سکونت"
|
||||
:row="isMobile ? 5 : 2"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="!isEditMode">
|
||||
<LineTitleBlock title="رمز عبور" title-en="Password" />
|
||||
<div class="user-form__row">
|
||||
<div class="user-form__cell user-form__cell--half">
|
||||
<PasswordField
|
||||
v-model="form.password"
|
||||
name="password"
|
||||
label="رمز عبور"
|
||||
:error="errors.password"
|
||||
@blur="validateAt('password', form.password)"
|
||||
/>
|
||||
</div>
|
||||
<div class="user-form__cell user-form__cell--half">
|
||||
<PasswordField
|
||||
v-model="form.passwordConfirmation"
|
||||
name="passwordConfirmation"
|
||||
label="تکرار رمز عبور"
|
||||
:error="errors.passwordConfirmation"
|
||||
@blur="validateAt('passwordConfirmation', form.passwordConfirmation)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="user-form__actions">
|
||||
<BaseButton
|
||||
variant="transparent"
|
||||
text="انصراف"
|
||||
custom-class="user-form__btn-cancel"
|
||||
@click="onCancel"
|
||||
/>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
:text="isEditMode ? 'ذخیره تغییرات' : 'ثبت کاربر'"
|
||||
:loading="submitting"
|
||||
custom-class="user-form__btn-submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="20" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { toast } from 'vue3-toastify'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import PasswordField from '@/components/form/PasswordField.vue'
|
||||
import ImageCropper from '@/components/form/ImageCropper.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useYup from '@/composables/useYup'
|
||||
import {
|
||||
adminUsersKeys,
|
||||
useAddAdminUserMutation,
|
||||
useAdminRolesListQuery,
|
||||
useAdminUserQuery,
|
||||
useUpdateAdminUserMutation,
|
||||
} from '@/services/query/admin-users'
|
||||
import { useGetCitiesOfProvinceQuery, useGetProvincesQuery } from '@/services/query/common'
|
||||
import { useUploadTemporaryMutation } from '@/services/query/auth'
|
||||
import { GENDER, MARITAL_STATUS, ROLE_LABELS } from '@/enums'
|
||||
import { userAddSchema, userEditSchema } from '@/features/admin/users/schema'
|
||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const userId = computed(() => (route.params.id ? Number(route.params.id) : null))
|
||||
const isEditMode = computed(() => !!userId.value)
|
||||
|
||||
const isMobile = ref(window.innerWidth < 1024)
|
||||
const onResize = () => {
|
||||
isMobile.value = window.innerWidth < 1024
|
||||
}
|
||||
onMounted(() => window.addEventListener('resize', onResize))
|
||||
onBeforeUnmount(() => window.removeEventListener('resize', onResize))
|
||||
|
||||
const todayIso = new Date().toISOString()
|
||||
|
||||
const maritalStatusOptions = Object.entries(MARITAL_STATUS).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
const genderOptions = Object.entries(GENDER).map(([value, label]) => ({ value, label }))
|
||||
|
||||
const { data: roles = ref([]) } = useAdminRolesListQuery()
|
||||
const roleOptions = computed(() =>
|
||||
(roles.value ?? []).map((r) => ({ ...r, label: ROLE_LABELS[r.name] || r.name }))
|
||||
)
|
||||
const { data: provinces = ref([]) } = useGetProvincesQuery()
|
||||
|
||||
const provinceIdRef = ref(null)
|
||||
const { data: cities = ref([]) } = useGetCitiesOfProvinceQuery(provinceIdRef, {
|
||||
enabled: () => !!provinceIdRef.value,
|
||||
})
|
||||
|
||||
const initialNationalCode = ref('')
|
||||
|
||||
const form = ref({
|
||||
roleId: '',
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
birthDate: '',
|
||||
nationalCode: '',
|
||||
maritalStatus: '',
|
||||
gender: '',
|
||||
bio: '',
|
||||
phoneNumber: '',
|
||||
provinceId: '',
|
||||
cityId: '',
|
||||
address: '',
|
||||
avatarId: null,
|
||||
password: '',
|
||||
passwordConfirmation: '',
|
||||
})
|
||||
|
||||
const avatar = ref(null)
|
||||
|
||||
const schema = isEditMode.value ? userEditSchema : userAddSchema
|
||||
|
||||
const { validate, validateAt, errors } = useYup(schema)
|
||||
|
||||
const onProvinceChange = () => {
|
||||
provinceIdRef.value = form.value.provinceId
|
||||
form.value.cityId = ''
|
||||
}
|
||||
|
||||
watch(
|
||||
() => form.value.provinceId,
|
||||
(val) => {
|
||||
provinceIdRef.value = val
|
||||
}
|
||||
)
|
||||
|
||||
const { data: existingUser } = useAdminUserQuery(userId, {
|
||||
enabled: () => !!userId.value,
|
||||
})
|
||||
|
||||
watch(existingUser, (user) => {
|
||||
if (!user) return
|
||||
const firstRole = Array.isArray(user.roles) ? user.roles[0] : null
|
||||
const firstRoleId = typeof firstRole === 'object' ? firstRole?.id : null
|
||||
form.value = {
|
||||
...form.value,
|
||||
roleId: user.roleId || user.profile?.roleId || firstRoleId || '',
|
||||
firstName: user.firstName || '',
|
||||
lastName: user.lastName || '',
|
||||
birthDate: user.profile?.birthDate || '',
|
||||
nationalCode: user.nationalCode || '',
|
||||
maritalStatus: user.profile?.maritalStatus || '',
|
||||
gender: user.profile?.gender || '',
|
||||
bio: user.profile?.bio || '',
|
||||
phoneNumber: user.phoneNumber || '',
|
||||
provinceId: user.address?.province?.id || '',
|
||||
cityId: user.address?.city?.id || '',
|
||||
address: user.address?.address || '',
|
||||
avatarId: user.profile?.avatarId || null,
|
||||
}
|
||||
initialNationalCode.value = user.nationalCode || ''
|
||||
if (user.avatarUrl) {
|
||||
avatar.value = { url: user.avatarUrl }
|
||||
}
|
||||
})
|
||||
|
||||
const uploadMutation = useUploadTemporaryMutation()
|
||||
|
||||
const onAvatarCropped = async (file) => {
|
||||
try {
|
||||
const formData = objectToFormData({ file, subType: 'avatar', context: 'user' })
|
||||
const response = await uploadMutation.mutateAsync(formData)
|
||||
const payload = response?.data ?? response
|
||||
avatar.value = { url: payload?.url, uploadId: payload?.uploadId, ...payload }
|
||||
form.value.avatarId = payload?.uploadId || payload?.id
|
||||
} catch {
|
||||
/* error handled by global handler */
|
||||
}
|
||||
}
|
||||
|
||||
const onAvatarError = (msg) => toast.error(msg)
|
||||
|
||||
const addMutation = useAddAdminUserMutation()
|
||||
const updateMutation = useUpdateAdminUserMutation()
|
||||
|
||||
const submitting = computed(() => addMutation.isPending.value || updateMutation.isPending.value)
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
if (isEditMode.value) {
|
||||
await updateMutation.mutateAsync({ id: userId.value, payload })
|
||||
} else {
|
||||
await addMutation.mutateAsync(payload)
|
||||
}
|
||||
await queryClient.invalidateQueries({ queryKey: adminUsersKeys.all })
|
||||
router.push({ name: 'admin-users' })
|
||||
}
|
||||
|
||||
const onCancel = () => router.push({ name: 'admin-users' })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.user-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__form {
|
||||
background: rgba(255, 255, 255, 60%);
|
||||
padding: 1rem;
|
||||
border-radius: 1rem;
|
||||
}
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 1rem;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: 4fr 8fr;
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: 3fr 9fr;
|
||||
}
|
||||
}
|
||||
|
||||
&__avatar-col {
|
||||
order: 2;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
order: 1;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__main-col {
|
||||
order: 1;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
order: 2;
|
||||
padding-inline-start: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
flex-flow: column wrap;
|
||||
gap: 0.5rem;
|
||||
align-items: stretch;
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
flex-direction: row;
|
||||
}
|
||||
}
|
||||
|
||||
&__cell {
|
||||
width: 100%;
|
||||
|
||||
&--third {
|
||||
@media (min-width: 768px) {
|
||||
width: 49%;
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
width: 32.3%;
|
||||
}
|
||||
}
|
||||
|
||||
&--half {
|
||||
@media (min-width: 768px) {
|
||||
width: 49%;
|
||||
}
|
||||
}
|
||||
|
||||
&--full {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
&__btn-submit {
|
||||
min-width: 11rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,126 @@
|
||||
<template>
|
||||
<div class="user-verification-page">
|
||||
<BoxedIconTitleBlock
|
||||
class="user-verification-page__heading"
|
||||
title="تایید هویت کاربران"
|
||||
desc="در این قسمت میتوانید کاربران خود را تایید یا رد کنید"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="users-three" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<VerificationsFilters v-model="filters" @apply="onFilterApply" @reset="onFilterReset" />
|
||||
|
||||
<SimpleTitleIconBlock title="لیست همه کاربران" class="user-verification-page__list-title">
|
||||
<template #header-icon>
|
||||
<SvgIcon name="users" :size="16" color="#bcbcbc" />
|
||||
</template>
|
||||
</SimpleTitleIconBlock>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="6" :cols-per-row="1" />
|
||||
<div v-else-if="users.length > 0">
|
||||
<VerificationItem
|
||||
v-for="user in users"
|
||||
:key="user.id"
|
||||
:user="user"
|
||||
@show-details="onShowDetails"
|
||||
@show-reject-reason="onShowRejectReason"
|
||||
@verify-user="onVerifyUser"
|
||||
/>
|
||||
</div>
|
||||
<NoItems v-else title="متاسفیم" desc="کاربری برای نمایش وجود ندارد." />
|
||||
|
||||
<PaginationBlock :pagination="paginationMeta" @update:page="setPage" />
|
||||
|
||||
<UserVerificationDetailsModal v-if="isModal('UserVerificationDetailsModal')" />
|
||||
<RejectReasonModal v-if="isModal('RejectReasonModal')" />
|
||||
<RejectReasonDetailsModal v-if="isModal('RejectReasonDetailsModal')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import VerificationsFilters from '@/features/admin/users/components/verifications/VerificationsFilters.vue'
|
||||
import VerificationItem from '@/features/admin/users/components/verifications/VerificationItem.vue'
|
||||
import UserVerificationDetailsModal from '@/features/admin/users/components/verifications/modals/UserVerificationDetailsModal.vue'
|
||||
import RejectReasonModal from '@/features/admin/users/components/verifications/modals/RejectReasonModal.vue'
|
||||
import RejectReasonDetailsModal from '@/features/admin/users/components/verifications/modals/RejectReasonDetailsModal.vue'
|
||||
import {
|
||||
adminPendingStudentsKeys,
|
||||
useChangePendingStudentStatusMutation,
|
||||
usePendingStudentsListQuery,
|
||||
} from '@/services/query/admin-pending-students'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import useModal from '@/composables/useModal'
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { openModal, isModal } = useModal()
|
||||
|
||||
const filters = ref({ name: '', nationalCode: '', fromDate: '', toDate: '' })
|
||||
const { pagination, setPage, reset: resetPagination } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = usePendingStudentsListQuery(filters, pagination, {
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
const users = computed(() => data.value?.data ?? [])
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const onFilterApply = () => resetPagination()
|
||||
const onFilterReset = () => resetPagination()
|
||||
|
||||
const changeStatusMutation = useChangePendingStudentStatusMutation()
|
||||
|
||||
const onVerifyUser = ({ id, status }) => {
|
||||
if (status === 'rejected') {
|
||||
openModal('RejectReasonModal', { id })
|
||||
return
|
||||
}
|
||||
changeStatusMutation.mutate(
|
||||
{ id, payload: { status } },
|
||||
{
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: adminPendingStudentsKeys.all }),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const onShowDetails = (id) => {
|
||||
openModal('UserVerificationDetailsModal', {
|
||||
id,
|
||||
onVerify: ({ id: targetId, status }) => onVerifyUser({ id: targetId, status }),
|
||||
})
|
||||
}
|
||||
|
||||
const onShowRejectReason = (user) => {
|
||||
openModal('RejectReasonDetailsModal', { verification: user.verification })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.user-verification-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
&__list-title {
|
||||
margin-bottom: 0.375rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<div class="users-page">
|
||||
<BoxedIconTitleBlock
|
||||
class="users-page__heading"
|
||||
title="مدیریت کاربران"
|
||||
desc="در این قسمت میتوانید کاربران خود را مدیریت کنید"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="users-three" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<UsersFilters v-model="filters" @apply="onFilterApply" @reset="onFilterReset" />
|
||||
|
||||
<div class="users-page__list-header">
|
||||
<SimpleTitleIconBlock title="لیست همه کاربران" class="users-page__list-title">
|
||||
<template #header-icon>
|
||||
<SvgIcon name="users" :size="16" color="#bcbcbc" />
|
||||
</template>
|
||||
</SimpleTitleIconBlock>
|
||||
<BaseButton text="افزودن کاربر جدید" custom-class="users-page__add-btn" @click="onAdd">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="plus" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="6" :cols-per-row="1" />
|
||||
<UsersTable
|
||||
v-else-if="users.length > 0"
|
||||
:users="users"
|
||||
@edit="onEdit"
|
||||
@delete="onAskDelete"
|
||||
@show-details="onShowDetails"
|
||||
@show-assignments="onShowAssignments"
|
||||
@show-exams="onShowExams"
|
||||
/>
|
||||
<NoItems v-else title="متاسفیم" desc="کاربری برای نمایش وجود ندارد." />
|
||||
|
||||
<PaginationBlock :pagination="paginationMeta" @update:page="setPage" />
|
||||
|
||||
<UserDetailsModal v-if="isModal('UserDetailsModal')" />
|
||||
<UserAssignmentsModal v-if="isModal('UserAssignmentsModal')" />
|
||||
<UserExamsModal v-if="isModal('UserExamsModal')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import UsersFilters from '@/features/admin/users/components/UsersFilters.vue'
|
||||
import UsersTable from '@/features/admin/users/components/UsersTable.vue'
|
||||
import UserDetailsModal from '@/features/admin/users/components/modals/UserDetailsModal.vue'
|
||||
import UserAssignmentsModal from '@/features/admin/users/components/modals/UserAssignmentsModal.vue'
|
||||
import UserExamsModal from '@/features/admin/users/components/modals/UserExamsModal.vue'
|
||||
import {
|
||||
adminUsersKeys,
|
||||
useAdminUsersListQuery,
|
||||
useDeleteAdminUserMutation,
|
||||
} from '@/services/query/admin-users'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import useModal from '@/composables/useModal'
|
||||
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
const { openModal, isModal } = useModal()
|
||||
|
||||
const filters = ref({ name: '', nationalCode: '', phoneNumber: '', roleId: '' })
|
||||
const { pagination, setPage, reset: resetPagination } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = useAdminUsersListQuery(filters, pagination, {
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
const users = computed(() => data.value?.data ?? [])
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const onFilterApply = () => resetPagination()
|
||||
const onFilterReset = () => resetPagination()
|
||||
|
||||
const onAdd = () => {
|
||||
router.push({ name: 'admin-add-user' }).catch(() => {})
|
||||
}
|
||||
|
||||
const onEdit = (user) => {
|
||||
router.push({ name: 'admin-edit-user', params: { id: user.id } }).catch(() => {})
|
||||
}
|
||||
|
||||
const onShowDetails = (user) => openModal('UserDetailsModal', { id: user.id })
|
||||
const onShowAssignments = (user) => openModal('UserAssignmentsModal', { id: user.id })
|
||||
const onShowExams = (user) => openModal('UserExamsModal', { id: user.id })
|
||||
|
||||
const deleteMutation = useDeleteAdminUserMutation()
|
||||
|
||||
const onAskDelete = (user) => {
|
||||
const name = `${user.firstName || ''} ${user.lastName || ''}`.trim() || user.phoneNumber
|
||||
openModal('ConfirmModal', {
|
||||
title: 'حذف کاربر',
|
||||
message: `آیا از حذف <strong>${name}</strong> مطمئن هستید؟`,
|
||||
onConfirm: () =>
|
||||
deleteMutation.mutate(user.id, {
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: adminUsersKeys.all }),
|
||||
}),
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.users-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__list-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
margin-bottom: 0.375rem;
|
||||
}
|
||||
|
||||
&__list-title {
|
||||
flex: 1;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&__add-btn {
|
||||
min-width: fit-content;
|
||||
padding: 0 1.25rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,40 @@
|
||||
import { object, string } from 'yup'
|
||||
|
||||
import { phoneNumberRule } from '@/constants/rules/phoneNumberRule'
|
||||
import { nationalCodeRule } from '@/constants/rules/nationalCodeRule'
|
||||
import { passwordRule } from '@/constants/rules/passwordRule'
|
||||
import { passwordConfirmationRule } from '@/constants/rules/passwordConfirmationRule'
|
||||
|
||||
export const rejectionReasonSchema = object().shape({
|
||||
rejectionReason: string().required(),
|
||||
priority: object()
|
||||
.shape({
|
||||
id: string().required().default(null),
|
||||
})
|
||||
.required()
|
||||
.default(null),
|
||||
adminNote: string().notRequired(),
|
||||
})
|
||||
|
||||
const baseUserShape = {
|
||||
roleId: string().required(),
|
||||
firstName: string().required().min(2),
|
||||
lastName: string().required().min(2),
|
||||
phoneNumber: phoneNumberRule,
|
||||
nationalCode: nationalCodeRule,
|
||||
birthDate: string().nullable().notRequired(),
|
||||
maritalStatus: string().nullable().notRequired(),
|
||||
gender: string().nullable().notRequired(),
|
||||
bio: string().nullable().notRequired(),
|
||||
provinceId: string().nullable().notRequired(),
|
||||
cityId: string().nullable().notRequired(),
|
||||
address: string().nullable().notRequired(),
|
||||
}
|
||||
|
||||
export const userAddSchema = object().shape({
|
||||
...baseUserShape,
|
||||
password: passwordRule,
|
||||
passwordConfirmation: passwordConfirmationRule,
|
||||
})
|
||||
|
||||
export const userEditSchema = object().shape(baseUserShape)
|
||||
Reference in New Issue
Block a user