fix
Deploy banu-front / deploy (push) Successful in 1m20s

This commit is contained in:
sajjadtalkhabi
2026-06-27 20:07:58 +03:30
parent 2c617258f4
commit e700609236
22 changed files with 236 additions and 177 deletions
+24 -4
View File
@@ -121,6 +121,23 @@ let mediaStream = null
let chunks = []
let timerHandle = null
let timerStart = 0
let recorderType = null
// The backend only accepts these audio extensions. Browsers can't record mp3/wav,
// but most can record into an mp4 container (→ .m4a), so prefer a supported type
// whose extension the backend allows; fall back to webm only as a last resort.
const ACCEPTED_AUDIO_TYPES = [
{ mime: 'audio/mp4', ext: 'm4a' },
{ mime: 'audio/mpeg', ext: 'mp3' },
{ mime: 'audio/wav', ext: 'wav' },
]
const pickRecorderType = () => {
const supported = ACCEPTED_AUDIO_TYPES.find((c) =>
window.MediaRecorder?.isTypeSupported?.(c.mime)
)
return supported || { mime: 'audio/webm', ext: 'webm' }
}
const formattedTime = computed(() => {
const s = Math.floor(elapsedMs.value / 1000)
@@ -163,16 +180,19 @@ const startRecording = async () => {
try {
mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true })
chunks = []
mediaRecorder = new window.MediaRecorder(mediaStream)
recorderType = pickRecorderType()
mediaRecorder = new window.MediaRecorder(mediaStream, { mimeType: recorderType.mime })
mediaRecorder.ondataavailable = (e) => {
if (e.data?.size > 0) chunks.push(e.data)
}
mediaRecorder.onstop = () => {
isRecording.value = false
stopTracks()
const blob = new Blob(chunks, { type: 'audio/webm' })
const file = new File([blob], `recording-${Date.now()}.webm`, {
type: 'audio/webm',
const mime = recorderType?.mime || mediaRecorder?.mimeType || 'audio/webm'
const ext = recorderType?.ext || 'webm'
const blob = new Blob(chunks, { type: mime })
const file = new File([blob], `recording-${Date.now()}.${ext}`, {
type: mime,
lastModified: Date.now(),
})
setRecording(file)
@@ -21,10 +21,6 @@
</div>
<div class="assignment-details__grid">
<LineInfoBlock
title="تاریخ شروع"
:numeric-desc="formatJalaaliDate(assignment.startDate) || ''"
/>
<LineInfoBlock title="تاریخ پایان" :numeric-desc="deadlineLabel" />
<LineInfoBlock title="مدت زمان" :numeric-desc="durationLabel" />
<LineInfoBlock title="اولویت" :desc="priorityLabel" />
@@ -198,7 +198,6 @@ const normalizeExistingQuestions = (raw = []) => {
optionText: o.optionText || '',
isCorrect: !!o.isCorrect,
})),
// No `__local` flag — these came from the server, so the builder will lock them.
}
})
}
@@ -280,7 +279,6 @@ const submitting = computed(
const postQuestionsSequentially = async (id, list) => {
for (const payload of list) {
// Sequential so question position ordering is preserved on the backend.
// eslint-disable-next-line no-await-in-loop
await addQuestionMutation.mutateAsync({ examId: id, payload })
}
@@ -302,7 +300,7 @@ const onSubmit = async () => {
if (targetExamId && newQuestions.length > 0) {
await postQuestionsSequentially(targetExamId, newQuestions)
}
await queryClient.invalidateQueries({ queryKey: adminExamsKeys.all })
await queryClient.invalidateQueries({ queryKey: adminExamsKeys.all, refetchType: 'all' })
router.push({ name: 'admin-exams' })
}
@@ -59,7 +59,8 @@ const { data, isLoading } = useAdminTicketsListQuery(filters, pagination, {
keepPreviousData: true,
})
const tickets = computed(() => data.value?.data ?? [])
const tickets = computed(() => data.value?.items ?? [])
const paginationMeta = computed(() => ({
page: pagination.value.page,
perPage: pagination.value.perPage,
@@ -39,11 +39,9 @@
:src="mediaUrl"
:video-id="session.id"
/>
<VoiceRecorder
v-else-if="contentType === 'voice'"
:model-value="mediaUrl"
:disabled="true"
/>
<div v-else-if="contentType === 'voice'" class="session-details__voice">
<VoiceRecorder :model-value="mediaUrl" :disabled="true" />
</div>
<a
v-else-if="mediaUrl"
:href="mediaUrl"
@@ -111,9 +109,9 @@ const courseTitle = computed(() => session.value?.course?.title || '—')
const isOnline = computed(() => session.value?.type === 'online')
const collectionToContentType = (collectionName) => {
if (collectionName === 'videos') return 'video'
if (collectionName === 'video') return 'video'
if (collectionName === 'voice') return 'voice'
if (collectionName === 'pdfs') return 'text'
if (collectionName === 'pdf') return 'text'
return ''
}
@@ -173,6 +171,22 @@ const mediaFileName = computed(() => contentMedia.value?.fileName || 'فایل
justify-content: center;
}
&__voice {
width: 100%;
/* stylelint-disable-next-line selector-class-pattern */
:deep(.voice-recorder) {
min-height: auto;
padding: 0.75rem;
}
/* stylelint-disable-next-line selector-class-pattern */
:deep(.voice-recorder__main-btn) {
width: 4rem;
height: 4rem;
}
}
&__file {
display: inline-flex;
align-items: center;
@@ -357,7 +357,10 @@ const onSubmit = async () => {
} else {
await addMutation.mutateAsync(payload)
}
await queryClient.invalidateQueries({ queryKey: adminSessionsKeys.all })
// The list query is inactive while we're on the form page, and the global
// `refetchOnMount: false` means navigating back won't refetch a merely-stale
// query — so force a refetch of all matching queries, active or not.
await queryClient.invalidateQueries({ queryKey: adminSessionsKeys.all, refetchType: 'all' })
router.push({ name: 'admin-sessions' })
}
@@ -17,19 +17,19 @@
<LineInfoBlock title="نام و نام خانوادگی" :numeric-desc="fullName" />
<LineInfoBlock
title="تاریخ تولد"
:numeric-desc="profile.faBirthDate || formatJalaaliDate(profile.birthDate) || ''"
:numeric-desc="formatJalaaliDate(personal.birthDate) || ''"
/>
<LineInfoBlock title="شماره تماس" :numeric-desc="user.phoneNumber" />
<LineInfoBlock title="کد ملی" :numeric-desc="user.nationalCode" />
<LineInfoBlock title="شماره تماس" :numeric-desc="personal.phone" />
<LineInfoBlock title="کد ملی" :numeric-desc="personal.nationalCode" />
<LineInfoBlock
title="وضعیت تاهل"
:desc="profile.faMaritalStatus || MARITAL_STATUS[profile.maritalStatus] || ''"
:desc="MARITAL_STATUS[personal.maritalStatus] || ''"
/>
<LineInfoBlock title="جنسیت" :desc="profile.faGender || GENDER[profile.gender] || ''" />
<LineInfoBlock title="استان" :desc="user?.province?.name || '-'" />
<LineInfoBlock title="شهر" :desc="user?.city?.name || '-'" />
<LineInfoBlock title="جنسیت" :desc="GENDER[personal.gender] || ''" />
<LineInfoBlock title="استان" :desc="personal.province || '-'" />
<LineInfoBlock title="شهر" :desc="personal.city || '-'" />
<div class="user-verification-details__cell user-verification-details__cell--span-3">
<LineInfoBlock title="آدرس" :desc="user?.address || '-'" />
<LineInfoBlock title="آدرس" :desc="personal.address || '-'" />
</div>
</div>
</section>
@@ -39,15 +39,15 @@
<div class="user-verification-details__grid user-verification-details__grid--4">
<LineInfoBlock
title="وضعیت تحصیلی"
:desc="profile.faEducationStatus || EDUCATION_STATUS[profile.educationStatus] || ''"
:desc="EDUCATION_STATUS[profile.educationStatus] || ''"
/>
<LineInfoBlock
title="آخرین مدرک تحصیلی (طلبه)"
:desc="profile.faSeminaryLevel || SEMINARY_LEVEL[profile.seminaryLevel] || ''"
:desc="SEMINARY_LEVEL[profile.seminaryLevel] || ''"
/>
<LineInfoBlock
title="آخرین مدرک تحصیلی"
:desc="profile.faUniversityLevel || UNIVERSITY_LEVEL[profile.universityLevel] || ''"
:desc="UNIVERSITY_LEVEL[profile.universityLevel] || ''"
/>
<LineInfoBlock title="نام حوزه علمیه/دانشگاه" :desc="profile.universityName || ''" />
<div class="user-verification-details__cell user-verification-details__cell--full">
@@ -56,30 +56,12 @@
:desc="profile.fieldOfStudy || ''"
/>
</div>
<div class="user-verification-details__cell user-verification-details__cell--full">
<LineInfoBlock
title="خلاصه‌ای از سوابق شغلی"
:desc="profile.workExperienceSummary || ''"
/>
</div>
<div class="user-verification-details__cell user-verification-details__cell--full">
<LineInfoBlock
title="خلاصه‌ای از فعالیت‌ها در موقعیت‌های شغلی"
:desc="profile.activitySummary || ''"
/>
</div>
</div>
</section>
<section class="user-verification-details__section">
<LineTitleBlock title="اطلاعات شغلی" title-en="Job information" />
<div class="user-verification-details__grid user-verification-details__grid--4">
<div class="user-verification-details__cell user-verification-details__cell--full">
<LineInfoBlock
title="گرایش تخصصی حوزوی / رشته تحصیلی دانشگاهی"
:desc="profile.fieldOfStudy || ''"
/>
</div>
<div class="user-verification-details__cell user-verification-details__cell--full">
<LineInfoBlock
title="خلاصه‌ای از سوابق شغلی"
@@ -190,7 +172,9 @@
<section v-if="faithProduction?.url" class="user-verification-details__section">
<LineTitleBlock title="بخش صوت" title-en="Audio section" />
<LineInfoBlock title="نظر و تحلیل از ویدئو ارائه شده" />
<audio :src="faithProduction.url" controls class="user-verification-details__audio" />
<div class="user-verification-details__voice">
<VoiceRecorder :model-value="faithProduction" disabled />
</div>
</section>
<section v-if="leaderMessage?.url" class="user-verification-details__section">
@@ -214,6 +198,7 @@ import useModal from '@/composables/useModal'
import BasicModal from '@/components/BasicModal.vue'
import { formatJalaaliDate } from '@/utils/date-utils'
import LineTitleBlock from '@/components/LineTitleBlock.vue'
import VoiceRecorder from '@/components/form/VoiceRecorder.vue'
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
import { useAdminUserQuery, useAdminUserRegisterDataQuery } from '@/services/query/admin-users'
import {
@@ -227,7 +212,6 @@ import {
SEMINARY_LEVEL,
SESSION_CANCELLATION_RESPONSE,
UNIVERSITY_LEVEL,
VERIFICATION_MEDIA_TYPE,
} from '@/enums'
defineOptions({ name: 'UserVerificationDetailsModal' })
@@ -248,15 +232,23 @@ const { data: registerData } = useAdminUserRegisterDataQuery(userIdRef, {
const user = computed(() => modalData.value.user || fetched.value || null)
// The register-data endpoint returns the answers the user gave during the
// registration steps — the same fields the sections below render. Merge it over
// the user's stored profile so reviewing admins see what was actually submitted.
const profile = computed(() => ({ ...user.value?.profile, ...registerData.value }))
const fullName = computed(
() =>
user.value?.name || `${user.value?.firstName || ''} ${user.value?.lastName || ''}`.trim() || '—'
)
const fullName = computed(() => user.value?.name || '—')
const personal = computed(() => {
const u = user.value || {}
const p = u.profile || {}
return {
birthDate: u.birthday || p.birthDate || '',
phone: u.phone || u.phoneNumber || '',
nationalCode: u.nationalCode || '',
maritalStatus: u.marriageStatus || p.maritalStatus || '',
gender: u.gender || p.gender || '',
address: typeof u.address === 'string' ? u.address : u.address?.address || '',
province: u.province?.name || u.address?.province?.name || '',
city: u.city?.name || u.address?.city?.name || '',
}
})
const platforms = computed(() =>
Array.isArray(profile.value.propagationPlatforms) ? profile.value.propagationPlatforms : []
@@ -276,13 +268,10 @@ const onlinePlatformDetails = computed(
() => platforms.value.find((p) => p.platform === 'online')?.platformDetails || ''
)
const verificationMedia = computed(() => user.value?.verification?.media || [])
const faithProduction = computed(() =>
verificationMedia.value.find((m) => m.type === VERIFICATION_MEDIA_TYPE.FAITH_PRODUCTION)
)
const leaderMessage = computed(() =>
verificationMedia.value.find((m) => m.type === VERIFICATION_MEDIA_TYPE.LEADER_MESSAGE)
)
// Skill parts 6 & 7 store the uploaded media objects in register-data under
// `faithProductionAudio` / `leaderMessageVideo` (each carries a `url`).
const faithProduction = computed(() => profile.value.faithProductionAudio || null)
const leaderMessage = computed(() => profile.value.leaderMessageVideo || null)
</script>
<style lang="scss" scoped>
@@ -428,6 +417,22 @@ const leaderMessage = computed(() =>
margin-top: 0.5rem;
}
&__voice {
margin-top: 0.5rem;
/* stylelint-disable-next-line selector-class-pattern */
:deep(.voice-recorder) {
min-height: auto;
padding: 0.75rem;
}
/* stylelint-disable-next-line selector-class-pattern */
:deep(.voice-recorder__main-btn) {
width: 4rem;
height: 4rem;
}
}
&__divider {
border-block-end: 1px solid var(--color-thd-gray);
margin-block: 1.5rem;
@@ -14,13 +14,13 @@
</AuthHeading>
<TextField
v-model="form.verifyCode"
name="verifyCode"
v-model="form.code"
name="code"
label="کد تایید را وارد کنید"
inputmode="numeric"
:convert-digits="true"
:error="errors.verifyCode"
@blur="validateAt('verifyCode', form.verifyCode)"
:error="errors.code"
@blur="validateAt('code', form.code)"
>
<template #appendIcon>
<SvgIcon name="check" :size="22" color="var(--color-thd-gray)" />
@@ -74,7 +74,7 @@ const props = defineProps({
const emit = defineEmits(['back', 'verified'])
const schema = verifyCodeSchema
const form = ref({ verifyCode: '' })
const form = ref({ code: '' })
const { validate, validateAt, errors } = useYup(schema)
const { applySession } = useAuth()
@@ -106,7 +106,7 @@ const resending = computed(
const onSubmit = async () => {
const { isValid, payload } = await validate(form.value)
if (!isValid) return
const code = payload.verifyCode
const code = payload.code
if (props.mode === 'loginWithCode') {
const response = await verifyLoginMutation.mutateAsync({
@@ -127,8 +127,10 @@ const onSubmit = async () => {
return
}
await verifySignupMutation.mutateAsync({ phone: props.phoneNumber, verifyCode: code })
emit('verified', { phone: props.phoneNumber, verifyCode: code })
const response = await verifySignupMutation.mutateAsync({ phone: props.phoneNumber, code })
applySession(response?.data ?? response)
emit('verified', { phone: props.phoneNumber, code })
redirectAfterLogin()
}
const onResend = async () => {
@@ -112,6 +112,32 @@ let mediaStream = null
let chunks = []
let timerHandle = null
let timerStart = 0
let recorderType = null
// The backend only accepts these extensions. Browsers can't record mp3/wav, but
// most can record into an mp4 container (→ .m4a audio / .mp4 video), so prefer a
// supported type whose extension the backend allows.
const ACCEPTED_TYPES = {
audio: [
{ mime: 'audio/mp4', ext: 'm4a' },
{ mime: 'audio/mpeg', ext: 'mp3' },
{ mime: 'audio/wav', ext: 'wav' },
],
video: [
{ mime: 'video/mp4', ext: 'mp4' },
{ mime: 'video/webm', ext: 'webm' },
],
}
const pickRecorderType = (kind) => {
const candidates = ACCEPTED_TYPES[kind] || []
const supported = candidates.find((c) => window.MediaRecorder?.isTypeSupported?.(c.mime))
if (supported) return supported
// Last-resort fallbacks so recording still works even if extensions differ.
return kind === 'video'
? { mime: 'video/webm', ext: 'webm' }
: { mime: 'audio/webm', ext: 'webm' }
}
const hintText = computed(() =>
props.kind === 'video' ? 'ویدیوی خود را ضبط کنید' : 'صدای خود را ضبط کنید'
@@ -148,7 +174,8 @@ const onStart = async () => {
liveEl.value.srcObject = mediaStream
}
chunks = []
mediaRecorder = new window.MediaRecorder(mediaStream)
recorderType = pickRecorderType(props.kind)
mediaRecorder = new window.MediaRecorder(mediaStream, { mimeType: recorderType.mime })
mediaRecorder.ondataavailable = (e) => {
if (e.data?.size > 0) chunks.push(e.data)
}
@@ -176,9 +203,9 @@ const onStop = () => {
const handleStop = async () => {
isRecording.value = false
stopTracks()
const mime = props.kind === 'video' ? 'video/webm' : 'audio/webm'
const mime = recorderType?.mime || mediaRecorder?.mimeType || 'audio/webm'
const ext = recorderType?.ext || 'webm'
const blob = new Blob(chunks, { type: mime })
const ext = props.kind === 'video' ? 'webm' : 'webm'
const file = new File([blob], `recording.${ext}`, { type: mime, lastModified: Date.now() })
if (previewUrl.value && previewUrl.value.startsWith('blob:')) {
@@ -17,24 +17,11 @@
<div class="personal-info__row">
<div class="personal-info__cell">
<TextField
v-model="form.firstName"
name="firstName"
label="نام"
:error="errors.firstName"
@blur="validateAt('firstName', form.firstName)"
>
<template #appendIcon>
<SvgIcon name="user" :size="20" color="var(--color-thd-gray)" />
</template>
</TextField>
</div>
<div class="personal-info__cell">
<TextField
v-model="form.lastName"
name="lastName"
label="نام خانوادگی"
:error="errors.lastName"
@blur="validateAt('lastName', form.lastName)"
v-model="form.name"
name="name"
label="نام و نام خانوادگی"
:error="errors.name"
@blur="validateAt('name', form.name)"
>
<template #appendIcon>
<SvgIcon name="user" :size="20" color="var(--color-thd-gray)" />
@@ -57,6 +44,7 @@
label="کد ملی"
inputmode="numeric"
:convert-digits="true"
:disabled="!!initialNationalCode"
:error="errors.nationalCode"
@blur="validateAt('nationalCode', form.nationalCode)"
>
@@ -153,7 +141,7 @@
<StepActions
:show-back="false"
:loading="uploadMutation.isPending.value || saveRegisterMutation.isPending.value"
:loading="uploadMutation.isPending.value || updateProfileMutation.isPending.value"
/>
</form>
</template>
@@ -164,6 +152,7 @@ import useYup from '@/composables/useYup'
import useAuth from '@/composables/useAuth'
import SvgIcon from '@/components/icons/SvgIcon.vue'
import { convertToJalali } from '@/utils/date-utils'
import { useQueryClient } from '@tanstack/vue-query'
import TextField from '@/components/form/TextField.vue'
import SelectField from '@/components/form/SelectField.vue'
import LineTitleBlock from '@/components/LineTitleBlock.vue'
@@ -173,15 +162,15 @@ import TextareaField from '@/components/form/TextareaField.vue'
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'
import { authKeys, useUpdateProfileMutation, useUploadMediaMutation } from '@/services/query/auth'
const store = useStudentRegistrationStore()
const { user } = useAuth()
const queryClient = useQueryClient()
const isMobile = ref(window.innerWidth < 768)
const onResize = () => {
@@ -207,12 +196,12 @@ const maxBirthDate = computed(() => {
})
const initialPhone = ref(user.value?.phone || store.personal.phone || '')
const initialNationalCode = ref(user.value?.nationalCode || store.personal.nationalCode || '')
const form = ref({
firstName: store.personal.firstName || '',
lastName: store.personal.lastName || '',
name: user.value?.name || store.personal.name || '',
birthDate: store.personal.birthDate || '',
nationalCode: store.personal.nationalCode || '',
nationalCode: initialNationalCode.value,
maritalStatus: store.personal.maritalStatus || '',
gender: store.personal.gender || '',
phone: initialPhone.value,
@@ -264,13 +253,30 @@ const onAvatarCropped = async (file) => {
const onAvatarError = (msg) => toast.error(msg)
const saveRegisterMutation = useSaveRegisterDataMutation()
const updateProfileMutation = useUpdateProfileMutation()
const onSubmit = async () => {
const { isValid, payload } = await validate(form.value)
if (!isValid) return
const next = { ...payload, avatar: form.value.avatar }
await saveRegisterMutation.mutateAsync(toKeyValueList(next))
// Personal info maps to the user model and is persisted via PATCH /me.
// (http auto-converts camelCase → snake_case: birthday, national_code, …)
const body = {
name: payload.name,
birthday: payload.birthDate,
nationalCode: payload.nationalCode,
marriageStatus: payload.maritalStatus,
gender: payload.gender,
phone: payload.phone,
provinceId: payload.provinceId,
cityId: payload.cityId,
address: payload.address,
...(form.value.avatar?.uploadId
? { avatarMediaId: Number.parseInt(form.value.avatar.uploadId) }
: {}),
}
await updateProfileMutation.mutateAsync(body)
await queryClient.invalidateQueries({ queryKey: authKeys.me() })
store.personal = { ...store.personal, ...next }
store.markStepAsCompleted(STUDENT_REGISTRATION.PERSONAL_INFORMATION)
store.goToNextStep()
+1 -1
View File
@@ -24,7 +24,7 @@ const router = useRouter()
const step = ref(SIGNUP_STEPS.SIGNUP)
const phoneNumber = ref('')
const handleNext = ({ phoneNumber: phone }) => {
const handleNext = ({ phone }) => {
phoneNumber.value = phone
step.value = SIGNUP_STEPS.VERIFY_CODE
}
+1 -1
View File
@@ -21,7 +21,7 @@ export const signupSchema = object().shape({
})
export const verifyCodeSchema = object().shape({
verifyCode: string().required().length(6),
code: string().required().length(6),
})
export const resetPasswordSchema = object().shape({
+2 -3
View File
@@ -11,13 +11,12 @@ const requiredString = (min = 0) => {
export const personalInformationSchema = object().shape({
avatar: mixed().notRequired(),
avatarId: mixed().notRequired(),
firstName: requiredString(3),
lastName: requiredString(3),
name: requiredString(3),
birthDate: string().required(),
nationalCode: nationalCodeRule,
maritalStatus: string().required(),
gender: string().required(),
phoneNumber: phoneNumberRule,
phone: phoneNumberRule,
provinceId: mixed().required(),
cityId: mixed().required(),
address: requiredString(10),
@@ -9,8 +9,7 @@ const emptyState = () => ({
personal: {
avatar: null,
avatarId: '',
firstName: '',
lastName: '',
name: '',
birthDate: '',
nationalCode: '',
maritalStatus: '',
@@ -75,8 +74,7 @@ const SECTION_FIELDS = {
personal: [
'avatar',
'avatarId',
'firstName',
'lastName',
'name',
'birthDate',
'nationalCode',
'maritalStatus',
@@ -5,12 +5,6 @@
<div class="ses__stats">
<div class="ses__stat">
<SvgIcon name="check" :size="12" color="#5d5d5d" />
<span class="ses__stat-label">تعداد آزمونها :</span>
<span class="ses__stat-value">{{ attemptsCountText }}</span>
</div>
<div class="ses__stat">
<SvgIcon name="scroll" :size="12" color="#5d5d5d" />
<span class="ses__stat-label">تعداد سوال :</span>
<span class="ses__stat-value">{{ questionsCountText }}</span>
</div>
@@ -65,11 +59,6 @@ const props = defineProps({
const emit = defineEmits(['start'])
const attemptsCountText = computed(() =>
props.exam.attemptsCount == null
? `${(props.exam.attempts || []).length} آزمون`
: `${props.exam.attemptsCount} آزمون`
)
const questionsCountText = computed(() =>
props.exam.questionsCount == null ? '—' : `${props.exam.questionsCount}`
)
@@ -14,12 +14,12 @@
<p class="student-lesson-item__title">{{ lesson.title || '—' }}</p>
<Badge
variant="primary"
label="زمان یادگیری :"
:value="hoursText"
label="ظرفیت :"
:value="capacityText"
class="student-lesson-item__hours"
>
<template #prepend>
<SvgIcon name="calendar" :size="11" color="#007074" />
<SvgIcon name="users-three" :size="11" color="#007074" />
</template>
</Badge>
</div>
@@ -75,8 +75,8 @@ const props = defineProps({
const emit = defineEmits(['show-details'])
const hoursText = computed(() =>
props.lesson.learningHours == null ? '—' : `${props.lesson.learningHours} ساعت`
const capacityText = computed(() =>
props.lesson.capacity == null ? '—' : `${props.lesson.capacity} نفر`
)
const sessionsText = computed(() =>
props.lesson.sessionsCount == null ? '—' : `${props.lesson.sessionsCount} جلسه`
@@ -41,11 +41,11 @@
<div class="edit-profile__cell edit-profile__cell--third">
<DatePickerField
v-model="form.birthDate"
name="birthDate"
v-model="form.birthday"
name="birthday"
label="تاریخ تولد"
:max="todayIso"
:error="errors.birthDate"
:error="errors.birthday"
/>
</div>
<div class="edit-profile__cell edit-profile__cell--third">
@@ -253,7 +253,7 @@ const initialPhoneNumber = ref('')
const form = ref({
name: '',
birthDate: '',
birthday: '',
nationalCode: '',
marriageStatus: '',
gender: '',
@@ -298,7 +298,9 @@ const onProvinceChange = () => {
const { data: profile } = useGetMeQuery()
watch(profile, (user) => {
watch(
profile,
(user) => {
if (!user) return
const fullName =
user.name || [user.firstName, user.lastName].filter(Boolean).join(' ').trim() || ''
@@ -306,26 +308,28 @@ watch(profile, (user) => {
form.value = {
...form.value,
name: fullName,
birthDate: user.profile?.birthDate || '',
birthday: user?.birthday || '',
nationalCode: user.nationalCode || '',
marriageStatus: user.profile?.marriageStatus || '',
gender: user.profile?.gender || '',
marriageStatus: user?.marriageStatus || '',
gender: user?.gender || '',
phone,
provinceId: user?.province?.id || '',
cityId: user?.city?.id || '',
address: user?.address || '',
avatarMediaId: user.profile?.avatarMediaId || null,
avatarMediaId: user?.avatarMediaId || null,
}
initialNationalCode.value = user.nationalCode || ''
initialPhoneNumber.value = phone
if (user.avatarUrl) avatar.value = { url: user.avatarUrl }
})
},
{ immediate: true }
)
const uploadMutation = useUploadMediaMutation()
const onAvatarCropped = async (file) => {
try {
const formData = objectToFormData({ file, subType: 'avatar', context: 'user' })
const formData = objectToFormData({ file, purpose: 'avatar', context: 'user' })
const response = await uploadMutation.mutateAsync(formData)
const payload = response?.data ?? response
avatar.value = { url: payload?.url, uploadId: payload?.uploadId, ...payload }
@@ -344,7 +348,7 @@ const onSubmit = async () => {
const { isValid, payload } = await validate(form.value)
if (!isValid) return
// Backend PATCH /me accepts: name, email, phone, avatar_media_id.
// Other UI-only fields (province/city/address/birthDate/…) are not in
// Other UI-only fields (province/city/address/birthday/…) are not in
// the backend Postman doc and are dropped here. Password is handled
// separately via POST /reset-password.
const body = {
@@ -471,7 +475,7 @@ const onCancel = () => router.push({ name: 'student-dashboard' })
&__actions {
display: flex;
justify-content: flex-end;
gap: 0.625rem;
justify-content: space-between;
margin-top: 1rem;
}
+1 -1
View File
@@ -9,7 +9,7 @@ export const studentProfileSchema = object().shape({
name: string().required().min(2),
phone: phoneNumberRule,
nationalCode: nationalCodeRule,
birthDate: string().nullable().notRequired(),
birthday: string().nullable().notRequired(),
marriageStatus: string().nullable().notRequired(),
gender: string().nullable().notRequired(),
provinceId: string().nullable().notRequired(),
@@ -4,8 +4,8 @@
<p class="student-session-item__title">{{ session.title || '—' }}</p>
<div class="student-session-item__hours">
<SvgIcon name="calendar" :size="9" color="#007074" />
<span class="student-session-item__hours-label">زمان جلسه :</span>
<span class="student-session-item__hours-value">{{ durationText }}</span>
<span class="student-session-item__hours-label">مهلت :</span>
<span class="student-session-item__hours-value">{{ deadlineText }}</span>
</div>
</div>
@@ -13,8 +13,8 @@
<Badge v-if="isComplete" variant="success">تکمیل شده</Badge>
<Badge v-if="session.isSeen" variant="success">دیده شده</Badge>
<Badge v-if="session.grade != null" variant="primary" label="نمره" :value="session.grade" />
<Badge v-if="session.needsAssignment" icon="paper-plane">دارای تکلیف</Badge>
<Badge v-if="session.hasQuiz" icon="file">دارای آزمون</Badge>
<Badge v-if="session.homeworksCount > 0" icon="paper-plane">دارای تکلیف</Badge>
<Badge v-if="session.examsCount > 0" icon="file">دارای آزمون</Badge>
<Badge v-if="isOnline" icon="users-three">جلسه آنلاین</Badge>
</div>
@@ -37,6 +37,7 @@ import { computed } from 'vue'
import Badge from '@/components/Badge.vue'
import BaseButton from '@/components/BaseButton.vue'
import SvgIcon from '@/components/icons/SvgIcon.vue'
import { formatJalaaliDate } from '@/utils/date-utils'
const props = defineProps({
session: { type: Object, required: true },
@@ -44,8 +45,8 @@ const props = defineProps({
const emit = defineEmits(['start'])
const durationText = computed(() =>
props.session.durationHours == null ? '—' : `${props.session.durationHours} ساعت`
const deadlineText = computed(
() => formatJalaaliDate(props.session.deadline || props.session.endDate) || '—'
)
const isOnline = computed(() => props.session.type === 'online')
@@ -119,8 +119,6 @@ const { data: session, isLoading } = useStudentSessionQuery(sessionId, {
enabled: () => !!sessionId.value,
})
// The homework for this session comes from the dedicated endpoint (the session
// payload itself doesn't embed homeworks).
const homeworkFilters = computed(() => ({ sessionId: sessionId.value }))
const homeworkPagination = ref({ page: 1, perPage: 20 })
const { data: homeworksData } = useStudentHomeworksListQuery(homeworkFilters, homeworkPagination, {
@@ -152,7 +150,14 @@ const homeworkId = computed(
)
const uploadHomeworkFile = async (file) => {
const fd = objectToFormData({ file, purpose: 'homework_file', context: 'homework' })
// The backend validates allowed extensions per `purpose`: `homework_file`
// accepts documents/images only, so a recorded voice must go up as `voice`.
const isAudio = (file?.type || '').startsWith('audio/')
const fd = objectToFormData({
file,
purpose: isAudio ? 'voice' : 'homework_file',
context: 'homework',
})
const response = await uploadMediaMutation.mutateAsync(fd)
const payload = response?.data ?? response
return payload?.id ?? null
+1 -1
View File
@@ -15,7 +15,7 @@ export const endpoints = {
resetPassword: '/auth/password/reset',
resendVerificationCodeForRegister: '/resend-verification-code',
verifyCode: '/verify-code',
verifyCode: '/auth/login/otp/verify',
completeProfile: '/complete-profile',
getRegistrationQuestionVideo: '/verification-registration-media',
+1 -10
View File
@@ -13,21 +13,12 @@ export const adminTicketsKeys = {
detail: (id) => ['admin', 'tickets', 'detail', id],
}
// Backend may wrap the list as `{success, data: [...]}` (flat) or
// `{data: {data: [...], meta}}` (Laravel default). Normalize.
const selectList = (response) => {
const inner = response?.data
if (Array.isArray(inner)) return { data: inner, meta: response?.meta }
if (Array.isArray(inner?.data)) return { data: inner.data, meta: inner?.meta ?? response?.meta }
return { data: [], meta: response?.meta }
}
export const useAdminTicketsListQuery = (filtersRef, paginationRef, options = {}) =>
useQuery({
queryKey: ['admin', 'tickets', 'list', filtersRef, paginationRef],
queryFn: () =>
apiGetAdminTickets({ ...cleanFilters(filtersRef.value), ...paginationRef.value }),
select: selectList,
select: (response) => response?.data ?? response,
...options,
})