fix: admin courses
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
VITE_API_BASE_URL=https://tripwisedaily.ir/api
|
||||
VITE_API_BASE_URL=http://109.122.252.86/api
|
||||
VITE_USE_MOCKS=false
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
@click="removeFile(index, file)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="16" />
|
||||
<SvgIcon name="close" color="red" :size="16" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
|
||||
@@ -15,8 +15,8 @@ export default function useAuth() {
|
||||
const savePhoneNumber = (phoneNumber) => {
|
||||
if (!phoneNumber) return
|
||||
const current = tokenService.getUserInfo() || {}
|
||||
if (!current.phoneNumber) {
|
||||
store.setUser({ ...current, phoneNumber })
|
||||
if (!current.phone && !current.phoneNumber) {
|
||||
store.setUser({ ...current, phone: phoneNumber })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ export const fields = {
|
||||
activitySummary: 'خلاصهٔ فعالیت',
|
||||
|
||||
avatar: 'تصویر پروفایل',
|
||||
avatarId: 'تصویر پروفایل',
|
||||
image: 'تصویر',
|
||||
|
||||
status: 'وضعیت',
|
||||
@@ -71,6 +72,9 @@ export const fields = {
|
||||
educationStatus: 'وضعیت تحصیلی',
|
||||
fieldOfStudy: 'رشتهٔ تحصیلی',
|
||||
seminaryLevel: 'مقطع حوزه',
|
||||
universityLevel: 'مقطع دانشگاهی',
|
||||
universityName: 'نام حوزه علمیه / دانشگاه',
|
||||
workExperienceSummary: 'خلاصهٔ سوابق شغلی',
|
||||
hijabApproach: 'رویکرد حجاب',
|
||||
|
||||
prerequisites: 'پیشنیازها',
|
||||
@@ -84,5 +88,17 @@ export const fields = {
|
||||
otherPlatformDetails: 'جزئیات سایر بسترها',
|
||||
|
||||
faithProductionAudio: 'صدای تولید ایمانی',
|
||||
faithProductionId: 'صدای تولید ایمانی',
|
||||
leaderMessageVideo: 'ویدیوی پیام رهبر',
|
||||
leaderMessageId: 'ویدیوی پیام رهبر',
|
||||
|
||||
responseToLowSatisfaction: 'واکنش به رضایت پایین مخاطب',
|
||||
responseToLowSatisfactionDescription: 'توضیح واکنش به رضایت پایین مخاطب',
|
||||
responseToSessionCancellation: 'واکنش به لغو جلسه',
|
||||
responseToSessionCancellationDescription: 'توضیح واکنش به لغو جلسه',
|
||||
responseToAudienceConflict: 'واکنش به تعارض با مخاطب',
|
||||
responseToAudienceConflictDescription: 'توضیح واکنش به تعارض با مخاطب',
|
||||
responseToCompetingPropagator: 'واکنش به مبلغ رقیب',
|
||||
responseToCompetingPropagatorDescription: 'توضیح واکنش به مبلغ رقیب',
|
||||
responseToUnqualifiedAdvisors: 'واکنش به مشاوران غیرمتخصص',
|
||||
}
|
||||
|
||||
+2
-1
@@ -148,6 +148,7 @@ export const COURSE_CONTENT_TYPE_ACCEPT = Object.freeze({
|
||||
export const SESSION_TYPE = Object.freeze({
|
||||
in_person: 'حضوری',
|
||||
online: 'آنلاین',
|
||||
offline: 'آفلاین',
|
||||
video: 'ویدئو',
|
||||
audio: 'صوتی',
|
||||
text: 'متن',
|
||||
@@ -201,7 +202,7 @@ export const SERVICE_TYPE = Object.freeze({
|
||||
})
|
||||
|
||||
export const CONSULTATION_STATUS = Object.freeze({
|
||||
in_progress: 'در حال گفتگو',
|
||||
open: 'در حال گفتگو',
|
||||
answered: 'پاسخ داده شده',
|
||||
closed: 'بسته شده',
|
||||
})
|
||||
|
||||
@@ -104,7 +104,7 @@ const todayIso = new Date().toISOString()
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const templatePagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: templatesResponse } = useAdminCoursesListQuery(templateFilters, templatePagination)
|
||||
const templateOptions = computed(() => templatesResponse.value?.data ?? [])
|
||||
|
||||
@@ -113,7 +113,7 @@ const sessionListFilters = computed(() => ({
|
||||
title: sessionSearch.value,
|
||||
courseId: form.value.courseId || undefined,
|
||||
}))
|
||||
const sessionPagination = ref({ page: 1, perPage: 30 })
|
||||
const sessionPagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: sessionsResponse } = useAdminSessionsListQuery(sessionListFilters, sessionPagination)
|
||||
const sessionOptions = computed(() => sessionsResponse.value?.data ?? [])
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<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
|
||||
<BasicModal
|
||||
:title="isEditMode ? 'ویرایش تکلیف' : 'افزودن تکلیف جدید'"
|
||||
:title-en="isEditMode ? 'Edit Assignment' : 'Add Assignment'"
|
||||
/>
|
||||
|
||||
width="95%"
|
||||
max-width="64rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ close }">
|
||||
<form class="add-assignment" @submit.prevent="onSubmit(close)">
|
||||
<div class="add-assignment__grid">
|
||||
<TextField
|
||||
v-model="form.title"
|
||||
@@ -172,7 +174,7 @@ const { validate, validateAt, errors, resetErrors } = useYup(schema)
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const templatePagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: templatesResponse } = useAdminCoursesListQuery(templateFilters, templatePagination)
|
||||
const selectedTemplate = ref(null)
|
||||
const templateOptions = computed(() => {
|
||||
@@ -188,7 +190,7 @@ const sessionFilters = computed(() => ({
|
||||
title: sessionSearch.value,
|
||||
courseId: form.value.courseId,
|
||||
}))
|
||||
const sessionPagination = ref({ page: 1, perPage: 30 })
|
||||
const sessionPagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: sessionsResponse } = useAdminSessionsListQuery(sessionFilters, sessionPagination, {
|
||||
enabled: () => !!form.value.courseId,
|
||||
})
|
||||
@@ -307,8 +309,8 @@ const onSubmit = async (close) => {
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<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 v-if="consultation.student?.avatarUrl" class="consultation-item__avatar">
|
||||
<img :src="consultation.student.avatarUrl" :alt="userName" />
|
||||
</div>
|
||||
<div v-else class="consultation-item__avatar consultation-item__avatar--placeholder">
|
||||
<SvgIcon name="user" :size="24" color="#bcbcbc" />
|
||||
@@ -11,9 +11,7 @@
|
||||
<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>
|
||||
<span class="consultation-item__request-id-value">{{ consultation.id || '—' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -26,7 +24,7 @@
|
||||
<button
|
||||
type="button"
|
||||
class="consultation-item__status"
|
||||
:class="`consultation-item__status--${consultation.status || 'in_progress'}`"
|
||||
:class="`consultation-item__status--${consultation.status || 'open'}`"
|
||||
@click="onStatusClick"
|
||||
>
|
||||
<span class="consultation-item__status-dot" />
|
||||
@@ -69,24 +67,11 @@ const props = defineProps({
|
||||
|
||||
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 userName = computed(() => props.consultation.student?.name || '—')
|
||||
|
||||
const statusLabel = computed(
|
||||
() => props.consultation.statusLabel || CONSULTATION_STATUS[props.consultation.status] || '—'
|
||||
)
|
||||
const statusLabel = computed(() => 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 createdAt = computed(() => formatJalaaliDate(props.consultation.createdAt) || '—')
|
||||
|
||||
const menuOpen = ref(false)
|
||||
const menuTrigger = ref(null)
|
||||
@@ -246,7 +231,7 @@ const menuItems = computed(() =>
|
||||
color: #009a12;
|
||||
}
|
||||
|
||||
&--in_progress {
|
||||
&--open {
|
||||
background: rgba(0, 112, 116, 10%);
|
||||
color: #007074;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
:class="`consultation-details__row--${senderClass(message)}`"
|
||||
>
|
||||
<div class="consultation-details__bubble">
|
||||
<p class="consultation-details__text">{{ message.text }}</p>
|
||||
<p class="consultation-details__text">{{ message.message }}</p>
|
||||
<span class="consultation-details__time">{{ messageTime(message) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -77,13 +77,19 @@ const { data: consultation, isLoading } = useAdminConsultationQuery(consultation
|
||||
|
||||
const messages = computed(() => consultation.value?.messages ?? [])
|
||||
|
||||
const consultationDate = computed(
|
||||
() => consultation.value?.faCreatedAt || formatJalaaliDate(consultation.value?.createdAt) || '—'
|
||||
)
|
||||
const consultationDate = computed(() => formatJalaaliDate(consultation.value?.createdAt) || '—')
|
||||
|
||||
const senderClass = (message) => (message.sender === 'admin' ? 'admin' : 'user')
|
||||
// Student is "the user"; everyone else (counselor, admin) renders on the
|
||||
// opposite side of the thread. Same rule as the admin tickets modal.
|
||||
const senderClass = (message) =>
|
||||
message.senderId === consultation.value?.studentId ? 'user' : 'admin'
|
||||
|
||||
const messageTime = (message) => message.time || message.faSentAt || message.sentAt || '—'
|
||||
const messageTime = (message) => {
|
||||
if (!message.createdAt) return '—'
|
||||
const d = new Date(message.createdAt)
|
||||
if (Number.isNaN(d.getTime())) return '—'
|
||||
return d.toLocaleTimeString('fa-IR', { hour: '2-digit', minute: '2-digit' })
|
||||
}
|
||||
|
||||
const text = ref('')
|
||||
const canSend = computed(() => text.value.trim().length > 0)
|
||||
@@ -94,7 +100,8 @@ 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 } })
|
||||
// Backend POST /counselor/tickets/:id/messages — body is { message: string }.
|
||||
await sendMutation.mutateAsync({ id: consultationId.value, payload: { message: value } })
|
||||
await queryClient.invalidateQueries({ queryKey: adminConsultationsKeys.all })
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
@click="onReset"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" />
|
||||
<SvgIcon name="close" :size="20" color="black" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
|
||||
@@ -165,7 +165,7 @@ const { validate, validateAt, errors, resetErrors } = useYup(schema)
|
||||
|
||||
const termSearch = ref('')
|
||||
const termFilters = computed(() => ({ title: termSearch.value }))
|
||||
const termPagination = ref({ page: 1, perPage: 30 })
|
||||
const termPagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: termsResponse } = useAdminTermsListQuery(termFilters, termPagination)
|
||||
const selectedTerm = ref(null)
|
||||
const termOptions = computed(() => {
|
||||
@@ -178,7 +178,7 @@ const termOptions = computed(() => {
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value, termId: 'null' }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const templatePagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: templatesResponse } = useAdminCoursesListQuery(templateFilters, templatePagination)
|
||||
const selectedTemplate = ref(null)
|
||||
const templateOptions = computed(() => {
|
||||
|
||||
@@ -84,24 +84,25 @@
|
||||
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 v-if="studentAvatar(student)" class="course-details__avatar">
|
||||
<img :src="studentAvatar(student)" :alt="student.name" />
|
||||
</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-name">{{ student.name || '—' }}</p>
|
||||
<p class="course-details__student-meta">
|
||||
<span>{{ student.address?.province?.name || '—' }}</span>
|
||||
<span dir="ltr">{{ student.phone || '—' }}</span>
|
||||
<template v-if="student.email">
|
||||
<span class="course-details__sep">،</span>
|
||||
<span>{{ student.address?.city?.name || '—' }}</span>
|
||||
<span dir="ltr">{{ student.email }}</span>
|
||||
</template>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="course-details__student-actions">
|
||||
<div v-if="student.phone" class="course-details__student-actions">
|
||||
<CircleButton
|
||||
v-if="student.phoneNumber"
|
||||
tooltip="ارسال پیام"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.25rem"
|
||||
@@ -111,16 +112,6 @@
|
||||
<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>
|
||||
@@ -151,7 +142,6 @@
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
@@ -166,16 +156,13 @@ import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import CourseSessionItem from '@/features/admin/courses/components/CourseSessionItem.vue'
|
||||
import {
|
||||
adminCoursesKeys,
|
||||
useAdminCourseQuery,
|
||||
useAdminCourseSessionsQuery,
|
||||
useAdminCourseStudentsQuery,
|
||||
useRemoveAdminCourseStudentMutation,
|
||||
useCourseAttendeesQuery,
|
||||
} from '@/services/query/admin-courses'
|
||||
|
||||
defineOptions({ name: 'CourseDetailsModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { openModal, getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('CourseDetailsModal')?.data ?? {})
|
||||
@@ -226,7 +213,7 @@ const { pagination: studentsPagination, setPage: setStudentsPage } = usePaginati
|
||||
perPage: 10,
|
||||
})
|
||||
|
||||
const { data: studentsData, isLoading: studentsPending } = useAdminCourseStudentsQuery(
|
||||
const { data: studentsData, isLoading: studentsPending } = useCourseAttendeesQuery(
|
||||
courseId,
|
||||
studentsFilters,
|
||||
studentsPagination,
|
||||
@@ -243,15 +230,7 @@ const studentsPaginationMeta = computed(() => ({
|
||||
...studentsData.value?.meta,
|
||||
}))
|
||||
|
||||
const studentName = (student) =>
|
||||
`${student.firstName || ''} ${student.lastName || ''}`.trim() ||
|
||||
student.fullName ||
|
||||
student.phoneNumber ||
|
||||
'—'
|
||||
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminCoursesKeys.all })
|
||||
|
||||
const removeStudentMutation = useRemoveAdminCourseStudentMutation()
|
||||
const studentAvatar = (student) => student.avatarUrl || student.avatarDownloadUrl || ''
|
||||
|
||||
const onOpenAddSession = () => {
|
||||
openModal('AddSessionToCourseModal', { courseId: courseId.value })
|
||||
@@ -261,21 +240,9 @@ const onOpenAddStudent = () => {
|
||||
openModal('AddCourseStudentModal', { courseId: courseId.value })
|
||||
}
|
||||
|
||||
const onAskRemoveStudent = (student) => {
|
||||
openModal('ConfirmModal', {
|
||||
title: `حذف ${studentName(student)}`,
|
||||
message: `آیا از حذف <strong>${studentName(student)}</strong> از این دوره اطمینان دارید؟`,
|
||||
onConfirm: () =>
|
||||
removeStudentMutation.mutate(
|
||||
{ courseId: courseId.value, userId: student.id },
|
||||
{ onSuccess: invalidate }
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
const onMessageStudent = (student) => {
|
||||
if (!student?.phoneNumber) return
|
||||
window.location.href = `sms:${student.phoneNumber}`
|
||||
if (!student?.phone) return
|
||||
window.location.href = `sms:${student.phone}`
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:error="errors.contentType"
|
||||
@change="onContentTypeChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="course-form__cell course-form__cell--full">
|
||||
@@ -109,18 +108,6 @@
|
||||
:error="errors.description"
|
||||
/>
|
||||
</div>
|
||||
<div class="course-form__cell course-form__cell--full">
|
||||
<label class="course-form__uploader-label">فایل دوره</label>
|
||||
<FileUploader
|
||||
v-model="contentFiles"
|
||||
:accept="contentAccept"
|
||||
:multiple="false"
|
||||
:max-files="1"
|
||||
@select="onContentSelect"
|
||||
@remove="onContentRemove"
|
||||
@error="onContentError"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -157,6 +144,7 @@
|
||||
import { toast } from 'vue3-toastify'
|
||||
import useYup from '@/composables/useYup'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { COURSE_CONTENT_TYPE } from '@/enums'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
@@ -165,14 +153,12 @@ import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import FileUploader from '@/components/form/FileUploader.vue'
|
||||
import ImageCropper from '@/components/form/ImageCropper.vue'
|
||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||
import { useUploadMediaMutation } from '@/services/query/auth'
|
||||
import { courseSchema } from '@/features/admin/courses/schema'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import { useAdminUsersListQuery } from '@/services/query/admin-users'
|
||||
import { COURSE_CONTENT_TYPE, COURSE_CONTENT_TYPE_ACCEPT } from '@/enums'
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import {
|
||||
adminCoursesKeys,
|
||||
@@ -197,27 +183,23 @@ const form = ref({
|
||||
sessionsCount: '',
|
||||
prerequisites: [],
|
||||
contentType: '',
|
||||
contentMediaId: null,
|
||||
description: '',
|
||||
coverMediaId: null,
|
||||
termId: termId.value,
|
||||
})
|
||||
|
||||
const image = ref(null)
|
||||
const contentFiles = ref([])
|
||||
|
||||
const contentTypeOptions = Object.entries(COURSE_CONTENT_TYPE).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
|
||||
const contentAccept = computed(() => COURSE_CONTENT_TYPE_ACCEPT[form.value.contentType] || '*')
|
||||
|
||||
const { validate, validateAt, errors } = useYup(courseSchema)
|
||||
|
||||
const teacherSearch = ref('')
|
||||
const teacherFilters = computed(() => ({ name: teacherSearch.value }))
|
||||
const teacherPagination = ref({ page: 1, perPage: 30 })
|
||||
const teacherPagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: teachersResponse } = useAdminUsersListQuery(teacherFilters, teacherPagination)
|
||||
const selectedTeacher = ref(null)
|
||||
const teacherOptions = computed(() => {
|
||||
@@ -234,7 +216,7 @@ const teacherOptions = computed(() => {
|
||||
|
||||
const prereqSearch = ref('')
|
||||
const prereqFilters = computed(() => ({ title: prereqSearch.value }))
|
||||
const prereqPagination = ref({ page: 1, perPage: 30 })
|
||||
const prereqPagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: prereqsResponse } = useAdminCoursesListQuery(prereqFilters, prereqPagination)
|
||||
const selectedPrereqs = ref([])
|
||||
const prerequisiteOptions = computed(() => {
|
||||
@@ -268,22 +250,11 @@ watch(existingCourse, (course) => {
|
||||
sessionsCount: course.sessionsCount ?? '',
|
||||
prerequisites: prereqs.map((p) => p.courseId ?? p.id).filter(Boolean),
|
||||
contentType: course.contentType || '',
|
||||
contentMediaId: course.contentMediaId || null,
|
||||
description: course.description || '',
|
||||
coverMediaId: course.coverMediaId || null,
|
||||
termId: course.termId ?? termId.value,
|
||||
}
|
||||
if (course.coverUrl) image.value = { url: course.coverUrl }
|
||||
if (course.contentMedia) {
|
||||
contentFiles.value = [
|
||||
{
|
||||
id: course.contentMedia.id,
|
||||
name: course.contentMedia.name || course.contentMedia.fileName || 'file',
|
||||
size: course.contentMedia.size ?? 0,
|
||||
url: course.contentMedia.url,
|
||||
},
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
const uploadMutation = useUploadMediaMutation()
|
||||
@@ -302,38 +273,6 @@ const onImageCropped = async (file) => {
|
||||
|
||||
const onImageError = (msg) => toast.error(msg)
|
||||
|
||||
const onContentTypeChange = () => {
|
||||
contentFiles.value = []
|
||||
form.value.contentMediaId = null
|
||||
}
|
||||
|
||||
const onContentSelect = async (files) => {
|
||||
const file = files?.[0]
|
||||
if (!file) return
|
||||
try {
|
||||
const formData = objectToFormData({
|
||||
file,
|
||||
purpose: 'voice',
|
||||
context: 'course',
|
||||
type: form.value.contentType,
|
||||
})
|
||||
const response = await uploadMutation.mutateAsync(formData)
|
||||
const payload = response?.data ?? response
|
||||
const id = payload?.id ?? payload?.uploadId
|
||||
contentFiles.value = [{ id, name: file.name, size: file.size, url: payload?.url }]
|
||||
form.value.contentMediaId = id
|
||||
} catch {
|
||||
contentFiles.value = []
|
||||
}
|
||||
}
|
||||
|
||||
const onContentRemove = () => {
|
||||
contentFiles.value = []
|
||||
form.value.contentMediaId = null
|
||||
}
|
||||
|
||||
const onContentError = (msg) => toast.error(msg)
|
||||
|
||||
const addMutation = useAddAdminCourseMutation()
|
||||
const updateMutation = useUpdateAdminCourseMutation()
|
||||
|
||||
|
||||
@@ -130,14 +130,8 @@ const tabs = [
|
||||
]
|
||||
const activeTab = ref(routeTermId.value ? 'offered' : 'templates')
|
||||
|
||||
const templateFilters = ref({ title: '', status: '', fromDate: '', toDate: '' })
|
||||
const offeredFilters = ref({
|
||||
title: '',
|
||||
termId: routeTermId.value ?? '',
|
||||
status: '',
|
||||
fromDate: '',
|
||||
toDate: '',
|
||||
})
|
||||
const templateFilters = ref({})
|
||||
const offeredFilters = ref({})
|
||||
|
||||
const currentFilters = computed({
|
||||
get: () => (activeTab.value === 'templates' ? templateFilters.value : offeredFilters.value),
|
||||
|
||||
@@ -81,7 +81,7 @@ const todayIso = new Date().toISOString()
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const templatePagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: templatesResponse } = useAdminCoursesListQuery(templateFilters, templatePagination)
|
||||
const templateOptions = computed(() => templatesResponse.value?.data ?? [])
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ const { validate, validateAt, errors } = useYup(examSchema)
|
||||
|
||||
const sessionSearch = ref('')
|
||||
const sessionFilters = computed(() => ({ title: sessionSearch.value }))
|
||||
const sessionPagination = ref({ page: 1, perPage: 30 })
|
||||
const sessionPagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: sessionsResponse } = useAdminSessionsListQuery(sessionFilters, sessionPagination)
|
||||
const selectedSession = ref(null)
|
||||
const sessionOptions = computed(() => {
|
||||
|
||||
@@ -54,11 +54,7 @@ const props = defineProps({
|
||||
|
||||
const emit = defineEmits(['show-details'])
|
||||
|
||||
const userName = computed(() => {
|
||||
const s = props.ticket.student
|
||||
if (!s) return '—'
|
||||
return s.name || `${s.firstName || ''} ${s.lastName || ''}`.trim() || s.fullName || '—'
|
||||
})
|
||||
const userName = computed(() => props.ticket.student?.name || '—')
|
||||
|
||||
const statusLabel = computed(() => TICKET_STATUS[props.ticket.status] || '—')
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ const sessionTypeOptions = Object.entries(SESSION_TYPE).map(([value, label]) =>
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const templatePagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: templatesResponse } = useAdminCoursesListQuery(templateFilters, templatePagination)
|
||||
const templateOptions = computed(() => templatesResponse.value?.data ?? [])
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="60rem" min-width="auto" :show-close-button="true">
|
||||
<BasicModal
|
||||
title="حضور و غیاب"
|
||||
title-en="Attendance"
|
||||
width="95%"
|
||||
max-width="60rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ close }">
|
||||
<div class="session-attendance">
|
||||
<LineTitleBlock title="حضور و غیاب" title-en="Attendance" />
|
||||
|
||||
<div class="session-attendance__filters">
|
||||
<SelectField
|
||||
v-model="filters.termId"
|
||||
@@ -120,7 +125,7 @@ const paginationMeta = computed(() => ({
|
||||
|
||||
const termSearch = ref('')
|
||||
const termListFilters = computed(() => ({ title: termSearch.value }))
|
||||
const termPagination = ref({ page: 1, perPage: 30 })
|
||||
const termPagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: termsResponse } = useAdminTermsListQuery(termListFilters, termPagination)
|
||||
const termOptions = computed(() => termsResponse.value?.data ?? [])
|
||||
|
||||
|
||||
@@ -1,96 +1,63 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="60rem" min-width="auto" :show-close-button="true">
|
||||
<BasicModal
|
||||
title="جزئیات جلسه"
|
||||
title-en="details"
|
||||
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.course?.title" class="session-details__sub">
|
||||
دوره: {{ session.course.title }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="session-details__grid">
|
||||
<LineInfoBlock title="عنوان جلسه" :desc="session.title || '—'" />
|
||||
<LineInfoBlock
|
||||
title="تاریخ شروع"
|
||||
:numeric-desc="formatJalaaliDate(session.startsAt) || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="تاریخ پایان"
|
||||
:numeric-desc="formatJalaaliDate(session.endsAt) || '—'"
|
||||
/>
|
||||
<LineInfoBlock title="مدت زمان جلسه" :numeric-desc="durationLabel" />
|
||||
|
||||
<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>
|
||||
<LineInfoBlock title="دوره مرتبط" :desc="courseTitle" />
|
||||
<LineInfoBlock title="متعلق به" :desc="termTitle" />
|
||||
<LineInfoBlock title="محتوای جلسه" :desc="contentTypeLabel" />
|
||||
</div>
|
||||
|
||||
<div v-if="session.description" class="session-details__desc">
|
||||
<LineInfoBlock title="توضیحات" :desc="session.description" />
|
||||
<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">
|
||||
<div v-if="isOnline && session.link" class="session-details__link-row">
|
||||
<LineInfoBlock title="لینک جلسه" :desc="session.link" />
|
||||
</div>
|
||||
|
||||
<div v-if="mediaUrl || session.contentType" class="session-details__media">
|
||||
<VideoPlayerBlock
|
||||
v-if="session.contentType === 'video'"
|
||||
:src="mediaUrl"
|
||||
:video-id="session.id"
|
||||
/>
|
||||
<VoiceRecorder
|
||||
v-else-if="session.contentType === 'voice'"
|
||||
:model-value="mediaUrl"
|
||||
:disabled="true"
|
||||
/>
|
||||
<a
|
||||
:href="material.filePath || material.fileUrl || '#'"
|
||||
v-else-if="mediaUrl"
|
||||
:href="mediaUrl"
|
||||
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>
|
||||
<SvgIcon name="file" :size="18" color="var(--color-primary)" />
|
||||
<span>{{ mediaFileName }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
<NoItems v-else title="یافت نشد" desc="اطلاعات این جلسه در دسترس نیست." />
|
||||
@@ -98,7 +65,7 @@
|
||||
<div class="session-details__divider" />
|
||||
|
||||
<div class="session-details__footer">
|
||||
<BaseButton text="بستن" custom-class="session-details__close-btn" @click="close">
|
||||
<BaseButton text="تایید" custom-class="session-details__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
@@ -117,10 +84,11 @@ import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
import { SESSION_PLATFORM, SESSION_TYPE } from '@/enums'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import { COURSE_CONTENT_TYPE, SESSION_TYPE } from '@/enums'
|
||||
import VoiceRecorder from '@/components/form/VoiceRecorder.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import { useAdminSessionQuery } from '@/services/query/admin-sessions'
|
||||
import VideoPlayerBlock from '@/components/blocks/VideoPlayerBlock.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
|
||||
defineOptions({ name: 'SessionDetailsModal' })
|
||||
@@ -135,20 +103,30 @@ const { data: session, isLoading } = useAdminSessionQuery(sessionId, {
|
||||
})
|
||||
|
||||
const sessionTypeLabel = computed(
|
||||
() => session.value?.sessionTypeFa || SESSION_TYPE[session.value?.sessionType] || '—'
|
||||
() => SESSION_TYPE[session.value?.type] || session.value?.typeFa || '—'
|
||||
)
|
||||
|
||||
const durationLabel = computed(() =>
|
||||
session.value?.durationMinutes == null ? '—' : `${session.value.durationMinutes} دقیقه`
|
||||
)
|
||||
|
||||
const usedInTermsCount = computed(() => session.value?.usedInTerms?.length ?? 0)
|
||||
const courseTitle = computed(() => session.value?.course?.title || '—')
|
||||
|
||||
const hasConfig = computed(() => {
|
||||
const c = session.value?.sessionConfig
|
||||
if (!c) return false
|
||||
return Object.values(c).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
})
|
||||
const termTitle = computed(
|
||||
() => session.value?.course?.term?.title || session.value?.term?.title || '—'
|
||||
)
|
||||
|
||||
const contentTypeLabel = computed(() => COURSE_CONTENT_TYPE[session.value?.contentType] || '—')
|
||||
|
||||
const isOnline = computed(() => session.value?.type === 'online')
|
||||
|
||||
const mediaUrl = computed(
|
||||
() => session.value?.contentMedia?.url || session.value?.contentMedia?.downloadUrl || ''
|
||||
)
|
||||
|
||||
const mediaFileName = computed(
|
||||
() => session.value?.contentMedia?.fileName || session.value?.contentMedia?.name || 'فایل پیوست'
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -156,51 +134,6 @@ const hasConfig = computed(() => {
|
||||
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;
|
||||
@@ -211,33 +144,43 @@ const hasConfig = computed(() => {
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__config,
|
||||
&__desc,
|
||||
&__materials {
|
||||
margin-top: 1rem;
|
||||
&__link-row {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
&__materials-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
&__link-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__media {
|
||||
margin-top: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
&__file {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
gap: 0.5rem;
|
||||
color: var(--color-primary);
|
||||
text-decoration: none;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
font-size: 0.875rem;
|
||||
padding: 0.5rem 0;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
|
||||
@@ -11,9 +11,21 @@
|
||||
</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" />
|
||||
|
||||
<!-- row 1 — title / startTime / endTime -->
|
||||
<!-- row 1 — title / startsAt / endsAt -->
|
||||
<div class="session-form__row session-form__row--three">
|
||||
<TextField
|
||||
v-model="form.title"
|
||||
@@ -27,19 +39,19 @@
|
||||
</template>
|
||||
</TextField>
|
||||
<DatePickerField
|
||||
v-model="form.startTime"
|
||||
name="startTime"
|
||||
v-model="form.startsAt"
|
||||
name="startsAt"
|
||||
label="زمان شروع"
|
||||
type="datetime"
|
||||
:error="errors.startTime"
|
||||
@blur="validateAt('startTime', form.startTime)"
|
||||
:error="errors.startsAt"
|
||||
@blur="validateAt('startsAt', form.startsAt)"
|
||||
/>
|
||||
<DatePickerField
|
||||
v-model="form.endTime"
|
||||
name="endTime"
|
||||
v-model="form.endsAt"
|
||||
name="endsAt"
|
||||
label="زمان پایان"
|
||||
type="datetime"
|
||||
:error="errors.endTime"
|
||||
:error="errors.endsAt"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -77,25 +89,25 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- row 3 — sessionType / meetingLink -->
|
||||
<!-- row 3 — type / link -->
|
||||
<div class="session-form__row session-form__row--two">
|
||||
<SelectField
|
||||
v-model="form.sessionType"
|
||||
name="sessionType"
|
||||
v-model="form.type"
|
||||
name="type"
|
||||
label="نوع جلسه"
|
||||
:options="sessionTypeOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:error="errors.sessionType"
|
||||
:error="errors.type"
|
||||
@change="onSessionTypeChange"
|
||||
/>
|
||||
<TextField
|
||||
v-model="form.meetingLink"
|
||||
name="meetingLink"
|
||||
v-model="form.link"
|
||||
name="link"
|
||||
label="لینک جلسه"
|
||||
:disabled="form.sessionType !== 'online'"
|
||||
:error="errors.meetingLink"
|
||||
@blur="validateAt('meetingLink', form.meetingLink)"
|
||||
:disabled="form.type !== 'online'"
|
||||
:error="errors.link"
|
||||
@blur="validateAt('link', form.link)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -123,31 +135,7 @@
|
||||
@error="onContentError"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- row 6 — preview of uploaded content -->
|
||||
<div v-if="contentPreviewUrl" class="session-form__row session-form__preview">
|
||||
<video
|
||||
v-if="form.contentType === 'video'"
|
||||
:src="contentPreviewUrl"
|
||||
controls
|
||||
class="session-form__media"
|
||||
/>
|
||||
<audio
|
||||
v-else-if="form.contentType === 'voice'"
|
||||
:src="contentPreviewUrl"
|
||||
controls
|
||||
class="session-form__media"
|
||||
/>
|
||||
<a
|
||||
v-else
|
||||
:href="contentPreviewUrl"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="session-form__file-link"
|
||||
>
|
||||
<SvgIcon name="file" :size="18" color="var(--color-primary)" />
|
||||
<span>{{ contentFiles[0]?.name || 'فایل پیوست' }}</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="session-form__divider" />
|
||||
@@ -191,6 +179,7 @@ import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import FileUploader from '@/components/form/FileUploader.vue'
|
||||
import ImageCropper from '@/components/form/ImageCropper.vue'
|
||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||
import { useUploadMediaMutation } from '@/services/query/auth'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
@@ -213,13 +202,11 @@ const queryClient = useQueryClient()
|
||||
const sessionId = computed(() => (route.params.id ? Number(route.params.id) : null))
|
||||
const isEditMode = computed(() => !!sessionId.value)
|
||||
|
||||
// نوع جلسه: only the two delivery modes — backend `type` collapses to online/offline.
|
||||
const sessionTypeOptions = [
|
||||
{ value: 'in_person', label: SESSION_TYPE.in_person },
|
||||
{ value: 'offline', label: SESSION_TYPE.offline },
|
||||
{ value: 'online', label: SESSION_TYPE.online },
|
||||
]
|
||||
|
||||
// محتوای جلسه: voice / video / text — reuses the course content-type enum.
|
||||
const contentTypeOptions = Object.entries(COURSE_CONTENT_TYPE).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
@@ -227,27 +214,28 @@ const contentTypeOptions = Object.entries(COURSE_CONTENT_TYPE).map(([value, labe
|
||||
|
||||
const form = ref({
|
||||
title: '',
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
startsAt: '',
|
||||
endsAt: '',
|
||||
durationMinutes: '',
|
||||
courseId: '',
|
||||
contentType: '',
|
||||
sessionType: '',
|
||||
meetingLink: '',
|
||||
type: '',
|
||||
link: '',
|
||||
description: '',
|
||||
contentMediaId: null,
|
||||
})
|
||||
|
||||
const image = ref(null)
|
||||
const contentFiles = ref([])
|
||||
const coverMediaId = ref(null)
|
||||
const contentMediaId = ref(null)
|
||||
|
||||
const contentAccept = computed(() => COURSE_CONTENT_TYPE_ACCEPT[form.value.contentType] || '*')
|
||||
const contentPreviewUrl = computed(() => contentFiles.value[0]?.url || '')
|
||||
|
||||
const { validate, validateAt, errors } = useYup(sessionSchema)
|
||||
|
||||
const courseSearch = ref('')
|
||||
const courseFilters = computed(() => ({ title: courseSearch.value }))
|
||||
const coursePagination = ref({ page: 1, perPage: 30 })
|
||||
const coursePagination = ref({ page: 1, perPage: 10 })
|
||||
const { data: coursesResponse } = useAdminCoursesListQuery(courseFilters, coursePagination)
|
||||
const selectedCourse = ref(null)
|
||||
const courseOptions = computed(() => {
|
||||
@@ -264,50 +252,67 @@ const searchCourses = useDebounce((q) => {
|
||||
|
||||
const onContentTypeChange = () => {
|
||||
contentFiles.value = []
|
||||
form.value.contentMediaId = null
|
||||
contentMediaId.value = null
|
||||
}
|
||||
|
||||
const onSessionTypeChange = () => {
|
||||
if (form.value.sessionType !== 'online') form.value.meetingLink = ''
|
||||
if (form.value.type !== 'online') form.value.link = ''
|
||||
}
|
||||
|
||||
const { data: existingSession } = useAdminSessionQuery(sessionId, {
|
||||
enabled: () => !!sessionId.value,
|
||||
})
|
||||
|
||||
watch(existingSession, (session) => {
|
||||
watch(
|
||||
existingSession,
|
||||
(session) => {
|
||||
if (!session) return
|
||||
if (session.course) selectedCourse.value = session.course
|
||||
const media = Array.isArray(session.media) ? session.media : []
|
||||
const coverMedia = media.find((m) => m.collectionName === 'cover')
|
||||
const contentMedia = media.find((m) => m.collectionName !== 'cover')
|
||||
const contentType = collectionToContentType(contentMedia?.collectionName)
|
||||
form.value = {
|
||||
title: session.title || '',
|
||||
startTime: session.startsAt || session.sessionConfig?.startTime || '',
|
||||
endTime: session.endsAt || session.sessionConfig?.endTime || '',
|
||||
title: session.title ?? '',
|
||||
startsAt: session.startsAt ?? '',
|
||||
endsAt: session.endsAt ?? '',
|
||||
durationMinutes: session.durationMinutes ?? '',
|
||||
courseId: session.course?.id || session.courseId || '',
|
||||
contentType: session.contentType || '',
|
||||
sessionType: session.sessionType || '',
|
||||
meetingLink: session.link || session.sessionConfig?.meetingLink || '',
|
||||
description: session.description || '',
|
||||
contentMediaId: session.contentMediaId || null,
|
||||
courseId: session.course?.id ?? '',
|
||||
contentType,
|
||||
type: session.type ?? '',
|
||||
link: session.link ?? '',
|
||||
description: session.description ?? '',
|
||||
}
|
||||
if (session.contentMedia) {
|
||||
coverMediaId.value = coverMedia?.id ?? null
|
||||
contentMediaId.value = contentMedia?.id ?? null
|
||||
if (contentMedia) {
|
||||
contentFiles.value = [
|
||||
{
|
||||
id: session.contentMedia.id,
|
||||
name: session.contentMedia.fileName || session.contentMedia.name || 'file',
|
||||
size: session.contentMedia.fileSize ?? 0,
|
||||
url: session.contentMedia.url,
|
||||
id: contentMedia.id,
|
||||
name: contentMedia.fileName ?? 'file',
|
||||
size: contentMedia.fileSize ?? 0,
|
||||
url: contentMedia.url,
|
||||
},
|
||||
]
|
||||
}
|
||||
})
|
||||
if (coverMedia?.url) image.value = { url: coverMedia.url }
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const uploadMutation = useUploadMediaMutation()
|
||||
|
||||
const purposeForContentType = (contentType) => {
|
||||
if (contentType === 'video') return 'video'
|
||||
if (contentType === 'voice') return 'voice'
|
||||
return 'attachment'
|
||||
return 'pdf'
|
||||
}
|
||||
|
||||
const collectionToContentType = (collectionName) => {
|
||||
if (collectionName === 'videos') return 'video'
|
||||
if (collectionName === 'voices') return 'voice'
|
||||
if (collectionName === 'pdf') return 'text'
|
||||
return ''
|
||||
}
|
||||
|
||||
const onContentSelect = async (files) => {
|
||||
@@ -323,7 +328,7 @@ const onContentSelect = async (files) => {
|
||||
const payload = response?.data ?? response
|
||||
const id = payload?.id ?? payload?.uploadId
|
||||
contentFiles.value = [{ id, name: file.name, size: file.size, url: payload?.url }]
|
||||
form.value.contentMediaId = id
|
||||
contentMediaId.value = id
|
||||
} catch {
|
||||
contentFiles.value = []
|
||||
}
|
||||
@@ -331,26 +336,41 @@ const onContentSelect = async (files) => {
|
||||
|
||||
const onContentRemove = () => {
|
||||
contentFiles.value = []
|
||||
form.value.contentMediaId = null
|
||||
contentMediaId.value = null
|
||||
}
|
||||
|
||||
const onContentError = (msg) => toast.error(msg)
|
||||
|
||||
const onImageCropped = async (file) => {
|
||||
try {
|
||||
const formData = objectToFormData({ file, purpose: 'cover', context: 'session' })
|
||||
const response = await uploadMutation.mutateAsync(formData)
|
||||
const payload = response?.data ?? response
|
||||
image.value = { url: payload?.url, ...payload }
|
||||
coverMediaId.value = payload?.id ?? null
|
||||
} catch {
|
||||
/* handled globally */
|
||||
}
|
||||
}
|
||||
|
||||
const onImageError = (msg) => toast.error(msg)
|
||||
|
||||
const buildPayload = (values) => {
|
||||
const mediaIds = [coverMediaId.value, contentMediaId.value].filter((id) => id != null)
|
||||
const payload = {
|
||||
title: values.title,
|
||||
startTime: values.startTime,
|
||||
endTime: values.endTime,
|
||||
startsAt: values.startsAt,
|
||||
endsAt: values.endsAt,
|
||||
durationMinutes: values.durationMinutes,
|
||||
courseId: values.courseId,
|
||||
contentType: values.contentType,
|
||||
sessionType: values.sessionType,
|
||||
meetingLink: values.sessionType === 'online' ? values.meetingLink : undefined,
|
||||
type: values.type,
|
||||
link: values.type === 'online' ? values.link : undefined,
|
||||
description: values.description,
|
||||
contentMediaId: values.contentMediaId,
|
||||
mediaIds,
|
||||
}
|
||||
Object.keys(payload).forEach((key) => {
|
||||
if (payload[key] === undefined || payload[key] === '' || payload[key] === null) {
|
||||
const value = payload[key]
|
||||
if (value === undefined || value === '' || value === null) {
|
||||
delete payload[key]
|
||||
}
|
||||
})
|
||||
@@ -397,6 +417,41 @@ const onCancel = () => router.push({ name: 'admin-sessions' })
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
&__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;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
order: 2;
|
||||
padding-inline-start: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
@@ -461,8 +516,8 @@ const onCancel = () => router.push({ name: 'admin-sessions' })
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
|
||||
@@ -2,17 +2,15 @@ import { number, object, string } from 'yup'
|
||||
|
||||
export const sessionSchema = object().shape({
|
||||
title: string().required().min(3),
|
||||
startTime: string().required(),
|
||||
endTime: string().nullable().notRequired(),
|
||||
startsAt: string().required(),
|
||||
endsAt: string().nullable().notRequired(),
|
||||
durationMinutes: number().typeError('مدت زمان باید عدد باشد').required().min(1),
|
||||
courseId: string().required(),
|
||||
contentType: string().oneOf(['voice', 'video', 'text']).required(),
|
||||
sessionType: string().oneOf(['in_person', 'online']).required(),
|
||||
meetingLink: string().when('sessionType', {
|
||||
type: string().oneOf(['offline', 'online']).required(),
|
||||
link: string().when('sessionType', {
|
||||
is: 'online',
|
||||
then: (schema) => schema.required(),
|
||||
otherwise: (schema) => schema.nullable().notRequired(),
|
||||
}),
|
||||
description: string().nullable().notRequired(),
|
||||
contentMediaId: number().nullable().notRequired(),
|
||||
})
|
||||
|
||||
@@ -51,37 +51,23 @@
|
||||
<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 v-if="studentAvatar(student)" class="term-details__avatar">
|
||||
<img :src="studentAvatar(student)" :alt="student.name" />
|
||||
</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-name">{{ student.name || '—' }}</p>
|
||||
<p class="term-details__student-meta">
|
||||
<span>{{ student.address?.province?.name || '—' }}</span>
|
||||
<span dir="ltr">{{ student.phone || '—' }}</span>
|
||||
<template v-if="student.email">
|
||||
<span class="term-details__sep">،</span>
|
||||
<span>{{ student.address?.city?.name || '—' }}</span>
|
||||
<span dir="ltr">{{ student.email }}</span>
|
||||
</template>
|
||||
</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="دانشجویی برای نمایش وجود ندارد." />
|
||||
@@ -143,11 +129,9 @@ import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import TabsBlock from '@/components/blocks/TabsBlock.vue'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import ToggleSwitch from '@/components/form/ToggleSwitch.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
@@ -156,13 +140,7 @@ import {
|
||||
useAdminCoursesListQuery,
|
||||
useUpdateAdminCourseMutation,
|
||||
} from '@/services/query/admin-courses'
|
||||
import {
|
||||
adminTermsKeys,
|
||||
useAdminTermQuery,
|
||||
useAdminTermStudentsQuery,
|
||||
useRemoveAdminTermStudentMutation,
|
||||
useToggleAdminTermStudentLeaveMutation,
|
||||
} from '@/services/query/admin-terms'
|
||||
import { useAdminTermQuery, useTermAttendeesQuery } from '@/services/query/admin-terms'
|
||||
|
||||
defineOptions({ name: 'TermDetailsModal' })
|
||||
|
||||
@@ -189,7 +167,7 @@ const {
|
||||
reset: resetStudentPagination,
|
||||
} = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data: studentsData, isLoading: studentsPending } = useAdminTermStudentsQuery(
|
||||
const { data: studentsData, isLoading: studentsPending } = useTermAttendeesQuery(
|
||||
termId,
|
||||
studentFilters,
|
||||
studentPagination,
|
||||
@@ -206,31 +184,7 @@ const studentPaginationMeta = computed(() => ({
|
||||
...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) => {
|
||||
removeStudentMutation.mutate(
|
||||
{ termId: termId.value, userId: student.id },
|
||||
{ onSuccess: invalidate }
|
||||
)
|
||||
}
|
||||
const studentAvatar = (student) => student.avatarUrl || student.avatarDownloadUrl || ''
|
||||
|
||||
const courseFilters = computed(() => ({ termId: termId.value }))
|
||||
const { pagination: coursePagination, setPage: setCoursePage } = usePagination({
|
||||
|
||||
@@ -91,7 +91,11 @@ const redirectAfterLogin = useRedirectAfterLogin()
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
const response = await loginMutation.mutateAsync(payload)
|
||||
const response = await loginMutation.mutateAsync({
|
||||
phone: payload.phoneNumber,
|
||||
password: payload.password,
|
||||
deviceName: 'web',
|
||||
})
|
||||
applySession(response?.data ?? response)
|
||||
redirectAfterLogin()
|
||||
}
|
||||
|
||||
@@ -114,7 +114,13 @@ const { savePhoneNumber } = useAuth()
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
await registerMutation.mutateAsync(payload)
|
||||
const name = [payload.firstName, payload.lastName].filter(Boolean).join(' ').trim()
|
||||
await registerMutation.mutateAsync({
|
||||
name,
|
||||
phone: payload.phoneNumber,
|
||||
password: payload.password,
|
||||
passwordConfirmation: payload.passwordConfirmation,
|
||||
})
|
||||
savePhoneNumber(payload.phoneNumber)
|
||||
emit('next', { phoneNumber: payload.phoneNumber })
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
</div>
|
||||
|
||||
<div class="educational-info__divider" />
|
||||
<StepActions @back="store.goToPrevStep()" />
|
||||
<StepActions :loading="saveRegisterMutation.isPending.value" @back="store.goToPrevStep()" />
|
||||
</form>
|
||||
</template>
|
||||
|
||||
@@ -108,9 +108,13 @@ import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||
import { educationalInformationSchema } from '@/features/auth/schema/student-register'
|
||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||
import {
|
||||
toKeyValueList,
|
||||
useStudentRegistrationStore,
|
||||
} from '@/features/auth/store/student-registration'
|
||||
import { EDUCATION_STATUS, SEMINARY_LEVEL, STUDENT_REGISTRATION, UNIVERSITY_LEVEL } from '@/enums'
|
||||
|
||||
const store = useStudentRegistrationStore()
|
||||
@@ -139,9 +143,12 @@ const form = ref({ ...store.educational })
|
||||
|
||||
const { validate, validateAt, errors } = useYup(educationalInformationSchema)
|
||||
|
||||
const saveRegisterMutation = useSaveRegisterDataMutation()
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
await saveRegisterMutation.mutateAsync(toKeyValueList(payload))
|
||||
store.educational = { ...store.educational, ...payload }
|
||||
store.markStepAsCompleted(STUDENT_REGISTRATION.EDUCATIONAL_INFORMATION)
|
||||
store.goToNextStep()
|
||||
|
||||
@@ -92,6 +92,7 @@ const props = defineProps({
|
||||
maxSeconds: { type: Number, default: 120 },
|
||||
context: { type: String, default: 'verification' },
|
||||
subType: { type: String, default: '' },
|
||||
purpose: { type: String, default: '' },
|
||||
error: { type: String, default: '' },
|
||||
})
|
||||
|
||||
@@ -191,6 +192,7 @@ const handleStop = async () => {
|
||||
file,
|
||||
subType: props.subType || props.kind,
|
||||
context: props.context,
|
||||
...(props.purpose ? { purpose: props.purpose } : {}),
|
||||
})
|
||||
const response = await uploadMutation.mutateAsync(fd)
|
||||
const payload = response?.data ?? response
|
||||
@@ -276,7 +278,6 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
|
||||
&__media--audio {
|
||||
width: 100%;
|
||||
height: 2.5rem;
|
||||
background: transparent;
|
||||
position: absolute;
|
||||
|
||||
@@ -151,7 +151,10 @@
|
||||
|
||||
<div class="personal-info__divider" />
|
||||
|
||||
<StepActions :show-back="false" :loading="uploadMutation.isPending.value" />
|
||||
<StepActions
|
||||
:show-back="false"
|
||||
:loading="uploadMutation.isPending.value || saveRegisterMutation.isPending.value"
|
||||
/>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
@@ -167,13 +170,14 @@ import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import ImageCropper from '@/components/form/ImageCropper.vue'
|
||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import { useUploadMediaMutation } from '@/services/query/auth'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { GENDER, MARITAL_STATUS, STUDENT_REGISTRATION } from '@/enums'
|
||||
import { toKeyValueList } from '@/features/auth/store/student-registration'
|
||||
import { personalInformationSchema } from '@/features/auth/schema/student-register'
|
||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||
import { useSaveRegisterDataMutation, useUploadMediaMutation } from '@/services/query/auth'
|
||||
import { useGetCitiesOfProvinceQuery, useGetProvincesQuery } from '@/services/query/common'
|
||||
|
||||
const store = useStudentRegistrationStore()
|
||||
@@ -202,7 +206,9 @@ const maxBirthDate = computed(() => {
|
||||
}
|
||||
})
|
||||
|
||||
const initialPhoneNumber = ref(user.value?.phoneNumber || store.personal.phoneNumber || '')
|
||||
const initialPhoneNumber = ref(
|
||||
user.value?.phone || user.value?.phoneNumber || store.personal.phoneNumber || ''
|
||||
)
|
||||
|
||||
const form = ref({
|
||||
firstName: store.personal.firstName || '',
|
||||
@@ -246,7 +252,7 @@ const uploadMutation = useUploadMediaMutation()
|
||||
|
||||
const onAvatarCropped = async (file) => {
|
||||
try {
|
||||
const fd = objectToFormData({ file, subType: 'avatar', context: 'verification' })
|
||||
const fd = objectToFormData({ file, purpose: 'avatar', context: 'verification' })
|
||||
const response = await uploadMutation.mutateAsync(fd)
|
||||
const payload = response?.data ?? response
|
||||
const value = { url: payload?.url, uploadId: payload?.uploadId || payload?.id, ...payload }
|
||||
@@ -260,10 +266,14 @@ const onAvatarCropped = async (file) => {
|
||||
|
||||
const onAvatarError = (msg) => toast.error(msg)
|
||||
|
||||
const saveRegisterMutation = useSaveRegisterDataMutation()
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
store.personal = { ...store.personal, ...payload, avatar: form.value.avatar }
|
||||
const next = { ...payload, avatar: form.value.avatar }
|
||||
await saveRegisterMutation.mutateAsync(toKeyValueList(next))
|
||||
store.personal = { ...store.personal, ...next }
|
||||
store.markStepAsCompleted(STUDENT_REGISTRATION.PERSONAL_INFORMATION)
|
||||
store.goToNextStep()
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
</div>
|
||||
|
||||
<div class="professional-info__divider" />
|
||||
<StepActions @back="store.goToPrevStep()" />
|
||||
<StepActions :loading="saveRegisterMutation.isPending.value" @back="store.goToPrevStep()" />
|
||||
</form>
|
||||
</template>
|
||||
|
||||
@@ -114,9 +114,13 @@ import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import { PROPAGATION_PLATFORM, STUDENT_REGISTRATION } from '@/enums'
|
||||
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||
import { professionalInformationSchema } from '@/features/auth/schema/student-register'
|
||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||
import {
|
||||
toKeyValueList,
|
||||
useStudentRegistrationStore,
|
||||
} from '@/features/auth/store/student-registration'
|
||||
|
||||
const store = useStudentRegistrationStore()
|
||||
|
||||
@@ -167,6 +171,8 @@ const onPlatformsChange = (selected) => {
|
||||
|
||||
const { validate, validateAt, errors } = useYup(professionalInformationSchema)
|
||||
|
||||
const saveRegisterMutation = useSaveRegisterDataMutation()
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
@@ -181,12 +187,14 @@ const onSubmit = async () => {
|
||||
return { platform, platformDetails: '' }
|
||||
})
|
||||
|
||||
store.professional = {
|
||||
const next = {
|
||||
propagationExperienceYears: Number(payload.propagationExperienceYears),
|
||||
propagationMethodDescription: payload.propagationMethodDescription,
|
||||
specializedTopics: payload.specializedTopics,
|
||||
propagationPlatforms,
|
||||
}
|
||||
await saveRegisterMutation.mutateAsync(toKeyValueList(next))
|
||||
store.professional = next
|
||||
store.markStepAsCompleted(STUDENT_REGISTRATION.PROFESSIONAL_INFORMATION)
|
||||
store.goToNextStep()
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
kind="audio"
|
||||
sub-type="audio"
|
||||
context="verification"
|
||||
purpose="voice"
|
||||
:max-seconds="180"
|
||||
:error="errors.faithProductionAudio"
|
||||
@uploaded="onUploaded"
|
||||
@@ -28,20 +29,23 @@
|
||||
</div>
|
||||
|
||||
<div class="skill-six__divider" />
|
||||
<StepActions @back="store.goToPrevStep()" />
|
||||
<StepActions :loading="saveRegisterMutation.isPending.value" @back="store.goToPrevStep()" />
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import useYup from '@/composables/useYup'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { STUDENT_REGISTRATION } from '@/enums'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import { useGetRegistrationVideoQuery } from '@/services/query/auth'
|
||||
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||
import { skillAssessmentPart6Schema } from '@/features/auth/schema/student-register'
|
||||
import MediaRecorder from '@/features/auth/components/studentRegister/MediaRecorder.vue'
|
||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||
import {
|
||||
toKeyValueList,
|
||||
useStudentRegistrationStore,
|
||||
} from '@/features/auth/store/student-registration'
|
||||
|
||||
const store = useStudentRegistrationStore()
|
||||
|
||||
@@ -59,20 +63,14 @@ const onUploaded = (value) => {
|
||||
form.value.faithProductionId = value?.uploadId || ''
|
||||
}
|
||||
|
||||
const { data: media } = useGetRegistrationVideoQuery()
|
||||
const videoUrl = computed(() => store.registrationMedia.faithProductionVideoUrl || '')
|
||||
|
||||
const videoUrl = computed(
|
||||
() =>
|
||||
media.value?.faithProductionVideoUrl || store.registrationMedia.faithProductionVideoUrl || ''
|
||||
)
|
||||
|
||||
watch(media, (val) => {
|
||||
if (val) store.registrationMedia = { ...store.registrationMedia, ...val }
|
||||
})
|
||||
const saveRegisterMutation = useSaveRegisterDataMutation()
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
await saveRegisterMutation.mutateAsync(toKeyValueList(payload))
|
||||
store.skill6 = { ...store.skill6, ...payload }
|
||||
store.markStepAsCompleted(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_6)
|
||||
store.goToNextStep()
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<div class="skill-seven__divider" />
|
||||
<StepActions
|
||||
:loading="completeMutation.isPending.value"
|
||||
:loading="saveRegisterMutation.isPending.value"
|
||||
next-text="تایید اطلاعات"
|
||||
@back="store.goToPrevStep()"
|
||||
/>
|
||||
@@ -39,18 +39,19 @@
|
||||
<script setup>
|
||||
import { toast } from 'vue3-toastify'
|
||||
import useYup from '@/composables/useYup'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import useAuth from '@/composables/useAuth'
|
||||
import { computed, ref } from 'vue'
|
||||
import { STUDENT_REGISTRATION } from '@/enums'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||
import { skillAssessmentPart7Schema } from '@/features/auth/schema/student-register'
|
||||
import MediaRecorder from '@/features/auth/components/studentRegister/MediaRecorder.vue'
|
||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||
import { useCompleteProfileMutation, useGetRegistrationVideoQuery } from '@/services/query/auth'
|
||||
import {
|
||||
toKeyValueList,
|
||||
useStudentRegistrationStore,
|
||||
} from '@/features/auth/store/student-registration'
|
||||
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||
|
||||
const store = useStudentRegistrationStore()
|
||||
const { applySession } = useAuth()
|
||||
|
||||
const video = ref(store.skill7.leaderMessageVideo || null)
|
||||
|
||||
@@ -66,28 +67,17 @@ const onUploaded = (value) => {
|
||||
form.value.leaderMessageId = value?.uploadId || ''
|
||||
}
|
||||
|
||||
const { data: media } = useGetRegistrationVideoQuery()
|
||||
const videoUrl = computed(() => store.registrationMedia.leaderMessageVideoUrl || '')
|
||||
|
||||
const videoUrl = computed(
|
||||
() => media.value?.leaderMessageVideoUrl || store.registrationMedia.leaderMessageVideoUrl || ''
|
||||
)
|
||||
|
||||
watch(media, (val) => {
|
||||
if (val) store.registrationMedia = { ...store.registrationMedia, ...val }
|
||||
})
|
||||
|
||||
const completeMutation = useCompleteProfileMutation()
|
||||
const saveRegisterMutation = useSaveRegisterDataMutation()
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
try {
|
||||
await saveRegisterMutation.mutateAsync(toKeyValueList(payload))
|
||||
store.skill7 = { ...store.skill7, ...payload }
|
||||
store.markStepAsCompleted(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_7)
|
||||
|
||||
try {
|
||||
const response = await completeMutation.mutateAsync(store.buildCompletePayload())
|
||||
const data = response?.data ?? response
|
||||
applySession(data)
|
||||
store.isProfileCompleted = true
|
||||
} catch (error) {
|
||||
toast.error(error?.response?.data?.message || 'عملیات با خطا مواجه شد')
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</div>
|
||||
|
||||
<div class="skill-step__divider" />
|
||||
<StepActions @back="store.goToPrevStep()" />
|
||||
<StepActions :loading="saveRegisterMutation.isPending.value" @back="store.goToPrevStep()" />
|
||||
</form>
|
||||
</template>
|
||||
|
||||
@@ -44,8 +44,12 @@ import SelectField from '@/components/form/SelectField.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||
import {
|
||||
toKeyValueList,
|
||||
useStudentRegistrationStore,
|
||||
} from '@/features/auth/store/student-registration'
|
||||
|
||||
const props = defineProps({
|
||||
step: { type: Number, required: true },
|
||||
@@ -80,9 +84,12 @@ const onSelect = () => {
|
||||
|
||||
const { validate, errors } = useYup(props.schema)
|
||||
|
||||
const saveRegisterMutation = useSaveRegisterDataMutation()
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
await saveRegisterMutation.mutateAsync(toKeyValueList(payload))
|
||||
store[props.storeKey] = { ...store[props.storeKey], ...payload }
|
||||
store.markStepAsCompleted(props.step)
|
||||
store.goToNextStep()
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
v-model="form.phoneNumber"
|
||||
name="phoneNumber"
|
||||
label="شماره موبایل"
|
||||
:disabled="!!user?.phoneNumber"
|
||||
:disabled="!!(user?.phone || user?.phoneNumber)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="phone" :size="22" color="var(--color-thd-gray)" />
|
||||
@@ -71,7 +71,7 @@ const redirectAfterLogin = useRedirectAfterLogin()
|
||||
const schema = resetPasswordSchema
|
||||
|
||||
const form = ref({
|
||||
phoneNumber: user.value?.phoneNumber || '',
|
||||
phoneNumber: user.value?.phone || user.value?.phoneNumber || '',
|
||||
password: '',
|
||||
passwordConfirmation: '',
|
||||
})
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
import useModal from '@/composables/useModal'
|
||||
import { computed, markRaw, watch } from 'vue'
|
||||
import { STUDENT_REGISTRATION } from '@/enums'
|
||||
import { useGetRegisterDataQuery } from '@/services/query/auth'
|
||||
import SideBarSteps from '@/features/auth/components/studentRegister/SideBarSteps.vue'
|
||||
import SuccessModal from '@/features/auth/components/studentRegister/SuccessModal.vue'
|
||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||
@@ -40,6 +41,15 @@ import ProfessionalInformation from '@/features/auth/components/studentRegister/
|
||||
const store = useStudentRegistrationStore()
|
||||
const { isModal, openModal } = useModal()
|
||||
|
||||
const { data: registerData } = useGetRegisterDataQuery()
|
||||
watch(
|
||||
registerData,
|
||||
(list) => {
|
||||
if (Array.isArray(list) && list.length > 0) store.hydrateFromKeyValueList(list)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const STEP_TO_COMPONENT = {
|
||||
[STUDENT_REGISTRATION.PERSONAL_INFORMATION]: markRaw(PersonalInformation),
|
||||
[STUDENT_REGISTRATION.EDUCATIONAL_INFORMATION]: markRaw(EducationalInformation),
|
||||
|
||||
@@ -9,7 +9,7 @@ const requiredString = (min = 0) => {
|
||||
}
|
||||
|
||||
export const personalInformationSchema = object().shape({
|
||||
avatar: mixed().required(),
|
||||
avatar: mixed().notRequired(),
|
||||
avatarId: mixed().notRequired(),
|
||||
firstName: requiredString(3),
|
||||
lastName: requiredString(3),
|
||||
|
||||
@@ -69,6 +69,65 @@ const emptyState = () => ({
|
||||
registrationMedia: {},
|
||||
})
|
||||
|
||||
// Each field is owned by exactly one section. Used to route GET /me/register-data
|
||||
// values back into the matching slice on hydration.
|
||||
const SECTION_FIELDS = {
|
||||
personal: [
|
||||
'avatar',
|
||||
'avatarId',
|
||||
'firstName',
|
||||
'lastName',
|
||||
'birthDate',
|
||||
'nationalCode',
|
||||
'maritalStatus',
|
||||
'gender',
|
||||
'phoneNumber',
|
||||
'provinceId',
|
||||
'cityId',
|
||||
'address',
|
||||
],
|
||||
educational: [
|
||||
'educationStatus',
|
||||
'seminaryLevel',
|
||||
'universityLevel',
|
||||
'universityName',
|
||||
'fieldOfStudy',
|
||||
'workExperienceSummary',
|
||||
'activitySummary',
|
||||
],
|
||||
professional: [
|
||||
'propagationExperienceYears',
|
||||
'propagationMethodDescription',
|
||||
'specializedTopics',
|
||||
'propagationPlatforms',
|
||||
],
|
||||
skill1: ['responseToLowSatisfaction', 'responseToLowSatisfactionDescription'],
|
||||
skill2: ['responseToSessionCancellation', 'responseToSessionCancellationDescription'],
|
||||
skill3: ['responseToAudienceConflict', 'responseToAudienceConflictDescription'],
|
||||
skill4: ['responseToCompetingPropagator', 'responseToCompetingPropagatorDescription'],
|
||||
skill5: ['responseToUnqualifiedAdvisors', 'relevantCertificates', 'hijabApproach'],
|
||||
skill6: ['faithProductionAudio', 'faithProductionId'],
|
||||
skill7: ['leaderMessageVideo', 'leaderMessageId'],
|
||||
}
|
||||
|
||||
const FIELD_TO_SECTION = Object.entries(SECTION_FIELDS).reduce((acc, [section, fields]) => {
|
||||
fields.forEach((field) => {
|
||||
acc[field] = section
|
||||
})
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
export const toKeyValueList = (obj = {}) =>
|
||||
Object.entries(obj).map(([key, value]) => ({ key, value }))
|
||||
|
||||
export const fromKeyValueList = (list = []) => {
|
||||
if (!Array.isArray(list)) return {}
|
||||
return list.reduce((acc, item) => {
|
||||
if (item && typeof item === 'object' && 'key' in item) acc[item.key] = item.value
|
||||
return acc
|
||||
}, {})
|
||||
}
|
||||
|
||||
const readPersisted = () => {
|
||||
try {
|
||||
const raw = localStorage.getItem(STORAGE_KEY)
|
||||
@@ -98,6 +157,19 @@ export const useStudentRegistrationStore = defineStore('studentRegistration', ()
|
||||
const completedSteps = ref(initial.completedSteps || [])
|
||||
const registrationMedia = ref(initial.registrationMedia || {})
|
||||
|
||||
const sectionRefs = {
|
||||
personal,
|
||||
educational,
|
||||
professional,
|
||||
skill1,
|
||||
skill2,
|
||||
skill3,
|
||||
skill4,
|
||||
skill5,
|
||||
skill6,
|
||||
skill7,
|
||||
}
|
||||
|
||||
const snapshot = computed(() => ({
|
||||
isProfileCompleted: isProfileCompleted.value,
|
||||
personal: personal.value,
|
||||
@@ -171,6 +243,22 @@ export const useStudentRegistrationStore = defineStore('studentRegistration', ()
|
||||
: personal.value.avatarId,
|
||||
})
|
||||
|
||||
// Take the flat `{key,value}` list from GET /me/register-data and slot each
|
||||
// value into the right section ref, leaving anything we don't recognise alone.
|
||||
const hydrateFromKeyValueList = (list) => {
|
||||
const flat = fromKeyValueList(list)
|
||||
const buckets = {}
|
||||
Object.entries(flat).forEach(([key, value]) => {
|
||||
const section = FIELD_TO_SECTION[key]
|
||||
if (!section) return
|
||||
buckets[section] = { ...(buckets[section] || {}), [key]: value }
|
||||
})
|
||||
Object.entries(buckets).forEach(([section, patch]) => {
|
||||
const target = sectionRefs[section]
|
||||
if (target) target.value = { ...target.value, ...patch }
|
||||
})
|
||||
}
|
||||
|
||||
const reset = () => {
|
||||
const fresh = emptyState()
|
||||
isProfileCompleted.value = fresh.isProfileCompleted
|
||||
@@ -215,6 +303,7 @@ export const useStudentRegistrationStore = defineStore('studentRegistration', ()
|
||||
goToPrevStep,
|
||||
canGoToStep,
|
||||
buildCompletePayload,
|
||||
hydrateFromKeyValueList,
|
||||
reset,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -295,23 +295,27 @@ const { data: profile } = useGetMeQuery()
|
||||
|
||||
watch(profile, (user) => {
|
||||
if (!user) return
|
||||
const nameParts = String(user.name || '').trim().split(/\s+/).filter(Boolean)
|
||||
const firstName = user.firstName || nameParts[0] || ''
|
||||
const lastName = user.lastName || nameParts.slice(1).join(' ') || ''
|
||||
const phone = user.phone || user.phoneNumber || ''
|
||||
form.value = {
|
||||
...form.value,
|
||||
firstName: user.firstName || '',
|
||||
lastName: user.lastName || '',
|
||||
firstName,
|
||||
lastName,
|
||||
birthDate: user.profile?.birthDate || '',
|
||||
nationalCode: user.nationalCode || '',
|
||||
maritalStatus: user.profile?.maritalStatus || '',
|
||||
gender: user.profile?.gender || '',
|
||||
bio: user.profile?.bio || '',
|
||||
phoneNumber: user.phoneNumber || '',
|
||||
phoneNumber: phone,
|
||||
provinceId: user.address?.province?.id || '',
|
||||
cityId: user.address?.city?.id || '',
|
||||
address: user.address?.address || '',
|
||||
avatarId: user.profile?.avatarId || null,
|
||||
}
|
||||
initialNationalCode.value = user.nationalCode || ''
|
||||
initialPhoneNumber.value = user.phoneNumber || ''
|
||||
initialPhoneNumber.value = phone
|
||||
if (user.avatarUrl) avatar.value = { url: user.avatarUrl }
|
||||
})
|
||||
|
||||
@@ -336,11 +340,21 @@ const updateMutation = useUpdateProfileMutation()
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
if (!payload.password) {
|
||||
delete payload.password
|
||||
delete payload.passwordConfirmation
|
||||
// Backend PATCH /me accepts: name, email, phone, password (+confirmation),
|
||||
// avatar_media_id. Other UI-only fields (province/city/address/birthDate/…)
|
||||
// are not in the backend Postman doc and are dropped here.
|
||||
const name = [payload.firstName, payload.lastName].filter(Boolean).join(' ').trim()
|
||||
const body = {
|
||||
...(name ? { name } : {}),
|
||||
...(payload.phoneNumber ? { phone: payload.phoneNumber } : {}),
|
||||
...(payload.email ? { email: payload.email } : {}),
|
||||
...(payload.avatarId ? { avatarMediaId: payload.avatarId } : {}),
|
||||
}
|
||||
await updateMutation.mutateAsync(payload)
|
||||
if (payload.password) {
|
||||
body.password = payload.password
|
||||
body.passwordConfirmation = payload.passwordConfirmation
|
||||
}
|
||||
await updateMutation.mutateAsync(body)
|
||||
await queryClient.invalidateQueries({ queryKey: authKeys.me() })
|
||||
toast.success('پروفایل با موفقیت بهروز شد')
|
||||
router.push({ name: 'student-dashboard' })
|
||||
|
||||
@@ -10,5 +10,6 @@ export const apiShowAdminConsultation = (id) =>
|
||||
export const apiSendAdminConsultationMessage = (id, payload) =>
|
||||
http.post(buildUrl(endpoints.sendConsultationMessage, { id }), payload)
|
||||
|
||||
// Backend uses PATCH (not POST).
|
||||
export const apiChangeAdminConsultationStatus = (id, payload) =>
|
||||
http.post(buildUrl(endpoints.changeConsultationStatus, { id }), payload)
|
||||
http.patch(buildUrl(endpoints.changeConsultationStatus, { id }), payload)
|
||||
|
||||
@@ -15,6 +15,9 @@ export const apiDeleteAdminCourse = (id) => http.delete(buildUrl(endpoints.delet
|
||||
export const apiGetAdminCourseStudents = (courseId, params) =>
|
||||
http.get(buildUrl(endpoints.listCourseStudents, { courseId }), { params })
|
||||
|
||||
export const apiGetCourseAttendees = (courseId, params) =>
|
||||
http.get(buildUrl(endpoints.getCourseAttendees, { courseId }), { params })
|
||||
|
||||
export const apiAddAdminCourseStudent = (courseId, payload) =>
|
||||
http.post(buildUrl(endpoints.addCourseStudent, { courseId }), payload)
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ export const apiCloneAdminTerm = (id) => http.post(buildUrl(endpoints.cloneTerm,
|
||||
export const apiGetAdminTermStudents = (termId, params) =>
|
||||
http.get(buildUrl(endpoints.listUserTerm, { termId }), { params })
|
||||
|
||||
export const apiGetTermAttendees = (termId, params) =>
|
||||
http.get(buildUrl(endpoints.getTermAttendees, { termId }), { params })
|
||||
|
||||
export const apiAddAdminTermStudents = (termId, payload) =>
|
||||
http.post(buildUrl(endpoints.addUserTerm, { termId }), payload)
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { http } from '@/services/api/http'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
|
||||
// Backend (Postman: Auth) is the source of truth. Payloads use the backend's
|
||||
// field names — `name`, `phone`, `password`, `password_confirmation`,
|
||||
// `device_name`, `avatar_media_id` — and responses are passed through unchanged.
|
||||
// Callers (forms / store) are responsible for translating UI-local field names
|
||||
// (firstName/lastName/phoneNumber) into this shape.
|
||||
|
||||
export const apiLogin = (payload) => http.post(endpoints.login, payload)
|
||||
|
||||
export const apiLoginWithCode = (payload) => http.post(endpoints.loginWithCode2Step, payload)
|
||||
@@ -25,7 +31,12 @@ export const apiGetMe = () => http.get(endpoints.me)
|
||||
|
||||
export const apiCompleteProfile = (payload) => http.post(endpoints.completeProfile, payload)
|
||||
|
||||
export const apiUpdateProfile = (payload) => http.put(endpoints.updateProfile, payload)
|
||||
export const apiUpdateProfile = (payload) => http.patch(endpoints.updateProfile, payload)
|
||||
|
||||
// `data` is an array of `{ key, value }` entries. The backend echoes whatever
|
||||
// we POST back from the GET, so this is effectively a free-form key/value bag.
|
||||
export const apiGetRegisterData = () => http.get(endpoints.registerData)
|
||||
export const apiSaveRegisterData = (data) => http.post(endpoints.registerData, { data })
|
||||
|
||||
export const apiGetRegistrationQuestionVideo = () =>
|
||||
http.get(endpoints.getRegistrationQuestionVideo)
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
export const endpoints = {
|
||||
// ─── Auth & profile ────────────────────────────────────────────────────────
|
||||
register: '/register',
|
||||
// Backend-aligned (Postman: Auth collection)
|
||||
register: '/auth/register',
|
||||
login: '/auth/login',
|
||||
logout: '/auth/logout',
|
||||
me: '/auth/me',
|
||||
updateProfile: '/me',
|
||||
registerData: '/me/register-data',
|
||||
|
||||
// FE-only — NOT in backend Postman doc; kept so existing UI/mock layer works.
|
||||
resendVerificationCodeForRegister: '/resend-verification-code',
|
||||
verifyCode: '/verify-code',
|
||||
completeProfile: '/complete-profile',
|
||||
getRegistrationQuestionVideo: '/verification-registration-media',
|
||||
login: '/login',
|
||||
loginWithCode2Step: '/login-with-code',
|
||||
forgotPassword: '/forgot-password',
|
||||
verifyForgotPasswordCode: '/verify-forgot-password-code',
|
||||
resetPassword: '/reset-password',
|
||||
logout: '/logout',
|
||||
me: '/auth/me',
|
||||
updateProfile: '/profile',
|
||||
|
||||
// ─── Geo ───────────────────────────────────────────────────────────────────
|
||||
provinceList: '/provinces',
|
||||
@@ -67,6 +71,7 @@ export const endpoints = {
|
||||
showTerm: '/terms/:id',
|
||||
updateTerm: '/terms/:id',
|
||||
deleteTerm: '/terms/:id',
|
||||
getTermAttendees: '/terms/:termId/attendees',
|
||||
|
||||
// ─── Backend-aligned: Courses ──────────────────────────────────────────────
|
||||
getCoursesList: '/courses',
|
||||
@@ -74,6 +79,7 @@ export const endpoints = {
|
||||
showCourse: '/courses/:id',
|
||||
updateCourse: '/courses/:id',
|
||||
deleteCourse: '/courses/:id',
|
||||
getCourseAttendees: '/courses/:courseId/attendees',
|
||||
|
||||
// ─── Backend-aligned: Sessions ─────────────────────────────────────────────
|
||||
getSessionsList: '/sessions',
|
||||
@@ -146,16 +152,19 @@ export const endpoints = {
|
||||
getAssignmentSubmissions: '/homeworks/:homeworkId/submissions',
|
||||
showAssignmentSubmission: '/homework-submissions/:submissionId',
|
||||
|
||||
// ─── Tickets / Consultations (out of scope of Terms/Courses backend doc) ───
|
||||
// ─── Backend-aligned: Tickets ─────────────────────────────────────────────
|
||||
// Admin "messages" UI talks to /admin/tickets.
|
||||
// Admin "consultations" UI talks to /counselor/tickets (same schema; the
|
||||
// counselor scope is the consultation pool).
|
||||
getTicketsList: '/admin/tickets',
|
||||
showTicket: '/admin/tickets/:id',
|
||||
sendTicketMessage: '/admin/tickets/:id/messages',
|
||||
changeTicketStatus: '/admin/tickets/:id/status',
|
||||
|
||||
getConsultationsList: '/admin/consultations',
|
||||
showConsultation: '/admin/consultations/:id',
|
||||
sendConsultationMessage: '/admin/consultations/:id/messages',
|
||||
changeConsultationStatus: '/admin/consultations/:id/status',
|
||||
getConsultationsList: '/counselor/tickets',
|
||||
showConsultation: '/counselor/tickets/:id',
|
||||
sendConsultationMessage: '/counselor/tickets/:id/messages',
|
||||
changeConsultationStatus: '/counselor/tickets/:id/status',
|
||||
}
|
||||
|
||||
export const buildUrl = (template, params = {}) =>
|
||||
|
||||
@@ -89,7 +89,7 @@ const createInstance = (baseUrl, { headers = {}, ...configs } = {}) => {
|
||||
addResponseUnwrapInterceptor(instance)
|
||||
addCamelizeInterceptor(instance)
|
||||
addSnakizeInterceptor(instance)
|
||||
addUnauthorizeInterceptor(instance)
|
||||
// addUnauthorizeInterceptor(instance)
|
||||
return instance
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ register('GET', endpoints.me, () => ({
|
||||
data: currentMe,
|
||||
}))
|
||||
|
||||
register('PUT', endpoints.updateProfile, ({ data }) => {
|
||||
register('PATCH', endpoints.updateProfile, ({ data }) => {
|
||||
Object.assign(currentMe, {
|
||||
name: data.name ?? currentMe.name,
|
||||
email: data.email ?? currentMe.email,
|
||||
|
||||
@@ -18,6 +18,10 @@ export const useAdminConsultationsListQuery = (filtersRef, paginationRef, option
|
||||
queryKey: ['admin', 'consultations', 'list', filtersRef, paginationRef],
|
||||
queryFn: () =>
|
||||
apiGetAdminConsultations({ ...cleanFilters(filtersRef.value), ...paginationRef.value }),
|
||||
select: (response) => ({
|
||||
data: response?.data ?? [],
|
||||
meta: response?.meta,
|
||||
}),
|
||||
...options,
|
||||
})
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
apiGetAdminCourseSessions,
|
||||
apiGetAdminCourseStudents,
|
||||
apiGetAdminCourses,
|
||||
apiGetCourseAttendees,
|
||||
apiRemoveAdminCourseStudent,
|
||||
apiShowAdminCourse,
|
||||
apiUpdateAdminCourse,
|
||||
@@ -78,6 +79,21 @@ export const useAdminCourseStudentsQuery = (courseIdRef, filtersRef, paginationR
|
||||
...options,
|
||||
})
|
||||
|
||||
export const useCourseAttendeesQuery = (courseIdRef, filtersRef, paginationRef, options = {}) =>
|
||||
useQuery({
|
||||
queryKey: ['courses', 'attendees', courseIdRef, filtersRef, paginationRef],
|
||||
queryFn: () =>
|
||||
apiGetCourseAttendees(courseIdRef.value, {
|
||||
...cleanFilters(filtersRef?.value || {}),
|
||||
...paginationRef?.value,
|
||||
}),
|
||||
select: (response) => ({
|
||||
data: response?.data?.items ?? response?.data ?? [],
|
||||
meta: response?.data?.meta ?? response?.meta,
|
||||
}),
|
||||
...options,
|
||||
})
|
||||
|
||||
export const useAddAdminCourseStudentMutation = () =>
|
||||
useMutation({
|
||||
mutationFn: ({ courseId, payload }) => apiAddAdminCourseStudent(courseId, payload),
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
apiGetAdminTerms,
|
||||
apiGetAdminTermCourses,
|
||||
apiGetAdminTermStudents,
|
||||
apiGetTermAttendees,
|
||||
apiRemoveAdminTermCourse,
|
||||
apiRemoveAdminTermStudent,
|
||||
apiShowAdminTerm,
|
||||
@@ -28,6 +29,13 @@ export const adminTermsKeys = {
|
||||
filters,
|
||||
pagination,
|
||||
],
|
||||
attendees: (termId, filters, pagination) => [
|
||||
'terms',
|
||||
'attendees',
|
||||
termId,
|
||||
filters,
|
||||
pagination,
|
||||
],
|
||||
courses: (termId, filters, pagination) => [
|
||||
'admin',
|
||||
'terms',
|
||||
@@ -80,6 +88,21 @@ export const useAdminTermStudentsQuery = (termIdRef, filtersRef, paginationRef,
|
||||
...options,
|
||||
})
|
||||
|
||||
export const useTermAttendeesQuery = (termIdRef, filtersRef, paginationRef, options = {}) =>
|
||||
useQuery({
|
||||
queryKey: ['terms', 'attendees', termIdRef, filtersRef, paginationRef],
|
||||
queryFn: () =>
|
||||
apiGetTermAttendees(termIdRef.value, {
|
||||
...cleanFilters(filtersRef?.value || {}),
|
||||
...paginationRef?.value,
|
||||
}),
|
||||
select: (response) => ({
|
||||
data: response?.data?.items ?? response?.data ?? [],
|
||||
meta: response?.data?.meta ?? response?.meta,
|
||||
}),
|
||||
...options,
|
||||
})
|
||||
|
||||
export const useAddAdminTermStudentsMutation = () =>
|
||||
useMutation({
|
||||
mutationFn: ({ termId, payload }) => apiAddAdminTermStudents(termId, payload),
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
apiCompleteProfile,
|
||||
apiForgotPassword,
|
||||
apiGetMe,
|
||||
apiGetRegisterData,
|
||||
apiGetRegistrationQuestionVideo,
|
||||
apiLogin,
|
||||
apiLoginWithCode,
|
||||
@@ -11,6 +12,7 @@ import {
|
||||
apiRegister,
|
||||
apiResendVerificationCode,
|
||||
apiResetPassword,
|
||||
apiSaveRegisterData,
|
||||
apiUpdateProfile,
|
||||
apiUploadMedia,
|
||||
apiVerifyCode,
|
||||
@@ -20,6 +22,7 @@ import {
|
||||
export const authKeys = {
|
||||
me: () => ['auth', 'me'],
|
||||
registrationVideo: () => ['auth', 'registration-video'],
|
||||
registerData: () => ['auth', 'register-data'],
|
||||
}
|
||||
|
||||
export const useLoginMutation = () => useMutation({ mutationFn: apiLogin })
|
||||
@@ -63,3 +66,19 @@ export const useGetRegistrationVideoQuery = (options = {}) =>
|
||||
})
|
||||
|
||||
export const useUploadMediaMutation = () => useMutation({ mutationFn: apiUploadMedia })
|
||||
|
||||
export const useGetRegisterDataQuery = (options = {}) =>
|
||||
useQuery({
|
||||
queryKey: authKeys.registerData(),
|
||||
queryFn: () => apiGetRegisterData(),
|
||||
select: (response) => {
|
||||
const data = response?.data ?? response
|
||||
if (Array.isArray(data)) return data
|
||||
if (Array.isArray(data?.data)) return data.data
|
||||
return []
|
||||
},
|
||||
...options,
|
||||
})
|
||||
|
||||
export const useSaveRegisterDataMutation = () =>
|
||||
useMutation({ mutationFn: apiSaveRegisterData })
|
||||
|
||||
@@ -7,11 +7,48 @@ export const commonKeys = {
|
||||
cities: (provinceId) => ['common', 'cities', provinceId],
|
||||
}
|
||||
|
||||
// Sample data so the register form is usable while the backend geo endpoints
|
||||
// are still being built. Once /provinces and /provinces/:id/cities are live,
|
||||
// the real response overwrites these and the keys stay the same.
|
||||
const SAMPLE_PROVINCES = [
|
||||
{ id: 1, name: 'تهران' },
|
||||
{ id: 2, name: 'اصفهان' },
|
||||
{ id: 3, name: 'فارس' },
|
||||
{ id: 4, name: 'خراسان رضوی' },
|
||||
{ id: 5, name: 'قم' },
|
||||
]
|
||||
|
||||
const SAMPLE_CITIES_BY_PROVINCE = {
|
||||
1: [
|
||||
{ id: 101, name: 'تهران' },
|
||||
{ id: 102, name: 'ری' },
|
||||
{ id: 103, name: 'شمیرانات' },
|
||||
{ id: 104, name: 'اسلامشهر' },
|
||||
],
|
||||
2: [
|
||||
{ id: 201, name: 'اصفهان' },
|
||||
{ id: 202, name: 'کاشان' },
|
||||
{ id: 203, name: 'نجفآباد' },
|
||||
],
|
||||
3: [
|
||||
{ id: 301, name: 'شیراز' },
|
||||
{ id: 302, name: 'مرودشت' },
|
||||
{ id: 303, name: 'کازرون' },
|
||||
],
|
||||
4: [
|
||||
{ id: 401, name: 'مشهد' },
|
||||
{ id: 402, name: 'نیشابور' },
|
||||
{ id: 403, name: 'سبزوار' },
|
||||
],
|
||||
5: [{ id: 501, name: 'قم' }],
|
||||
}
|
||||
|
||||
export const useGetProvincesQuery = (options = {}) =>
|
||||
useQuery({
|
||||
queryKey: commonKeys.provinces(),
|
||||
queryFn: () => apiGetProvinces(),
|
||||
select: (response) => response?.data ?? response,
|
||||
initialData: SAMPLE_PROVINCES,
|
||||
...options,
|
||||
})
|
||||
|
||||
@@ -20,5 +57,6 @@ export const useGetCitiesOfProvinceQuery = (provinceIdRef, options = {}) =>
|
||||
queryKey: ['common', 'cities', provinceIdRef],
|
||||
queryFn: () => apiGetCitiesOfProvince(provinceIdRef.value),
|
||||
select: (response) => response?.data ?? response,
|
||||
initialData: () => SAMPLE_CITIES_BY_PROVINCE[provinceIdRef.value] || [],
|
||||
...options,
|
||||
})
|
||||
|
||||
+6
-1
@@ -7,7 +7,12 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
const user = ref(tokenService.getUserInfo())
|
||||
|
||||
const isAuthenticated = computed(() => !!tokenService.getToken() && !!user.value)
|
||||
const role = computed(() => user.value?.role || user.value?.roleName || null)
|
||||
const role = computed(() => {
|
||||
const u = user.value
|
||||
if (!u) return null
|
||||
if (Array.isArray(u.roles) && u.roles.length) return u.roles[0]
|
||||
return u.role || u.roleName || null
|
||||
})
|
||||
|
||||
const setUser = (userData) => {
|
||||
user.value = userData
|
||||
|
||||
Reference in New Issue
Block a user