Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f86acacb0 | |||
| 81332abdb0 | |||
| e4a0eb463b | |||
| 20551fee63 | |||
| 612a6e3dfe | |||
| 861773b05b | |||
| b2f2f89181 | |||
| b64f528c0d | |||
| d94a96b25e |
@@ -7,7 +7,9 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-block__logo">
|
<div class="header-block__logo">
|
||||||
<img :src="logo" alt="logo" />
|
<a :href="MAIN_SITE_URL">
|
||||||
|
<img :src="logo" alt="logo" />
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-block__title">
|
<div class="header-block__title">
|
||||||
<slot>
|
<slot>
|
||||||
@@ -49,9 +51,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useUIStore } from '@/store/ui'
|
import { useUIStore } from '@/store/ui'
|
||||||
|
import { MAIN_SITE_URL } from '@/enums'
|
||||||
import { gallery } from '@/utils/gallery'
|
import { gallery } from '@/utils/gallery'
|
||||||
import useAuth from '@/composables/useAuth'
|
import useAuth from '@/composables/useAuth'
|
||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||||
@@ -65,7 +68,7 @@ defineProps({
|
|||||||
|
|
||||||
const ui = useUIStore()
|
const ui = useUIStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { clearSession } = useAuth()
|
const { role, clearSession } = useAuth()
|
||||||
const logoutMutation = useLogoutMutation()
|
const logoutMutation = useLogoutMutation()
|
||||||
|
|
||||||
const logo = gallery.authLogo
|
const logo = gallery.authLogo
|
||||||
@@ -98,8 +101,10 @@ const onLogout = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const userMenuItems = [
|
const userMenuItems = computed(() => [
|
||||||
{ key: 'edit-profile', label: 'ویرایش پروفایل', icon: 'pencil', onClick: goEditProfile },
|
...(role.value === 'student'
|
||||||
|
? [{ key: 'edit-profile', label: 'ویرایش پروفایل', icon: 'pencil', onClick: goEditProfile }]
|
||||||
|
: []),
|
||||||
{
|
{
|
||||||
key: 'logout',
|
key: 'logout',
|
||||||
label: 'خروج',
|
label: 'خروج',
|
||||||
@@ -107,7 +112,7 @@ const userMenuItems = [
|
|||||||
color: 'var(--color-primary)',
|
color: 'var(--color-primary)',
|
||||||
onClick: onLogout,
|
onClick: onLogout,
|
||||||
},
|
},
|
||||||
]
|
])
|
||||||
|
|
||||||
const iconList = [
|
const iconList = [
|
||||||
// { icon: 'chat', action: () => {} },
|
// { icon: 'chat', action: () => {} },
|
||||||
@@ -147,7 +152,12 @@ const iconList = [
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
|
display: block;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
height: 3.5rem;
|
height: 3.5rem;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
|
|||||||
@@ -3,9 +3,12 @@
|
|||||||
<label class="file-uploader__dropzone-wrap">
|
<label class="file-uploader__dropzone-wrap">
|
||||||
<div
|
<div
|
||||||
class="file-uploader__dropzone"
|
class="file-uploader__dropzone"
|
||||||
:class="{ 'file-uploader__dropzone--active': isDragging }"
|
:class="{
|
||||||
|
'file-uploader__dropzone--active': isDragging,
|
||||||
|
'file-uploader__dropzone--disabled': disabled,
|
||||||
|
}"
|
||||||
@dragover.prevent
|
@dragover.prevent
|
||||||
@dragenter="isDragging = true"
|
@dragenter="onDragEnter"
|
||||||
@dragleave="isDragging = false"
|
@dragleave="isDragging = false"
|
||||||
@drop="handleDrop"
|
@drop="handleDrop"
|
||||||
>
|
>
|
||||||
@@ -19,6 +22,7 @@
|
|||||||
class="file-uploader__input"
|
class="file-uploader__input"
|
||||||
:accept="accept"
|
:accept="accept"
|
||||||
:multiple="multiple"
|
:multiple="multiple"
|
||||||
|
:disabled="disabled"
|
||||||
@change="handleFileSelect"
|
@change="handleFileSelect"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -75,6 +79,7 @@ const props = defineProps({
|
|||||||
multiple: { type: Boolean, default: true },
|
multiple: { type: Boolean, default: true },
|
||||||
maxFiles: { type: Number, default: 10 },
|
maxFiles: { type: Number, default: 10 },
|
||||||
maxSize: { type: Number, default: 0 },
|
maxSize: { type: Number, default: 0 },
|
||||||
|
disabled: { type: Boolean, default: false },
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'select', 'remove', 'error'])
|
const emit = defineEmits(['update:modelValue', 'select', 'remove', 'error'])
|
||||||
@@ -82,6 +87,7 @@ const emit = defineEmits(['update:modelValue', 'select', 'remove', 'error'])
|
|||||||
const isDragging = ref(false)
|
const isDragging = ref(false)
|
||||||
|
|
||||||
const handleFileSelect = (event) => {
|
const handleFileSelect = (event) => {
|
||||||
|
if (props.disabled) return
|
||||||
const files = [...event.target.files]
|
const files = [...event.target.files]
|
||||||
emitFiles(files)
|
emitFiles(files)
|
||||||
event.target.value = ''
|
event.target.value = ''
|
||||||
@@ -90,10 +96,15 @@ const handleFileSelect = (event) => {
|
|||||||
const handleDrop = (event) => {
|
const handleDrop = (event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
isDragging.value = false
|
isDragging.value = false
|
||||||
|
if (props.disabled) return
|
||||||
const files = [...event.dataTransfer.files]
|
const files = [...event.dataTransfer.files]
|
||||||
emitFiles(files)
|
emitFiles(files)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onDragEnter = () => {
|
||||||
|
if (!props.disabled) isDragging.value = true
|
||||||
|
}
|
||||||
|
|
||||||
const emitFiles = (files) => {
|
const emitFiles = (files) => {
|
||||||
if (props.modelValue.length + files.length > props.maxFiles) {
|
if (props.modelValue.length + files.length > props.maxFiles) {
|
||||||
emit('error', `حداکثر تعداد فایل مجاز ${props.maxFiles} عدد است.`)
|
emit('error', `حداکثر تعداد فایل مجاز ${props.maxFiles} عدد است.`)
|
||||||
@@ -155,6 +166,11 @@ const formatFileSize = (bytes) => {
|
|||||||
&--active {
|
&--active {
|
||||||
border-color: var(--color-primary);
|
border-color: var(--color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&--disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.55;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__upload-icon {
|
&__upload-icon {
|
||||||
|
|||||||
@@ -371,12 +371,15 @@ onBeforeUnmount(() => unmountFloating())
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.25rem 0.75rem;
|
min-height: 2.5rem;
|
||||||
|
padding: 0.5rem 0.75rem;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 1.5rem;
|
border-radius: 1.5rem;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
font-family: var(--font-family-fa);
|
font-family: var(--font-family-fa);
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 1.5;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background-color 0.15s;
|
transition: background-color 0.15s;
|
||||||
|
|
||||||
|
|||||||
+15
-4
@@ -53,6 +53,8 @@ export const USER_STATUS = Object.freeze({
|
|||||||
export const MARITAL_STATUS = Object.freeze({
|
export const MARITAL_STATUS = Object.freeze({
|
||||||
single: 'مجرد',
|
single: 'مجرد',
|
||||||
married: 'متاهل',
|
married: 'متاهل',
|
||||||
|
divorced: 'مطلقه',
|
||||||
|
widowed: 'بیوه',
|
||||||
})
|
})
|
||||||
|
|
||||||
export const GENDER = Object.freeze({
|
export const GENDER = Object.freeze({
|
||||||
@@ -138,9 +140,15 @@ export const COURSE_CONTENT_TYPE = Object.freeze({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const COURSE_CONTENT_TYPE_ACCEPT = Object.freeze({
|
export const COURSE_CONTENT_TYPE_ACCEPT = Object.freeze({
|
||||||
video: 'video/*',
|
video: '.mp4,.webm,video/mp4,video/webm',
|
||||||
voice: 'audio/*',
|
voice: '.mp3,.wav,.m4a,.webm,audio/mpeg,audio/wav,audio/mp4,audio/webm',
|
||||||
text: '.pdf,.doc,.docx,.txt',
|
text: '.pdf,application/pdf',
|
||||||
|
})
|
||||||
|
|
||||||
|
export const COURSE_CONTENT_TYPE_MAX_SIZE = Object.freeze({
|
||||||
|
video: 300 * 1024 * 1024,
|
||||||
|
voice: 50 * 1024 * 1024,
|
||||||
|
text: 50 * 1024 * 1024,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const SESSION_TYPE = Object.freeze({
|
export const SESSION_TYPE = Object.freeze({
|
||||||
@@ -212,8 +220,11 @@ export const MISSIONARY_REQUEST_STATUS = Object.freeze({
|
|||||||
rejected: 'رد شده',
|
rejected: 'رد شده',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const MAIN_SITE_URL = 'https://madresebanoo.ir/'
|
||||||
|
|
||||||
// Landing route per role after login / when a logged-in user hits a guest
|
// Landing route per role after login / when a logged-in user hits a guest
|
||||||
// page. Roles not listed here fall back to the student dashboard.
|
// page. Roles not listed here fall back to the student dashboard. Approved
|
||||||
|
// users of every role except admin bypass this and land on MAIN_SITE_URL.
|
||||||
export const ROLE_HOME_ROUTES = Object.freeze({
|
export const ROLE_HOME_ROUTES = Object.freeze({
|
||||||
admin: 'admin-dashboard',
|
admin: 'admin-dashboard',
|
||||||
counselor: 'counselor-dashboard',
|
counselor: 'counselor-dashboard',
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
<SelectField
|
<SelectField
|
||||||
v-model="form.teacherId"
|
v-model="form.teacherId"
|
||||||
name="teacherId"
|
name="teacherId"
|
||||||
label="استاد"
|
label="استاد (اختیاری)"
|
||||||
:options="teacherOptions"
|
:options="teacherOptions"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
@@ -251,12 +251,12 @@ watch(
|
|||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
const uploadMutation = useUploadMediaMutation()
|
const coverUploadMutation = useUploadMediaMutation()
|
||||||
|
|
||||||
const onImageCropped = async (file) => {
|
const onImageCropped = async (file) => {
|
||||||
try {
|
try {
|
||||||
const formData = objectToFormData({ file, purpose: 'cover', context: 'course' })
|
const formData = objectToFormData({ file, purpose: 'cover', context: 'course' })
|
||||||
const response = await uploadMutation.mutateAsync(formData)
|
const response = await coverUploadMutation.mutateAsync(formData)
|
||||||
const payload = response?.data ?? response
|
const payload = response?.data ?? response
|
||||||
image.value = { url: payload?.url, ...payload }
|
image.value = { url: payload?.url, ...payload }
|
||||||
form.value.coverMediaId = payload?.id
|
form.value.coverMediaId = payload?.id
|
||||||
@@ -270,15 +270,28 @@ const onImageError = (msg) => toast.error(msg)
|
|||||||
const addMutation = useAddAdminCourseMutation()
|
const addMutation = useAddAdminCourseMutation()
|
||||||
const updateMutation = useUpdateAdminCourseMutation()
|
const updateMutation = useUpdateAdminCourseMutation()
|
||||||
|
|
||||||
const submitting = computed(() => addMutation.isPending.value || updateMutation.isPending.value)
|
const submitting = computed(
|
||||||
|
() =>
|
||||||
|
coverUploadMutation.isPending.value ||
|
||||||
|
addMutation.isPending.value ||
|
||||||
|
updateMutation.isPending.value
|
||||||
|
)
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
if (coverUploadMutation.isPending.value) {
|
||||||
|
toast.info('لطفاً تا پایان بارگذاری تصویر دوره منتظر بمانید.')
|
||||||
|
return
|
||||||
|
}
|
||||||
const { isValid, payload } = await validate(form.value)
|
const { isValid, payload } = await validate(form.value)
|
||||||
if (!isValid) return
|
if (!isValid) return
|
||||||
if (isEditMode.value) {
|
try {
|
||||||
await updateMutation.mutateAsync({ id: courseId.value, payload })
|
if (isEditMode.value) {
|
||||||
} else {
|
await updateMutation.mutateAsync({ id: courseId.value, payload })
|
||||||
await addMutation.mutateAsync(payload)
|
} else {
|
||||||
|
await addMutation.mutateAsync(payload)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
await queryClient.invalidateQueries({ queryKey: adminCoursesKeys.all })
|
await queryClient.invalidateQueries({ queryKey: adminCoursesKeys.all })
|
||||||
router.push({ name: 'admin-courses' })
|
router.push({ name: 'admin-courses' })
|
||||||
|
|||||||
@@ -69,7 +69,12 @@ const courseIcon = gallery.courseIcon
|
|||||||
const routeTermId = computed(() => (route.params.termId ? Number(route.params.termId) : null))
|
const routeTermId = computed(() => (route.params.termId ? Number(route.params.termId) : null))
|
||||||
|
|
||||||
const onAdd = () => {
|
const onAdd = () => {
|
||||||
router.push({ name: 'admin-add-course' }).catch(() => {})
|
router
|
||||||
|
.push({
|
||||||
|
name: 'admin-add-course',
|
||||||
|
query: routeTermId.value ? { termId: routeTermId.value } : undefined,
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
|
|||||||
@@ -2,17 +2,15 @@ import { array, boolean, mixed, number, object, string } from 'yup'
|
|||||||
|
|
||||||
export const courseSchema = object().shape({
|
export const courseSchema = object().shape({
|
||||||
title: string().required().min(3).max(255),
|
title: string().required().min(3).max(255),
|
||||||
teacherId: mixed().required(),
|
// The backend intentionally allows courses without an assigned teacher.
|
||||||
|
teacherId: mixed().nullable().notRequired(),
|
||||||
capacity: number()
|
capacity: number()
|
||||||
.typeError('ظرفیت باید بهصورت عدد وارد شود')
|
.typeError('ظرفیت باید بهصورت عدد وارد شود')
|
||||||
.required()
|
.required()
|
||||||
.integer('ظرفیت باید عدد صحیح باشد')
|
.integer('ظرفیت باید عدد صحیح باشد')
|
||||||
.min(1, 'ظرفیت باید حداقل ۱ نفر باشد'),
|
.min(1, 'ظرفیت باید حداقل ۱ نفر باشد'),
|
||||||
prerequisiteCourseIds: array().nullable().default([]),
|
prerequisiteCourseIds: array().nullable().default([]),
|
||||||
contentMediaId: number()
|
coverMediaId: number().typeError('شناسه تصویر دوره باید عدد باشد').nullable().notRequired(),
|
||||||
.typeError('شناسه فایل محتوای دوره باید عدد باشد')
|
|
||||||
.nullable()
|
|
||||||
.notRequired(),
|
|
||||||
description: string().nullable().notRequired(),
|
description: string().nullable().notRequired(),
|
||||||
termId: mixed().required(),
|
termId: mixed().required(),
|
||||||
isActive: boolean().nullable().notRequired(),
|
isActive: boolean().nullable().notRequired(),
|
||||||
|
|||||||
@@ -77,6 +77,19 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- row 3b — embed code (online sessions only) -->
|
||||||
|
<div class="session-form__row" v-if="form.type === 'online'">
|
||||||
|
<TextareaField
|
||||||
|
v-model="form.embedCode"
|
||||||
|
name="embedCode"
|
||||||
|
label="کد امبد (Embed Code)"
|
||||||
|
placeholder="در صورت وجود، کد iframe/embed جلسه (مثلاً از آپارات یا سرویس ویدئوکنفرانس) را اینجا وارد کنید تا بهجای لینک، بهصورت مستقیم در صفحه نمایش داده شود."
|
||||||
|
:row="3"
|
||||||
|
:error="errors.embedCode"
|
||||||
|
@blur="validateAt('embedCode', form.embedCode)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- row 4 — description -->
|
<!-- row 4 — description -->
|
||||||
<div class="session-form__row">
|
<div class="session-form__row">
|
||||||
<TextareaField
|
<TextareaField
|
||||||
@@ -95,11 +108,23 @@
|
|||||||
:accept="contentAccept"
|
:accept="contentAccept"
|
||||||
:multiple="false"
|
:multiple="false"
|
||||||
:max-files="1"
|
:max-files="1"
|
||||||
:disabled="!form.contentType"
|
:max-size="contentMaxSize"
|
||||||
|
:disabled="!form.contentType || contentUploadMutation.isPending.value"
|
||||||
@select="onContentSelect"
|
@select="onContentSelect"
|
||||||
@remove="onContentRemove"
|
@remove="onContentRemove"
|
||||||
@error="onContentError"
|
@error="onContentError"
|
||||||
/>
|
/>
|
||||||
|
<div v-if="contentUploadMutation.isPending.value" class="session-form__upload-progress">
|
||||||
|
<div class="session-form__upload-progress-track">
|
||||||
|
<div
|
||||||
|
class="session-form__upload-progress-bar"
|
||||||
|
:style="{ width: contentUploadProgress + '%' }"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<span class="session-form__upload-progress-text">
|
||||||
|
{{ contentUploadProgress }}% بارگذاری شده
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -162,7 +187,12 @@ import TextareaField from '@/components/form/TextareaField.vue'
|
|||||||
import { sessionSchema } from '@/features/admin/sessions/schema'
|
import { sessionSchema } from '@/features/admin/sessions/schema'
|
||||||
import { useAdminCoursesListQuery } from '@/services/query/admin-courses'
|
import { useAdminCoursesListQuery } from '@/services/query/admin-courses'
|
||||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||||
import { COURSE_CONTENT_TYPE, COURSE_CONTENT_TYPE_ACCEPT, SESSION_TYPE } from '@/enums'
|
import {
|
||||||
|
COURSE_CONTENT_TYPE,
|
||||||
|
COURSE_CONTENT_TYPE_ACCEPT,
|
||||||
|
COURSE_CONTENT_TYPE_MAX_SIZE,
|
||||||
|
SESSION_TYPE,
|
||||||
|
} from '@/enums'
|
||||||
import {
|
import {
|
||||||
adminSessionsKeys,
|
adminSessionsKeys,
|
||||||
useAddAdminSessionMutation,
|
useAddAdminSessionMutation,
|
||||||
@@ -175,6 +205,7 @@ const router = useRouter()
|
|||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
const sessionId = computed(() => (route.params.id ? Number(route.params.id) : null))
|
const sessionId = computed(() => (route.params.id ? Number(route.params.id) : null))
|
||||||
|
const presetCourseId = computed(() => (route.query.courseId ? Number(route.query.courseId) : null))
|
||||||
const isEditMode = computed(() => !!sessionId.value)
|
const isEditMode = computed(() => !!sessionId.value)
|
||||||
|
|
||||||
const sessionTypeOptions = [
|
const sessionTypeOptions = [
|
||||||
@@ -189,10 +220,11 @@ const contentTypeOptions = Object.entries(COURSE_CONTENT_TYPE).map(([value, labe
|
|||||||
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
title: '',
|
title: '',
|
||||||
courseId: '',
|
courseId: presetCourseId.value ?? '',
|
||||||
contentType: '',
|
contentType: '',
|
||||||
type: '',
|
type: '',
|
||||||
link: '',
|
link: '',
|
||||||
|
embedCode: '',
|
||||||
description: '',
|
description: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -200,8 +232,12 @@ const image = ref(null)
|
|||||||
const contentFiles = ref([])
|
const contentFiles = ref([])
|
||||||
const coverMediaId = ref(null)
|
const coverMediaId = ref(null)
|
||||||
const contentMediaId = ref(null)
|
const contentMediaId = ref(null)
|
||||||
|
const contentUploadProgress = ref(0)
|
||||||
|
|
||||||
const contentAccept = computed(() => COURSE_CONTENT_TYPE_ACCEPT[form.value.contentType] || '*')
|
const contentAccept = computed(() => COURSE_CONTENT_TYPE_ACCEPT[form.value.contentType] || '*')
|
||||||
|
const contentMaxSize = computed(
|
||||||
|
() => COURSE_CONTENT_TYPE_MAX_SIZE[form.value.contentType] || 50 * 1024 * 1024
|
||||||
|
)
|
||||||
|
|
||||||
const { validate, validateAt, errors } = useYup(sessionSchema)
|
const { validate, validateAt, errors } = useYup(sessionSchema)
|
||||||
|
|
||||||
@@ -228,7 +264,10 @@ const onContentTypeChange = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onSessionTypeChange = () => {
|
const onSessionTypeChange = () => {
|
||||||
if (form.value.type !== 'online') form.value.link = ''
|
if (form.value.type !== 'online') {
|
||||||
|
form.value.link = ''
|
||||||
|
form.value.embedCode = ''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: existingSession } = useAdminSessionQuery(sessionId, {
|
const { data: existingSession } = useAdminSessionQuery(sessionId, {
|
||||||
@@ -257,6 +296,7 @@ watch(
|
|||||||
contentType,
|
contentType,
|
||||||
type: session.type ?? '',
|
type: session.type ?? '',
|
||||||
link: session.link ?? '',
|
link: session.link ?? '',
|
||||||
|
embedCode: session.embedCode ?? '',
|
||||||
description: session.description ?? '',
|
description: session.description ?? '',
|
||||||
}
|
}
|
||||||
coverMediaId.value = coverMedia?.id ?? null
|
coverMediaId.value = coverMedia?.id ?? null
|
||||||
@@ -276,7 +316,8 @@ watch(
|
|||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
const uploadMutation = useUploadMediaMutation()
|
const contentUploadMutation = useUploadMediaMutation()
|
||||||
|
const coverUploadMutation = useUploadMediaMutation()
|
||||||
|
|
||||||
const purposeForContentType = (contentType) => {
|
const purposeForContentType = (contentType) => {
|
||||||
if (contentType === 'video') return 'video'
|
if (contentType === 'video') return 'video'
|
||||||
@@ -287,13 +328,20 @@ const purposeForContentType = (contentType) => {
|
|||||||
const onContentSelect = async (files) => {
|
const onContentSelect = async (files) => {
|
||||||
const file = files?.[0]
|
const file = files?.[0]
|
||||||
if (!file) return
|
if (!file) return
|
||||||
|
contentUploadProgress.value = 0
|
||||||
try {
|
try {
|
||||||
const formData = objectToFormData({
|
const formData = objectToFormData({
|
||||||
file,
|
file,
|
||||||
purpose: purposeForContentType(form.value.contentType),
|
purpose: purposeForContentType(form.value.contentType),
|
||||||
context: 'session',
|
context: 'session',
|
||||||
})
|
})
|
||||||
const response = await uploadMutation.mutateAsync(formData)
|
const response = await contentUploadMutation.mutateAsync({
|
||||||
|
formData,
|
||||||
|
onUploadProgress: (event) => {
|
||||||
|
if (!event.total) return
|
||||||
|
contentUploadProgress.value = Math.round((event.loaded / event.total) * 100)
|
||||||
|
},
|
||||||
|
})
|
||||||
const payload = response?.data ?? response
|
const payload = response?.data ?? response
|
||||||
const id = payload?.id ?? payload?.uploadId
|
const id = payload?.id ?? payload?.uploadId
|
||||||
contentFiles.value = [{ id, name: file.name, size: file.size, url: payload?.url }]
|
contentFiles.value = [{ id, name: file.name, size: file.size, url: payload?.url }]
|
||||||
@@ -313,7 +361,7 @@ const onContentError = (msg) => toast.error(msg)
|
|||||||
const onImageCropped = async (file) => {
|
const onImageCropped = async (file) => {
|
||||||
try {
|
try {
|
||||||
const formData = objectToFormData({ file, purpose: 'cover', context: 'session' })
|
const formData = objectToFormData({ file, purpose: 'cover', context: 'session' })
|
||||||
const response = await uploadMutation.mutateAsync(formData)
|
const response = await coverUploadMutation.mutateAsync(formData)
|
||||||
const payload = response?.data ?? response
|
const payload = response?.data ?? response
|
||||||
image.value = { url: payload?.url, ...payload }
|
image.value = { url: payload?.url, ...payload }
|
||||||
coverMediaId.value = payload?.id ?? null
|
coverMediaId.value = payload?.id ?? null
|
||||||
@@ -331,6 +379,7 @@ const buildPayload = (values) => {
|
|||||||
courseId: values.courseId,
|
courseId: values.courseId,
|
||||||
type: values.type,
|
type: values.type,
|
||||||
link: values.type === 'online' ? values.link : undefined,
|
link: values.type === 'online' ? values.link : undefined,
|
||||||
|
embedCode: values.type === 'online' ? values.embedCode : undefined,
|
||||||
description: values.description,
|
description: values.description,
|
||||||
mediaIds,
|
mediaIds,
|
||||||
}
|
}
|
||||||
@@ -346,16 +395,34 @@ const buildPayload = (values) => {
|
|||||||
const addMutation = useAddAdminSessionMutation()
|
const addMutation = useAddAdminSessionMutation()
|
||||||
const updateMutation = useUpdateAdminSessionMutation()
|
const updateMutation = useUpdateAdminSessionMutation()
|
||||||
|
|
||||||
const submitting = computed(() => addMutation.isPending.value || updateMutation.isPending.value)
|
const submitting = computed(
|
||||||
|
() =>
|
||||||
|
contentUploadMutation.isPending.value ||
|
||||||
|
coverUploadMutation.isPending.value ||
|
||||||
|
addMutation.isPending.value ||
|
||||||
|
updateMutation.isPending.value
|
||||||
|
)
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
if (contentUploadMutation.isPending.value || coverUploadMutation.isPending.value) {
|
||||||
|
toast.info('لطفاً تا پایان بارگذاری محتوای جلسه منتظر بمانید.')
|
||||||
|
return
|
||||||
|
}
|
||||||
const { isValid } = await validate(form.value)
|
const { isValid } = await validate(form.value)
|
||||||
if (!isValid) return
|
if (!isValid) return
|
||||||
|
if (form.value.contentType && contentMediaId.value == null) {
|
||||||
|
toast.error('برای نوع محتوای انتخابشده، فایل جلسه را بارگذاری کنید.')
|
||||||
|
return
|
||||||
|
}
|
||||||
const payload = buildPayload(form.value)
|
const payload = buildPayload(form.value)
|
||||||
if (isEditMode.value) {
|
try {
|
||||||
await updateMutation.mutateAsync({ id: sessionId.value, payload })
|
if (isEditMode.value) {
|
||||||
} else {
|
await updateMutation.mutateAsync({ id: sessionId.value, payload })
|
||||||
await addMutation.mutateAsync(payload)
|
} else {
|
||||||
|
await addMutation.mutateAsync(payload)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
// The list query is inactive while we're on the form page, and the global
|
// 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
|
// `refetchOnMount: false` means navigating back won't refetch a merely-stale
|
||||||
@@ -448,6 +515,38 @@ const onCancel = () => router.push({ name: 'admin-sessions' })
|
|||||||
color: var(--color-prim-gray);
|
color: var(--color-prim-gray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__upload-progress {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
margin-top: -0.25rem;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__upload-progress-track {
|
||||||
|
flex: 1;
|
||||||
|
height: 0.5rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--color-thd-gray);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__upload-progress-bar {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--color-primary);
|
||||||
|
transition: width 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__upload-progress-text {
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-family: var(--font-family-en);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--color-sec-gray);
|
||||||
|
min-width: 3.5rem;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
&__preview {
|
&__preview {
|
||||||
place-items: center center;
|
place-items: center center;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,12 @@ const onFilterApply = () => resetPagination()
|
|||||||
const onFilterReset = () => resetPagination()
|
const onFilterReset = () => resetPagination()
|
||||||
|
|
||||||
const onAdd = () => {
|
const onAdd = () => {
|
||||||
router.push({ name: 'admin-add-session' }).catch(() => {})
|
router
|
||||||
|
.push({
|
||||||
|
name: 'admin-add-session',
|
||||||
|
query: routeCourseId.value ? { courseId: routeCourseId.value } : undefined,
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
const onEdit = (session) => {
|
const onEdit = (session) => {
|
||||||
|
|||||||
@@ -9,5 +9,6 @@ export const sessionSchema = object().shape({
|
|||||||
then: (schema) => schema.required(),
|
then: (schema) => schema.required(),
|
||||||
otherwise: (schema) => schema.nullable().notRequired(),
|
otherwise: (schema) => schema.nullable().notRequired(),
|
||||||
}),
|
}),
|
||||||
|
embedCode: string().nullable().notRequired(),
|
||||||
description: string().nullable().notRequired(),
|
description: string().nullable().notRequired(),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -163,8 +163,6 @@ const invalidate = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onAttach = async (template) => {
|
const onAttach = async (template) => {
|
||||||
console.log(template)
|
|
||||||
|
|
||||||
if (!termId.value) return
|
if (!termId.value) return
|
||||||
pendingId.value = template.id
|
pendingId.value = template.id
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -89,9 +89,9 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import useYup from '@/composables/useYup'
|
import useYup from '@/composables/useYup'
|
||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
|
||||||
import TextField from '@/components/form/TextField.vue'
|
import TextField from '@/components/form/TextField.vue'
|
||||||
import SelectField from '@/components/form/SelectField.vue'
|
import SelectField from '@/components/form/SelectField.vue'
|
||||||
|
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||||
import TextareaField from '@/components/form/TextareaField.vue'
|
import TextareaField from '@/components/form/TextareaField.vue'
|
||||||
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||||
@@ -124,6 +124,8 @@ const universityLevelOptions = Object.entries(UNIVERSITY_LEVEL).map(([value, lab
|
|||||||
|
|
||||||
const form = ref({ ...store.educational })
|
const form = ref({ ...store.educational })
|
||||||
|
|
||||||
|
watch(form, (value) => store.updateSection('educational', value), { deep: true })
|
||||||
|
|
||||||
const { validate, validateAt, errors } = useYup(educationalInformationSchema)
|
const { validate, validateAt, errors } = useYup(educationalInformationSchema)
|
||||||
|
|
||||||
const saveRegisterMutation = useSaveRegisterDataMutation()
|
const saveRegisterMutation = useSaveRegisterDataMutation()
|
||||||
@@ -136,8 +138,6 @@ const onSubmit = async () => {
|
|||||||
store.markStepAsCompleted(STUDENT_REGISTRATION.EDUCATIONAL_INFORMATION)
|
store.markStepAsCompleted(STUDENT_REGISTRATION.EDUCATIONAL_INFORMATION)
|
||||||
store.goToNextStep()
|
store.goToNextStep()
|
||||||
}
|
}
|
||||||
|
|
||||||
store.updateCurrentStep(STUDENT_REGISTRATION.EDUCATIONAL_INFORMATION)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -230,16 +230,15 @@ import { toast } from 'vue3-toastify'
|
|||||||
import useYup from '@/composables/useYup'
|
import useYup from '@/composables/useYup'
|
||||||
import useAuth from '@/composables/useAuth'
|
import useAuth from '@/composables/useAuth'
|
||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||||
import { convertToJalali } from '@/utils/date-utils'
|
|
||||||
import { useQueryClient } from '@tanstack/vue-query'
|
import { useQueryClient } from '@tanstack/vue-query'
|
||||||
import TextField from '@/components/form/TextField.vue'
|
import TextField from '@/components/form/TextField.vue'
|
||||||
import SelectField from '@/components/form/SelectField.vue'
|
import SelectField from '@/components/form/SelectField.vue'
|
||||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||||
|
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
import ImageCropper from '@/components/form/ImageCropper.vue'
|
import ImageCropper from '@/components/form/ImageCropper.vue'
|
||||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||||
import TextareaField from '@/components/form/TextareaField.vue'
|
import TextareaField from '@/components/form/TextareaField.vue'
|
||||||
import DatePickerField from '@/components/form/DatePickerField.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 { GENDER, MARITAL_STATUS, STUDENT_REGISTRATION } from '@/enums'
|
||||||
import { personalInformationSchema } from '@/features/auth/schema/student-register'
|
import { personalInformationSchema } from '@/features/auth/schema/student-register'
|
||||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||||
@@ -269,15 +268,14 @@ const maritalStatusOptions = Object.entries(MARITAL_STATUS).map(([value, label])
|
|||||||
}))
|
}))
|
||||||
const genderOptions = Object.entries(GENDER).map(([value, label]) => ({ value, label }))
|
const genderOptions = Object.entries(GENDER).map(([value, label]) => ({ value, label }))
|
||||||
|
|
||||||
const maxBirthDate = computed(() => {
|
const maxBirthDate = (() => {
|
||||||
const d = new Date()
|
const d = new Date()
|
||||||
d.setFullYear(d.getFullYear() - 15)
|
d.setFullYear(d.getFullYear() - 15)
|
||||||
try {
|
const year = d.getFullYear()
|
||||||
return convertToJalali(d.toISOString())
|
const month = String(d.getMonth() + 1).padStart(2, '0')
|
||||||
} catch {
|
const day = String(d.getDate()).padStart(2, '0')
|
||||||
return d.toISOString()
|
return `${year}-${month}-${day}`
|
||||||
}
|
})()
|
||||||
})
|
|
||||||
|
|
||||||
const initialPhone = ref(user.value?.phone || store.personal.phone || '')
|
const initialPhone = ref(user.value?.phone || store.personal.phone || '')
|
||||||
const initialNationalCode = ref(user.value?.nationalCode || store.personal.nationalCode || '')
|
const initialNationalCode = ref(user.value?.nationalCode || store.personal.nationalCode || '')
|
||||||
@@ -305,6 +303,8 @@ const form = ref({
|
|||||||
avatarId: store.personal.avatarId || '',
|
avatarId: store.personal.avatarId || '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(form, (value) => store.updateSection('personal', value), { deep: true })
|
||||||
|
|
||||||
const avatar = ref(initialAvatar)
|
const avatar = ref(initialAvatar)
|
||||||
|
|
||||||
const { validate, validateAt, errors } = useYup(personalInformationSchema)
|
const { validate, validateAt, errors } = useYup(personalInformationSchema)
|
||||||
@@ -316,8 +316,8 @@ const { data: cities = ref([]) } = useGetCitiesOfProvinceQuery(provinceIdRef, {
|
|||||||
enabled: () => !!provinceIdRef.value,
|
enabled: () => !!provinceIdRef.value,
|
||||||
})
|
})
|
||||||
|
|
||||||
const onProvinceChange = () => {
|
const onProvinceChange = (provinceId) => {
|
||||||
provinceIdRef.value = form.value.provinceId
|
provinceIdRef.value = provinceId
|
||||||
form.value.cityId = null
|
form.value.cityId = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,8 +382,6 @@ const onSubmit = async () => {
|
|||||||
store.markStepAsCompleted(STUDENT_REGISTRATION.PERSONAL_INFORMATION)
|
store.markStepAsCompleted(STUDENT_REGISTRATION.PERSONAL_INFORMATION)
|
||||||
store.goToNextStep()
|
store.goToNextStep()
|
||||||
}
|
}
|
||||||
|
|
||||||
store.updateCurrentStep(STUDENT_REGISTRATION.PERSONAL_INFORMATION)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -111,10 +111,10 @@ import SvgIcon from '@/components/icons/SvgIcon.vue'
|
|||||||
import TextField from '@/components/form/TextField.vue'
|
import TextField from '@/components/form/TextField.vue'
|
||||||
import SelectField from '@/components/form/SelectField.vue'
|
import SelectField from '@/components/form/SelectField.vue'
|
||||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
||||||
import TextareaField from '@/components/form/TextareaField.vue'
|
import TextareaField from '@/components/form/TextareaField.vue'
|
||||||
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||||
import { PROPAGATION_PLATFORM, STUDENT_REGISTRATION } from '@/enums'
|
import { PROPAGATION_PLATFORM, STUDENT_REGISTRATION } from '@/enums'
|
||||||
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||||
import { professionalInformationSchema } from '@/features/auth/schema/student-register'
|
import { professionalInformationSchema } from '@/features/auth/schema/student-register'
|
||||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||||
@@ -150,6 +150,8 @@ const form = ref({
|
|||||||
onlinePlatformDetails: seedOnline,
|
onlinePlatformDetails: seedOnline,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(form, (value) => store.updateSection('professional', value), { deep: true })
|
||||||
|
|
||||||
const hasOther = computed(() => form.value.propagationPlatforms.includes('other'))
|
const hasOther = computed(() => form.value.propagationPlatforms.includes('other'))
|
||||||
const hasOnline = computed(() => form.value.propagationPlatforms.includes('online'))
|
const hasOnline = computed(() => form.value.propagationPlatforms.includes('online'))
|
||||||
|
|
||||||
@@ -195,8 +197,6 @@ const onSubmit = async () => {
|
|||||||
store.markStepAsCompleted(STUDENT_REGISTRATION.PROFESSIONAL_INFORMATION)
|
store.markStepAsCompleted(STUDENT_REGISTRATION.PROFESSIONAL_INFORMATION)
|
||||||
store.goToNextStep()
|
store.goToNextStep()
|
||||||
}
|
}
|
||||||
|
|
||||||
store.updateCurrentStep(STUDENT_REGISTRATION.PROFESSIONAL_INFORMATION)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -7,33 +7,57 @@
|
|||||||
<div class="sidebar-steps__logo">
|
<div class="sidebar-steps__logo">
|
||||||
<img :src="logoWhite" alt="مدرسه بانو" />
|
<img :src="logoWhite" alt="مدرسه بانو" />
|
||||||
</div>
|
</div>
|
||||||
<ul class="sidebar-steps__list">
|
<ul ref="stepsList" class="sidebar-steps__list scrollbar-thin">
|
||||||
<li
|
<li v-for="tab in tabs" :key="tab.step" class="sidebar-steps__item">
|
||||||
v-for="tab in tabs"
|
<button
|
||||||
:key="tab.key"
|
type="button"
|
||||||
class="sidebar-steps__item"
|
class="sidebar-steps__button"
|
||||||
:class="{ 'sidebar-steps__item--active': activeTab === tab.key }"
|
:class="{
|
||||||
@click="emit('update:active-tab', tab.key)"
|
'sidebar-steps__button--active': activeStep === tab.step,
|
||||||
>
|
'sidebar-steps__button--completed': tab.completed,
|
||||||
<SvgIcon :name="tab.icon" :size="22" color="#fff" />
|
}"
|
||||||
|
:disabled="tab.disabled"
|
||||||
|
:aria-label="`${tab.title}، مرحله ${tab.step}`"
|
||||||
|
:aria-current="activeStep === tab.step ? 'step' : undefined"
|
||||||
|
@click="emit('select-step', tab.step)"
|
||||||
|
>
|
||||||
|
<span class="sidebar-steps__icon">
|
||||||
|
<SvgIcon :name="tab.completed ? 'check-square' : tab.icon" :size="20" color="#fff" />
|
||||||
|
</span>
|
||||||
|
<span class="sidebar-steps__label">{{ tab.title }}</span>
|
||||||
|
<span class="sidebar-steps__number">{{ tab.step }}</span>
|
||||||
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<SidebarLogout color="#fff" stacked />
|
<div class="sidebar-steps__logout">
|
||||||
|
<SidebarLogout color="#fff" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { gallery } from '@/utils/gallery'
|
import { gallery } from '@/utils/gallery'
|
||||||
|
import { nextTick, ref, watch } from 'vue'
|
||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||||
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'
|
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'
|
||||||
|
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
tabs: { type: Array, required: true },
|
tabs: { type: Array, required: true },
|
||||||
activeTab: { type: String, default: '' },
|
activeStep: { type: Number, default: 1 },
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:active-tab'])
|
const emit = defineEmits(['select-step'])
|
||||||
|
const stepsList = ref(null)
|
||||||
|
|
||||||
|
const scrollActiveStepIntoView = async () => {
|
||||||
|
await nextTick()
|
||||||
|
stepsList.value
|
||||||
|
?.querySelector('[aria-current="step"]')
|
||||||
|
?.scrollIntoView({ block: 'nearest', inline: 'center' })
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => props.activeStep, scrollActiveStepIntoView, { immediate: true })
|
||||||
|
|
||||||
const logoWhite = gallery.logoWhite
|
const logoWhite = gallery.logoWhite
|
||||||
const logoPinkishRed = gallery.logoPinkishRed
|
const logoPinkishRed = gallery.logoPinkishRed
|
||||||
@@ -67,14 +91,11 @@ const logoPinkishRed = gallery.logoPinkishRed
|
|||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
// Fill the full-height column only on desktop; on mobile the panel is a
|
|
||||||
// content-height bar, so height:100% would overflow past the logo above it
|
|
||||||
// and collide with the page heading.
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: stretch;
|
||||||
gap: 1.5rem;
|
gap: 1rem;
|
||||||
padding: 1.25rem 0.75rem;
|
padding: 1.25rem 0.875rem;
|
||||||
border-radius: 1.5rem;
|
border-radius: 1.5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,30 +122,127 @@ const logoPinkishRed = gallery.logoPinkishRed
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: flex-start;
|
||||||
gap: 1rem;
|
gap: 0.375rem;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
overflow-x: auto;
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
gap: 1.25rem;
|
gap: 0.25rem;
|
||||||
padding-top: 1rem;
|
padding-top: 0.5rem;
|
||||||
|
overflow: hidden auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__item {
|
&__item {
|
||||||
cursor: pointer;
|
flex: 0 0 auto;
|
||||||
opacity: 0.5;
|
min-width: 0;
|
||||||
transition: opacity 0.15s ease;
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__button {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 0.25rem;
|
gap: 0.5rem;
|
||||||
|
width: 2.75rem;
|
||||||
|
min-height: 2.75rem;
|
||||||
|
padding: 0.375rem;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: 0.875rem;
|
||||||
|
background: transparent;
|
||||||
|
color: #fff;
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 0.62;
|
||||||
|
transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
|
||||||
|
|
||||||
&--active,
|
@media (min-width: 1024px) {
|
||||||
&:hover {
|
justify-content: flex-start;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.5rem 0.625rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover:not(:disabled),
|
||||||
|
&--active {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
background: rgba(255, 255, 255, 14%);
|
||||||
|
border-color: rgba(255, 255, 255, 22%);
|
||||||
|
}
|
||||||
|
|
||||||
|
&--completed {
|
||||||
|
&:not(.sidebar-steps__button--active) {
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__icon {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__label {
|
||||||
|
display: none;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
font-family: var(--font-family-fa);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__number {
|
||||||
|
display: none;
|
||||||
|
margin-inline-start: auto;
|
||||||
|
font-family: var(--font-family-number-fa);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
opacity: 0.75;
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__logout {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
|
||||||
|
:deep(.sidebar-logout) {
|
||||||
|
padding: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.sidebar-logout__labels) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
border-top: 1px solid rgba(255, 255, 255, 20%);
|
||||||
|
padding-top: 0.5rem;
|
||||||
|
|
||||||
|
:deep(.sidebar-logout) {
|
||||||
|
justify-content: flex-start;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.5rem 0.625rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.sidebar-logout__labels) {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="skill-five__divider" />
|
<div class="skill-five__divider" />
|
||||||
<StepActions @back="store.goToPrevStep()" />
|
<StepActions :loading="saveRegisterMutation.isPending.value" @back="store.goToPrevStep()" />
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -51,9 +51,10 @@
|
|||||||
import useYup from '@/composables/useYup'
|
import useYup from '@/composables/useYup'
|
||||||
import { STUDENT_REGISTRATION } from '@/enums'
|
import { STUDENT_REGISTRATION } from '@/enums'
|
||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||||
import TextareaField from '@/components/form/TextareaField.vue'
|
import TextareaField from '@/components/form/TextareaField.vue'
|
||||||
|
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||||
import { skillAssessmentPart5Schema } from '@/features/auth/schema/student-register'
|
import { skillAssessmentPart5Schema } from '@/features/auth/schema/student-register'
|
||||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||||
@@ -69,17 +70,19 @@ onBeforeUnmount(() => window.removeEventListener('resize', onResize))
|
|||||||
|
|
||||||
const form = ref({ ...store.skill5 })
|
const form = ref({ ...store.skill5 })
|
||||||
|
|
||||||
|
watch(form, (value) => store.updateSection('skill5', value), { deep: true })
|
||||||
|
|
||||||
const { validate, validateAt, errors } = useYup(skillAssessmentPart5Schema)
|
const { validate, validateAt, errors } = useYup(skillAssessmentPart5Schema)
|
||||||
|
const saveRegisterMutation = useSaveRegisterDataMutation()
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
const { isValid, payload } = await validate(form.value)
|
const { isValid, payload } = await validate(form.value)
|
||||||
if (!isValid) return
|
if (!isValid) return
|
||||||
|
await saveRegisterMutation.mutateAsync(payload)
|
||||||
store.skill5 = { ...store.skill5, ...payload }
|
store.skill5 = { ...store.skill5, ...payload }
|
||||||
store.markStepAsCompleted(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_5)
|
store.markStepAsCompleted(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_5)
|
||||||
store.goToNextStep()
|
store.goToNextStep()
|
||||||
}
|
}
|
||||||
|
|
||||||
store.updateCurrentStep(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_5)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
purpose="voice"
|
purpose="voice"
|
||||||
:max-seconds="180"
|
:max-seconds="180"
|
||||||
:error="errors.faithProductionAudio"
|
:error="errors.faithProductionAudio"
|
||||||
@uploaded="onUploaded"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="skill-six__content-col">
|
<div class="skill-six__content-col">
|
||||||
@@ -23,7 +22,8 @@
|
|||||||
<video :src="videoUrl" controls playsinline class="skill-six__video" />
|
<video :src="videoUrl" controls playsinline class="skill-six__video" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="skill-six__video-placeholder">
|
<div v-else class="skill-six__video-placeholder">
|
||||||
<p>ویدیویی در دسترس نیست</p>
|
<p>ویدیوی راهنما هنوز بارگذاری نشده است.</p>
|
||||||
|
<p>تا زمان انتشار ویدیو، ارسال پاسخ در این مرحله اختیاری است.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -34,8 +34,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref } from 'vue'
|
|
||||||
import useYup from '@/composables/useYup'
|
import useYup from '@/composables/useYup'
|
||||||
|
import { computed, ref, watch } from 'vue'
|
||||||
import { STUDENT_REGISTRATION } from '@/enums'
|
import { STUDENT_REGISTRATION } from '@/enums'
|
||||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||||
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||||
@@ -55,10 +55,12 @@ const form = ref({
|
|||||||
|
|
||||||
const { validate, errors } = useYup(skillAssessmentPart6Schema)
|
const { validate, errors } = useYup(skillAssessmentPart6Schema)
|
||||||
|
|
||||||
const onUploaded = (value) => {
|
watch(audio, (value) => {
|
||||||
form.value.faithProductionAudio = value
|
form.value.faithProductionAudio = value
|
||||||
form.value.faithProductionId = value?.uploadId || ''
|
form.value.faithProductionId = value?.uploadId || ''
|
||||||
}
|
})
|
||||||
|
|
||||||
|
watch(form, (value) => store.updateSection('skill6', value), { deep: true })
|
||||||
|
|
||||||
const videoUrl = computed(() => store.registrationMedia.faithProductionVideoUrl || '')
|
const videoUrl = computed(() => store.registrationMedia.faithProductionVideoUrl || '')
|
||||||
|
|
||||||
@@ -72,8 +74,6 @@ const onSubmit = async () => {
|
|||||||
store.markStepAsCompleted(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_6)
|
store.markStepAsCompleted(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_6)
|
||||||
store.goToNextStep()
|
store.goToNextStep()
|
||||||
}
|
}
|
||||||
|
|
||||||
store.updateCurrentStep(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_6)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@@ -107,8 +107,8 @@ store.updateCurrentStep(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_6)
|
|||||||
|
|
||||||
&__intro {
|
&__intro {
|
||||||
font-family: var(--font-family-fa);
|
font-family: var(--font-family-fa);
|
||||||
font-weight: 300;
|
font-weight: 400;
|
||||||
font-size: 0.875rem;
|
font-size: 0.9375rem;
|
||||||
line-height: 1.7;
|
line-height: 1.7;
|
||||||
margin: 0 0 0.75rem;
|
margin: 0 0 0.75rem;
|
||||||
text-align: justify;
|
text-align: justify;
|
||||||
@@ -130,11 +130,16 @@ store.updateCurrentStep(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_6)
|
|||||||
&__video-placeholder {
|
&__video-placeholder {
|
||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
background: #f3f4f6;
|
background: #f3f4f6;
|
||||||
color: var(--color-thd-gray);
|
color: #666;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-family: var(--font-family-fa);
|
font-family: var(--font-family-fa);
|
||||||
font-size: 0.875rem;
|
font-size: 0.9375rem;
|
||||||
|
font-weight: 400;
|
||||||
|
|
||||||
|
p + p {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__divider {
|
&__divider {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
context="verification"
|
context="verification"
|
||||||
:max-seconds="180"
|
:max-seconds="180"
|
||||||
:error="errors.leaderMessageVideo"
|
:error="errors.leaderMessageVideo"
|
||||||
@uploaded="onUploaded"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="skill-seven__content-col">
|
<div class="skill-seven__content-col">
|
||||||
@@ -22,7 +21,8 @@
|
|||||||
<video :src="videoUrl" controls playsinline class="skill-seven__video" />
|
<video :src="videoUrl" controls playsinline class="skill-seven__video" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="skill-seven__video-placeholder">
|
<div v-else class="skill-seven__video-placeholder">
|
||||||
<p>ویدیویی در دسترس نیست</p>
|
<p>ویدیوی راهنما هنوز بارگذاری نشده است.</p>
|
||||||
|
<p>تا زمان انتشار ویدیو، ارسال پاسخ در این مرحله اختیاری است.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -37,9 +37,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref } from 'vue'
|
|
||||||
import { toast } from 'vue3-toastify'
|
import { toast } from 'vue3-toastify'
|
||||||
import useYup from '@/composables/useYup'
|
import useYup from '@/composables/useYup'
|
||||||
|
import { computed, ref, watch } from 'vue'
|
||||||
import { STUDENT_REGISTRATION } from '@/enums'
|
import { STUDENT_REGISTRATION } from '@/enums'
|
||||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||||
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||||
@@ -59,10 +59,12 @@ const form = ref({
|
|||||||
|
|
||||||
const { validate, errors } = useYup(skillAssessmentPart7Schema)
|
const { validate, errors } = useYup(skillAssessmentPart7Schema)
|
||||||
|
|
||||||
const onUploaded = (value) => {
|
watch(video, (value) => {
|
||||||
form.value.leaderMessageVideo = value
|
form.value.leaderMessageVideo = value
|
||||||
form.value.leaderMessageId = value?.uploadId || ''
|
form.value.leaderMessageId = value?.uploadId || ''
|
||||||
}
|
})
|
||||||
|
|
||||||
|
watch(form, (value) => store.updateSection('skill7', value), { deep: true })
|
||||||
|
|
||||||
const videoUrl = computed(() => store.registrationMedia.leaderMessageVideoUrl || '')
|
const videoUrl = computed(() => store.registrationMedia.leaderMessageVideoUrl || '')
|
||||||
|
|
||||||
@@ -80,8 +82,6 @@ const onSubmit = async () => {
|
|||||||
toast.error(error?.response?.data?.message || 'عملیات با خطا مواجه شد')
|
toast.error(error?.response?.data?.message || 'عملیات با خطا مواجه شد')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
store.updateCurrentStep(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_7)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@@ -115,8 +115,8 @@ store.updateCurrentStep(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_7)
|
|||||||
|
|
||||||
&__intro {
|
&__intro {
|
||||||
font-family: var(--font-family-fa);
|
font-family: var(--font-family-fa);
|
||||||
font-weight: 300;
|
font-weight: 400;
|
||||||
font-size: 0.875rem;
|
font-size: 0.9375rem;
|
||||||
line-height: 1.7;
|
line-height: 1.7;
|
||||||
margin: 0 0 0.75rem;
|
margin: 0 0 0.75rem;
|
||||||
text-align: justify;
|
text-align: justify;
|
||||||
@@ -138,11 +138,16 @@ store.updateCurrentStep(STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_7)
|
|||||||
&__video-placeholder {
|
&__video-placeholder {
|
||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
background: #f3f4f6;
|
background: #f3f4f6;
|
||||||
color: var(--color-thd-gray);
|
color: #666;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-family: var(--font-family-fa);
|
font-family: var(--font-family-fa);
|
||||||
font-size: 0.875rem;
|
font-size: 0.9375rem;
|
||||||
|
font-weight: 400;
|
||||||
|
|
||||||
|
p + p {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__divider {
|
&__divider {
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ import useYup from '@/composables/useYup'
|
|||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||||
import SelectField from '@/components/form/SelectField.vue'
|
import SelectField from '@/components/form/SelectField.vue'
|
||||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
||||||
import TextareaField from '@/components/form/TextareaField.vue'
|
import TextareaField from '@/components/form/TextareaField.vue'
|
||||||
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
import { useSaveRegisterDataMutation } from '@/services/query/auth'
|
||||||
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
import StepActions from '@/features/auth/components/studentRegister/StepActions.vue'
|
||||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||||
|
|
||||||
@@ -73,6 +73,8 @@ const form = ref({
|
|||||||
[props.descField]: seed[props.descField] || '',
|
[props.descField]: seed[props.descField] || '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(form, (value) => store.updateSection(props.storeKey, value), { deep: true })
|
||||||
|
|
||||||
const hasOther = computed(() => form.value[props.selectField] === 'other')
|
const hasOther = computed(() => form.value[props.selectField] === 'other')
|
||||||
|
|
||||||
const onSelect = () => {
|
const onSelect = () => {
|
||||||
@@ -91,8 +93,6 @@ const onSubmit = async () => {
|
|||||||
store.markStepAsCompleted(props.step)
|
store.markStepAsCompleted(props.step)
|
||||||
store.goToNextStep()
|
store.goToNextStep()
|
||||||
}
|
}
|
||||||
|
|
||||||
store.updateCurrentStep(props.step)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@@ -115,8 +115,8 @@ store.updateCurrentStep(props.step)
|
|||||||
|
|
||||||
p {
|
p {
|
||||||
font-family: var(--font-family-fa);
|
font-family: var(--font-family-fa);
|
||||||
font-weight: 300;
|
font-weight: 400;
|
||||||
font-size: 0.875rem;
|
font-size: 0.9375rem;
|
||||||
line-height: 1.7;
|
line-height: 1.7;
|
||||||
color: #a7a7a7;
|
color: #a7a7a7;
|
||||||
text-align: justify;
|
text-align: justify;
|
||||||
|
|||||||
@@ -45,21 +45,27 @@ const emit = defineEmits(['back'])
|
|||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.step-actions {
|
.step-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.5rem;
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
|
||||||
&__back {
|
&__back {
|
||||||
flex: 1 1 60%;
|
flex: 1 1 10rem;
|
||||||
|
min-width: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__next {
|
&__next {
|
||||||
flex: 1 1 40%;
|
flex: 1 1 12rem;
|
||||||
|
min-width: 0;
|
||||||
max-width: 16rem;
|
max-width: 16rem;
|
||||||
margin-inline-start: auto;
|
margin-inline-start: auto;
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
@media (max-width: 767px) {
|
||||||
flex: 0 0 16rem;
|
order: -1;
|
||||||
|
flex-basis: 100%;
|
||||||
|
max-width: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,10 +73,17 @@ const emit = defineEmits(['back'])
|
|||||||
color: #969696;
|
color: #969696;
|
||||||
padding: 0 1rem;
|
padding: 0 1rem;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__next-btn {
|
&__next-btn {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-height: 2.65rem;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.base-button__text) {
|
||||||
|
font-size: 0.9375rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { ROLE_HOME_ROUTES } from '@/enums'
|
|
||||||
import { useAuthStore } from '@/store/auth'
|
import { useAuthStore } from '@/store/auth'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import { MAIN_SITE_URL, ROLE_HOME_ROUTES } from '@/enums'
|
||||||
|
|
||||||
|
const shouldLandOnMainSite = (auth) => auth.role !== 'admin' && auth.user?.status === 'approved'
|
||||||
|
|
||||||
export const useRedirectAfterLogin = () => {
|
export const useRedirectAfterLogin = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -13,6 +15,10 @@ export const useRedirectAfterLogin = () => {
|
|||||||
router.push(redirect).catch(() => router.push('/'))
|
router.push(redirect).catch(() => router.push('/'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (shouldLandOnMainSite(auth)) {
|
||||||
|
window.location.href = MAIN_SITE_URL
|
||||||
|
return
|
||||||
|
}
|
||||||
const target = { name: ROLE_HOME_ROUTES[auth.role] || 'student-dashboard' }
|
const target = { name: ROLE_HOME_ROUTES[auth.role] || 'student-dashboard' }
|
||||||
router.push(target).catch(() => router.push('/'))
|
router.push(target).catch(() => router.push('/'))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,26 @@
|
|||||||
<div class="student-register">
|
<div class="student-register">
|
||||||
<div class="student-register__container">
|
<div class="student-register__container">
|
||||||
<aside class="student-register__sidebar">
|
<aside class="student-register__sidebar">
|
||||||
<SideBarSteps :tabs="tabs" :active-tab="activeTab" @update:active-tab="goToStep" />
|
<SideBarSteps :tabs="tabs" :active-step="store.currentStep" @select-step="goToStep" />
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<main class="student-register__main">
|
<main class="student-register__main">
|
||||||
<header class="student-register__heading">
|
<header class="student-register__heading">
|
||||||
|
<div class="student-register__step-meta">
|
||||||
|
<span>مرحله {{ currentStepNumber }} از {{ totalSteps }}</span>
|
||||||
|
<span>{{ progressPercent }}٪</span>
|
||||||
|
</div>
|
||||||
|
<div class="student-register__progress" aria-hidden="true">
|
||||||
|
<span :style="{ width: `${progressPercent}%` }" />
|
||||||
|
</div>
|
||||||
<h1 class="student-register__title">{{ stepLabel.title }}</h1>
|
<h1 class="student-register__title">{{ stepLabel.title }}</h1>
|
||||||
<p class="student-register__desc">{{ stepLabel.desc }}</p>
|
<p class="student-register__desc">{{ stepLabel.desc }}</p>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<component :is="currentComponent" />
|
<div v-if="isRegistrationDataPending" class="student-register__loading" aria-live="polite">
|
||||||
|
در حال بازیابی اطلاعات ثبتنام…
|
||||||
|
</div>
|
||||||
|
<component :is="currentComponent" v-else />
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -23,10 +33,10 @@
|
|||||||
import useModal from '@/composables/useModal'
|
import useModal from '@/composables/useModal'
|
||||||
import { computed, markRaw, watch } from 'vue'
|
import { computed, markRaw, watch } from 'vue'
|
||||||
import { STUDENT_REGISTRATION } from '@/enums'
|
import { STUDENT_REGISTRATION } from '@/enums'
|
||||||
import { useGetRegisterDataQuery } from '@/services/query/auth'
|
|
||||||
import SideBarSteps from '@/features/auth/components/studentRegister/SideBarSteps.vue'
|
import SideBarSteps from '@/features/auth/components/studentRegister/SideBarSteps.vue'
|
||||||
import SuccessModal from '@/features/auth/components/studentRegister/SuccessModal.vue'
|
import SuccessModal from '@/features/auth/components/studentRegister/SuccessModal.vue'
|
||||||
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
import { useStudentRegistrationStore } from '@/features/auth/store/student-registration'
|
||||||
|
import { useGetRegisterDataQuery, useGetRegistrationVideoQuery } from '@/services/query/auth'
|
||||||
import PersonalInformation from '@/features/auth/components/studentRegister/PersonalInformation.vue'
|
import PersonalInformation from '@/features/auth/components/studentRegister/PersonalInformation.vue'
|
||||||
import SkillAssessmentPart1 from '@/features/auth/components/studentRegister/SkillAssessmentPart1.vue'
|
import SkillAssessmentPart1 from '@/features/auth/components/studentRegister/SkillAssessmentPart1.vue'
|
||||||
import SkillAssessmentPart2 from '@/features/auth/components/studentRegister/SkillAssessmentPart2.vue'
|
import SkillAssessmentPart2 from '@/features/auth/components/studentRegister/SkillAssessmentPart2.vue'
|
||||||
@@ -41,15 +51,21 @@ import ProfessionalInformation from '@/features/auth/components/studentRegister/
|
|||||||
const store = useStudentRegistrationStore()
|
const store = useStudentRegistrationStore()
|
||||||
const { isModal, openModal } = useModal()
|
const { isModal, openModal } = useModal()
|
||||||
|
|
||||||
const { data: registerData } = useGetRegisterDataQuery()
|
const { data: registerData, isPending: isRegistrationDataPending } = useGetRegisterDataQuery()
|
||||||
watch(
|
watch(
|
||||||
registerData,
|
registerData,
|
||||||
(value) => {
|
(value) => {
|
||||||
if (value && Object.keys(value).length > 0) store.hydrateFromRegisterData(value)
|
if (value && Object.keys(value).length > 0) store.hydrateFromRegisterData(value)
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true, flush: 'sync' }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const { data: registrationMedia } = useGetRegistrationVideoQuery({ retry: false })
|
||||||
|
watch(registrationMedia, (value) => store.setRegistrationMedia(value), {
|
||||||
|
immediate: true,
|
||||||
|
flush: 'sync',
|
||||||
|
})
|
||||||
|
|
||||||
const STEP_TO_COMPONENT = {
|
const STEP_TO_COMPONENT = {
|
||||||
[STUDENT_REGISTRATION.PERSONAL_INFORMATION]: markRaw(PersonalInformation),
|
[STUDENT_REGISTRATION.PERSONAL_INFORMATION]: markRaw(PersonalInformation),
|
||||||
[STUDENT_REGISTRATION.EDUCATIONAL_INFORMATION]: markRaw(EducationalInformation),
|
[STUDENT_REGISTRATION.EDUCATIONAL_INFORMATION]: markRaw(EducationalInformation),
|
||||||
@@ -63,26 +79,6 @@ const STEP_TO_COMPONENT = {
|
|||||||
[STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_7]: markRaw(SkillAssessmentPart7),
|
[STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_7]: markRaw(SkillAssessmentPart7),
|
||||||
}
|
}
|
||||||
|
|
||||||
const STEP_TO_TAB = {
|
|
||||||
[STUDENT_REGISTRATION.PERSONAL_INFORMATION]: 'personal',
|
|
||||||
[STUDENT_REGISTRATION.EDUCATIONAL_INFORMATION]: 'educational',
|
|
||||||
[STUDENT_REGISTRATION.PROFESSIONAL_INFORMATION]: 'professional',
|
|
||||||
[STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_1]: 'skill',
|
|
||||||
[STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_2]: 'skill',
|
|
||||||
[STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_3]: 'skill',
|
|
||||||
[STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_4]: 'skill',
|
|
||||||
[STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_5]: 'skill',
|
|
||||||
[STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_6]: 'skill',
|
|
||||||
[STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_7]: 'skill',
|
|
||||||
}
|
|
||||||
|
|
||||||
const TAB_TO_STEP = {
|
|
||||||
personal: STUDENT_REGISTRATION.PERSONAL_INFORMATION,
|
|
||||||
educational: STUDENT_REGISTRATION.EDUCATIONAL_INFORMATION,
|
|
||||||
professional: STUDENT_REGISTRATION.PROFESSIONAL_INFORMATION,
|
|
||||||
skill: STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_1,
|
|
||||||
}
|
|
||||||
|
|
||||||
const STEP_LABELS = {
|
const STEP_LABELS = {
|
||||||
[STUDENT_REGISTRATION.PERSONAL_INFORMATION]: {
|
[STUDENT_REGISTRATION.PERSONAL_INFORMATION]: {
|
||||||
title: 'اطلاعـــــات شخصـــــی',
|
title: 'اطلاعـــــات شخصـــــی',
|
||||||
@@ -126,14 +122,33 @@ const STEP_LABELS = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const tabs = [
|
const STEP_NAVIGATION = [
|
||||||
{ key: 'personal', icon: 'user' },
|
{ step: STUDENT_REGISTRATION.PERSONAL_INFORMATION, title: 'مشخصات فردی', icon: 'user' },
|
||||||
{ key: 'educational', icon: 'book' },
|
{ step: STUDENT_REGISTRATION.EDUCATIONAL_INFORMATION, title: 'اطلاعات تحصیلی', icon: 'book' },
|
||||||
{ key: 'professional', icon: 'file' },
|
{ step: STUDENT_REGISTRATION.PROFESSIONAL_INFORMATION, title: 'فعالیتهای تبلیغی', icon: 'file' },
|
||||||
{ key: 'skill', icon: 'check-square' },
|
{ step: STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_1, title: 'مهارت ۱', icon: 'check-square' },
|
||||||
|
{ step: STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_2, title: 'مهارت ۲', icon: 'check-square' },
|
||||||
|
{ step: STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_3, title: 'مهارت ۳', icon: 'check-square' },
|
||||||
|
{ step: STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_4, title: 'مهارت ۴', icon: 'check-square' },
|
||||||
|
{ step: STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_5, title: 'مهارت ۵', icon: 'check-square' },
|
||||||
|
{ step: STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_6, title: 'مهارت ۶', icon: 'check-square' },
|
||||||
|
{ step: STUDENT_REGISTRATION.SKILL_ASSESSMENT_PART_7, title: 'مهارت ۷', icon: 'check-square' },
|
||||||
]
|
]
|
||||||
|
|
||||||
const activeTab = computed(() => STEP_TO_TAB[store.currentStep] || 'personal')
|
const tabs = computed(() =>
|
||||||
|
STEP_NAVIGATION.map((tab) => ({
|
||||||
|
...tab,
|
||||||
|
completed: store.completedSteps.includes(tab.step),
|
||||||
|
disabled: !store.canGoToStep(tab.step),
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
|
||||||
|
const totalSteps = STEP_NAVIGATION.length
|
||||||
|
const currentStepNumber = computed(() => {
|
||||||
|
const index = STEP_NAVIGATION.findIndex((item) => item.step === store.currentStep)
|
||||||
|
return index >= 0 ? index + 1 : 1
|
||||||
|
})
|
||||||
|
const progressPercent = computed(() => Math.round((currentStepNumber.value / totalSteps) * 100))
|
||||||
|
|
||||||
const currentComponent = computed(
|
const currentComponent = computed(
|
||||||
() =>
|
() =>
|
||||||
@@ -145,12 +160,8 @@ const stepLabel = computed(
|
|||||||
() => STEP_LABELS[store.currentStep] || STEP_LABELS[STUDENT_REGISTRATION.PERSONAL_INFORMATION]
|
() => STEP_LABELS[store.currentStep] || STEP_LABELS[STUDENT_REGISTRATION.PERSONAL_INFORMATION]
|
||||||
)
|
)
|
||||||
|
|
||||||
const goToStep = (tabKey) => {
|
const goToStep = (step) => {
|
||||||
const targetStep = TAB_TO_STEP[tabKey]
|
store.updateCurrentStep(step)
|
||||||
if (!targetStep) return
|
|
||||||
if (store.canGoToStep(targetStep)) {
|
|
||||||
store.updateCurrentStep(targetStep)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@@ -188,9 +199,8 @@ watch(
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
width: 8.333%;
|
width: 13.5rem;
|
||||||
min-width: 5rem;
|
min-width: 13.5rem;
|
||||||
max-width: 6.5rem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,23 +216,97 @@ watch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__heading {
|
&__heading {
|
||||||
|
margin-bottom: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__step-meta {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 0.375rem;
|
||||||
|
color: #6f6f6f;
|
||||||
|
font-family: var(--font-family-number-fa);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__progress {
|
||||||
|
width: 100%;
|
||||||
|
height: 0.35rem;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #f2f2f2;
|
||||||
|
|
||||||
|
span {
|
||||||
|
display: block;
|
||||||
|
height: 100%;
|
||||||
|
border-radius: inherit;
|
||||||
|
background: var(--color-primary);
|
||||||
|
transition: width 0.2s ease;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
font-family: var(--font-family-fa);
|
font-family: var(--font-family-fa);
|
||||||
font-weight: 500;
|
font-weight: 600;
|
||||||
font-size: 1.125rem;
|
font-size: 1.375rem;
|
||||||
color: #4c4c4c;
|
color: #3f3f3f;
|
||||||
margin: 0 0 0.25rem;
|
margin: 0 0 0.375rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__desc {
|
&__desc {
|
||||||
font-family: var(--font-family-fa);
|
font-family: var(--font-family-fa);
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 0.75rem;
|
font-size: 0.9375rem;
|
||||||
color: #adadad;
|
line-height: 1.8;
|
||||||
|
color: #747474;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__loading {
|
||||||
|
padding: 3rem 1rem;
|
||||||
|
color: #747474;
|
||||||
|
font-family: var(--font-family-fa);
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__main :deep(.text-field__label),
|
||||||
|
&__main :deep(.textarea-field__label),
|
||||||
|
&__main :deep(.select-field__label),
|
||||||
|
&__main :deep(.datepicker-field__label) {
|
||||||
|
color: #626262;
|
||||||
|
font-size: 0.9375rem;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__main :deep(.text-field__input),
|
||||||
|
&__main :deep(.textarea-field__input),
|
||||||
|
&__main :deep(.select-field__trigger),
|
||||||
|
&__main :deep(.datepicker-field__trigger) {
|
||||||
|
min-height: 2.6rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__main :deep(.line-title__fa) {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__main :deep(.line-title__en) {
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__main :deep(.text-field__error),
|
||||||
|
&__main :deep(.textarea-field__error),
|
||||||
|
&__main :deep(.select-field__error),
|
||||||
|
&__main :deep(.datepicker-field__error) {
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { array, mixed, number, object, string } from 'yup'
|
import { array, mixed, number, object, string } from 'yup'
|
||||||
|
|
||||||
import { phoneNumberRule } from '@/constants/rules/phoneNumberRule'
|
|
||||||
import { nationalCodeRule } from '@/constants/rules/nationalCodeRule'
|
import { nationalCodeRule } from '@/constants/rules/nationalCodeRule'
|
||||||
|
|
||||||
const requiredString = (min = 0) => {
|
const requiredString = (min = 0) => {
|
||||||
@@ -16,7 +15,9 @@ export const personalInformationSchema = object().shape({
|
|||||||
nationalCode: nationalCodeRule,
|
nationalCode: nationalCodeRule,
|
||||||
maritalStatus: string().required(),
|
maritalStatus: string().required(),
|
||||||
gender: string().required(),
|
gender: string().required(),
|
||||||
phone: phoneNumberRule,
|
// The verified phone is read-only here and may be returned in international
|
||||||
|
// format (for example +98912...). Do not re-validate it as a local 09 number.
|
||||||
|
phone: string().required(),
|
||||||
provinceId: mixed().required(),
|
provinceId: mixed().required(),
|
||||||
cityId: mixed().required(),
|
cityId: mixed().required(),
|
||||||
address: requiredString(10),
|
address: requiredString(10),
|
||||||
@@ -118,11 +119,11 @@ export const skillAssessmentPart5Schema = object().shape({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const skillAssessmentPart6Schema = object().shape({
|
export const skillAssessmentPart6Schema = object().shape({
|
||||||
faithProductionAudio: mixed().required(),
|
faithProductionAudio: mixed().nullable().notRequired(),
|
||||||
faithProductionId: mixed().notRequired(),
|
faithProductionId: mixed().notRequired(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const skillAssessmentPart7Schema = object().shape({
|
export const skillAssessmentPart7Schema = object().shape({
|
||||||
leaderMessageVideo: mixed().required(),
|
leaderMessageVideo: mixed().nullable().notRequired(),
|
||||||
leaderMessageId: mixed().notRequired(),
|
leaderMessageId: mixed().notRequired(),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -145,6 +145,21 @@ const readPersisted = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const normalizeCompletedSteps = (steps) =>
|
||||||
|
Array.isArray(steps) ? STUDENT_REGISTRATION_ORDER.filter((step) => steps.includes(step)) : []
|
||||||
|
|
||||||
|
const firstIncompleteIndex = (steps) => {
|
||||||
|
const index = STUDENT_REGISTRATION_ORDER.findIndex((step) => !steps.includes(step))
|
||||||
|
return index === -1 ? STUDENT_REGISTRATION_ORDER.length - 1 : index
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolveCurrentStep = (candidate, completed) => {
|
||||||
|
const candidateIndex = STUDENT_REGISTRATION_ORDER.indexOf(candidate)
|
||||||
|
const reachableIndex = firstIncompleteIndex(completed)
|
||||||
|
if (candidateIndex >= 0 && candidateIndex <= reachableIndex) return candidate
|
||||||
|
return STUDENT_REGISTRATION_ORDER[reachableIndex]
|
||||||
|
}
|
||||||
|
|
||||||
export const useStudentRegistrationStore = defineStore('studentRegistration', () => {
|
export const useStudentRegistrationStore = defineStore('studentRegistration', () => {
|
||||||
const persisted = readPersisted() || {}
|
const persisted = readPersisted() || {}
|
||||||
const initial = { ...emptyState(), ...persisted }
|
const initial = { ...emptyState(), ...persisted }
|
||||||
@@ -160,8 +175,8 @@ export const useStudentRegistrationStore = defineStore('studentRegistration', ()
|
|||||||
const skill5 = ref({ ...emptyState().skill5, ...persisted.skill5 })
|
const skill5 = ref({ ...emptyState().skill5, ...persisted.skill5 })
|
||||||
const skill6 = ref({ ...emptyState().skill6, ...persisted.skill6 })
|
const skill6 = ref({ ...emptyState().skill6, ...persisted.skill6 })
|
||||||
const skill7 = ref({ ...emptyState().skill7, ...persisted.skill7 })
|
const skill7 = ref({ ...emptyState().skill7, ...persisted.skill7 })
|
||||||
const currentStep = ref(initial.currentStep)
|
const completedSteps = ref(normalizeCompletedSteps(initial.completedSteps))
|
||||||
const completedSteps = ref(initial.completedSteps || [])
|
const currentStep = ref(resolveCurrentStep(initial.currentStep, completedSteps.value))
|
||||||
const registrationMedia = ref(initial.registrationMedia || {})
|
const registrationMedia = ref(initial.registrationMedia || {})
|
||||||
|
|
||||||
const sectionRefs = {
|
const sectionRefs = {
|
||||||
@@ -207,18 +222,33 @@ export const useStudentRegistrationStore = defineStore('studentRegistration', ()
|
|||||||
)
|
)
|
||||||
|
|
||||||
const markStepAsCompleted = (stepKey) => {
|
const markStepAsCompleted = (stepKey) => {
|
||||||
if (!completedSteps.value.includes(stepKey)) {
|
if (STUDENT_REGISTRATION_ORDER.includes(stepKey) && !completedSteps.value.includes(stepKey)) {
|
||||||
completedSteps.value = [...completedSteps.value, stepKey]
|
completedSteps.value = [...completedSteps.value, stepKey]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateCurrentStep = (stepKey) => {
|
const updateCurrentStep = (stepKey) => {
|
||||||
if (stepKey) currentStep.value = stepKey
|
if (canGoToStep(stepKey)) currentStep.value = stepKey
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateSection = (section, value) => {
|
||||||
|
const target = sectionRefs[section]
|
||||||
|
if (!target || !value || typeof value !== 'object') return
|
||||||
|
target.value = { ...target.value, ...value }
|
||||||
|
}
|
||||||
|
|
||||||
|
const setRegistrationMedia = (value) => {
|
||||||
|
if (!value || typeof value !== 'object') return
|
||||||
|
registrationMedia.value = { ...registrationMedia.value, ...value }
|
||||||
}
|
}
|
||||||
|
|
||||||
const goToNextStep = () => {
|
const goToNextStep = () => {
|
||||||
const idx = STUDENT_REGISTRATION_ORDER.indexOf(currentStep.value)
|
const idx = STUDENT_REGISTRATION_ORDER.indexOf(currentStep.value)
|
||||||
if (idx >= 0 && idx < STUDENT_REGISTRATION_ORDER.length - 1) {
|
if (
|
||||||
|
idx >= 0 &&
|
||||||
|
idx < STUDENT_REGISTRATION_ORDER.length - 1 &&
|
||||||
|
completedSteps.value.includes(currentStep.value)
|
||||||
|
) {
|
||||||
currentStep.value = STUDENT_REGISTRATION_ORDER[idx + 1]
|
currentStep.value = STUDENT_REGISTRATION_ORDER[idx + 1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,9 +259,8 @@ export const useStudentRegistrationStore = defineStore('studentRegistration', ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const canGoToStep = (stepKey) => {
|
const canGoToStep = (stepKey) => {
|
||||||
const currentIndex = STUDENT_REGISTRATION_ORDER.indexOf(currentStep.value)
|
|
||||||
const targetIndex = STUDENT_REGISTRATION_ORDER.indexOf(stepKey)
|
const targetIndex = STUDENT_REGISTRATION_ORDER.indexOf(stepKey)
|
||||||
return targetIndex <= currentIndex + 1
|
return targetIndex >= 0 && targetIndex <= firstIncompleteIndex(completedSteps.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildCompletePayload = () => ({
|
const buildCompletePayload = () => ({
|
||||||
@@ -307,6 +336,8 @@ export const useStudentRegistrationStore = defineStore('studentRegistration', ()
|
|||||||
registrationMedia,
|
registrationMedia,
|
||||||
markStepAsCompleted,
|
markStepAsCompleted,
|
||||||
updateCurrentStep,
|
updateCurrentStep,
|
||||||
|
updateSection,
|
||||||
|
setRegistrationMedia,
|
||||||
goToNextStep,
|
goToNextStep,
|
||||||
goToPrevStep,
|
goToPrevStep,
|
||||||
canGoToStep,
|
canGoToStep,
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ const downloadItems = computed(() => [
|
|||||||
|
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
order: 3;
|
order: 1;
|
||||||
min-width: 12rem;
|
min-width: 12rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,8 +146,8 @@ const downloadItems = computed(() => [
|
|||||||
&__course-info {
|
&__course-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: flex-end;
|
||||||
text-align: end;
|
text-align: right;
|
||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
@@ -186,6 +186,7 @@ const downloadItems = computed(() => [
|
|||||||
background: rgba(107, 107, 107, 4%);
|
background: rgba(107, 107, 107, 4%);
|
||||||
font-family: var(--font-family-fa);
|
font-family: var(--font-family-fa);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
align-self: center;
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
order: 2;
|
order: 2;
|
||||||
@@ -222,15 +223,20 @@ const downloadItems = computed(() => [
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
order: 1;
|
order: 3;
|
||||||
justify-content: flex-start;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__download-btn {
|
&__download-btn {
|
||||||
min-width: 9rem;
|
width: 100%;
|
||||||
height: 2rem;
|
height: 2rem;
|
||||||
padding: 0 1.25rem;
|
padding: 0 1.25rem;
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
width: auto;
|
||||||
|
min-width: 9rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import { computed, ref } from 'vue'
|
|||||||
import { toast } from 'vue3-toastify'
|
import { toast } from 'vue3-toastify'
|
||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||||
import NoItems from '@/components/blocks/NoItems.vue'
|
import NoItems from '@/components/blocks/NoItems.vue'
|
||||||
|
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||||
import { usePagination } from '@/composables/usePagination'
|
import { usePagination } from '@/composables/usePagination'
|
||||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||||
@@ -53,7 +54,17 @@ const { data, isLoading } = useStudentCertificatesQuery(filters, pagination, {
|
|||||||
keepPreviousData: true,
|
keepPreviousData: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
const certificates = computed(() => data.value?.data ?? [])
|
// Bridge the backend payload (title/teacherName/startedAt/endedAt) into the
|
||||||
|
// display shape CertificateItem expects, without touching its template.
|
||||||
|
const certificates = computed(() =>
|
||||||
|
(data.value?.data ?? []).map((c) => ({
|
||||||
|
...c,
|
||||||
|
courseTitle: c.title ?? '',
|
||||||
|
teacherName: c.teacherName ?? '',
|
||||||
|
startDate: formatJalaaliDate(c.startedAt) || '',
|
||||||
|
endDate: formatJalaaliDate(c.endedAt) || '',
|
||||||
|
}))
|
||||||
|
)
|
||||||
const meta = computed(() => ({
|
const meta = computed(() => ({
|
||||||
page: pagination.value.page,
|
page: pagination.value.page,
|
||||||
perPage: pagination.value.perPage,
|
perPage: pagination.value.perPage,
|
||||||
|
|||||||
@@ -91,11 +91,11 @@ const performanceStats = computed(() => {
|
|||||||
const stats = dashboard.value.stats ?? {}
|
const stats = dashboard.value.stats ?? {}
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
icon: 'user-sound',
|
icon: 'video',
|
||||||
label: 'تعداد جلسات اعزام شده',
|
label: 'تعداد جلسات آموزشی گذراندهشده',
|
||||||
value: toFaDigits(stats.attendedSessions ?? 0),
|
value: toFaDigits(stats.attendedSessions ?? 0),
|
||||||
unit: 'جلسه',
|
unit: 'جلسه',
|
||||||
subtitle: 'اعزام شده است',
|
subtitle: 'با موفقیت گذرانده شده',
|
||||||
to: { name: 'student-terms' },
|
to: { name: 'student-terms' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,21 +31,29 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="contentKind === 'audio'" class="ssd__audio">
|
<div v-else-if="contentKind === 'audio'" class="ssd__audio">
|
||||||
<VoiceRecorder
|
<VoiceRecorder :model-value="session?.audioUrl" disabled />
|
||||||
:model-value="session?.audioUrl"
|
|
||||||
disabled
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="contentKind === 'text'" class="ssd__text">
|
<div v-else-if="contentKind === 'text'" class="ssd__text">
|
||||||
<SvgIcon name="warning" :size="22" color="#b8b8b8" class="ssd__text-icon" />
|
<SvgIcon name="warning" :size="22" color="#b8b8b8" class="ssd__text-icon" />
|
||||||
<p class="ssd__text-body">{{ session.text }}</p>
|
<p class="ssd__text-body">{{ session.text }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else-if="contentKind === 'embed'" class="ssd__embed">
|
||||||
|
<iframe
|
||||||
|
class="ssd__embed-frame"
|
||||||
|
:srcdoc="session.embedCode"
|
||||||
|
sandbox="allow-scripts allow-popups allow-forms allow-presentation"
|
||||||
|
allow="autoplay; fullscreen; picture-in-picture"
|
||||||
|
allowfullscreen
|
||||||
|
loading="lazy"
|
||||||
|
referrerpolicy="no-referrer"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div v-else-if="contentKind === 'link'" class="ssd__link">
|
<div v-else-if="contentKind === 'link'" class="ssd__link">
|
||||||
<div class="ssd__link__box">
|
<div class="ssd__link__box">
|
||||||
<span>https://link</span>
|
<span>{{ session?.link || 'لینکی ثبت نشده است' }}</span>
|
||||||
<SvgIcon name="link" :size="22" class="ssd__link-icon" />
|
<SvgIcon name="link" :size="22" class="ssd__link-icon" />
|
||||||
</div>
|
</div>
|
||||||
<BaseButton text="ورود به جلسه " custom-class="ssd__link-btn">
|
<BaseButton text="ورود به جلسه " custom-class="ssd__link-btn" @click="openSessionLink">
|
||||||
<template #appendIcon>
|
<template #appendIcon>
|
||||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||||
</template>
|
</template>
|
||||||
@@ -132,13 +140,17 @@ const homework = computed(() => (homeworksData.value?.data ?? [])[0] ?? null)
|
|||||||
const contentKind = computed(() => {
|
const contentKind = computed(() => {
|
||||||
const s = session.value
|
const s = session.value
|
||||||
if (!s) return ''
|
if (!s) return ''
|
||||||
if (s.type === 'online') return 'link'
|
if (s.type === 'online') return s.embedCode?.trim() ? 'embed' : 'link'
|
||||||
if (s.videoUrl) return 'link'
|
if (s.videoUrl) return 'video'
|
||||||
if (s.audioUrl) return 'audio'
|
if (s.audioUrl) return 'audio'
|
||||||
if (s.text) return 'text'
|
if (s.text) return 'text'
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const openSessionLink = () => {
|
||||||
|
if (session.value?.link) window.open(session.value.link, '_blank', 'noopener,noreferrer')
|
||||||
|
}
|
||||||
|
|
||||||
const homeworkAudio = ref(null)
|
const homeworkAudio = ref(null)
|
||||||
const homeworkImage = ref(null)
|
const homeworkImage = ref(null)
|
||||||
const errors = reactive({ audio: '', image: '' })
|
const errors = reactive({ audio: '', image: '' })
|
||||||
@@ -263,6 +275,18 @@ const onSubmit = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__embed {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__embed-frame {
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 16 / 9;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 1rem;
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
|
||||||
&__link {
|
&__link {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -40,13 +40,16 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useUIStore } from '@/store/ui'
|
import { useUIStore } from '@/store/ui'
|
||||||
|
import { useAuthStore } from '@/store/auth'
|
||||||
import { RouterView, useRoute } from 'vue-router'
|
import { RouterView, useRoute } from 'vue-router'
|
||||||
import Copyright from '@/components/Copyright.vue'
|
import Copyright from '@/components/Copyright.vue'
|
||||||
import HeaderBlock from '@/components/HeaderBlock.vue'
|
import HeaderBlock from '@/components/HeaderBlock.vue'
|
||||||
|
import { buildMergedMenuItems } from '@/layouts/roleMenuItems'
|
||||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||||
import CounselorSidebar from '@/layouts/sidebars/CounselorSidebar.vue'
|
import CounselorSidebar from '@/layouts/sidebars/CounselorSidebar.vue'
|
||||||
|
|
||||||
const ui = useUIStore()
|
const ui = useUIStore()
|
||||||
|
const auth = useAuthStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const isMobile = ref(window.innerWidth < 1024)
|
const isMobile = ref(window.innerWidth < 1024)
|
||||||
@@ -59,20 +62,7 @@ onBeforeUnmount(() => window.removeEventListener('resize', onResize))
|
|||||||
const pageTitle = computed(() => route.meta?.title || 'مشاوره')
|
const pageTitle = computed(() => route.meta?.title || 'مشاوره')
|
||||||
const pageSubtitle = computed(() => route.meta?.subtitle || '')
|
const pageSubtitle = computed(() => route.meta?.subtitle || '')
|
||||||
|
|
||||||
const menuItems = computed(() => [
|
const menuItems = computed(() => buildMergedMenuItems(auth.roles, route))
|
||||||
{
|
|
||||||
title: 'پیشخوان',
|
|
||||||
icon: 'menu',
|
|
||||||
to: { name: 'counselor-dashboard' },
|
|
||||||
active: route.name === 'counselor-dashboard',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'مشاوره',
|
|
||||||
icon: 'chat',
|
|
||||||
to: { name: 'counselor-consultations' },
|
|
||||||
active: route.name === 'counselor-consultations',
|
|
||||||
},
|
|
||||||
])
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -38,13 +38,16 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useUIStore } from '@/store/ui'
|
import { useUIStore } from '@/store/ui'
|
||||||
|
import { useAuthStore } from '@/store/auth'
|
||||||
import { RouterView, useRoute } from 'vue-router'
|
import { RouterView, useRoute } from 'vue-router'
|
||||||
import Copyright from '@/components/Copyright.vue'
|
import Copyright from '@/components/Copyright.vue'
|
||||||
import HeaderBlock from '@/components/HeaderBlock.vue'
|
import HeaderBlock from '@/components/HeaderBlock.vue'
|
||||||
|
import { buildMergedMenuItems } from '@/layouts/roleMenuItems'
|
||||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||||
import StudentSidebar from '@/layouts/sidebars/StudentSidebar.vue'
|
import StudentSidebar from '@/layouts/sidebars/StudentSidebar.vue'
|
||||||
|
|
||||||
const ui = useUIStore()
|
const ui = useUIStore()
|
||||||
|
const auth = useAuthStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const isMobile = ref(window.innerWidth < 1024)
|
const isMobile = ref(window.innerWidth < 1024)
|
||||||
@@ -57,32 +60,7 @@ onBeforeUnmount(() => window.removeEventListener('resize', onResize))
|
|||||||
const pageTitle = computed(() => route.meta?.title || 'سیستم مدیریت اعزام')
|
const pageTitle = computed(() => route.meta?.title || 'سیستم مدیریت اعزام')
|
||||||
const pageSubtitle = computed(() => route.meta?.subtitle || '')
|
const pageSubtitle = computed(() => route.meta?.subtitle || '')
|
||||||
|
|
||||||
const menuItems = computed(() => [
|
const menuItems = computed(() => buildMergedMenuItems(auth.roles, route))
|
||||||
{
|
|
||||||
title: 'پیشخوان',
|
|
||||||
icon: 'menu',
|
|
||||||
to: { name: 'missionary-dashboard' },
|
|
||||||
active: route.name === 'missionary-dashboard',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'سامانه اعزام',
|
|
||||||
icon: 'user-sound',
|
|
||||||
to: { name: 'missionary-requests' },
|
|
||||||
active: route.name === 'missionary-requests',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'آموزش من',
|
|
||||||
icon: 'graduation-cap',
|
|
||||||
to: { name: 'missionary-education' },
|
|
||||||
active: route.name?.startsWith('missionary-education'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'تیکت',
|
|
||||||
icon: 'envelope-open',
|
|
||||||
to: { name: 'missionary-tickets' },
|
|
||||||
active: route.name === 'missionary-tickets',
|
|
||||||
},
|
|
||||||
])
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -38,13 +38,16 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useUIStore } from '@/store/ui'
|
import { useUIStore } from '@/store/ui'
|
||||||
|
import { useAuthStore } from '@/store/auth'
|
||||||
import { RouterView, useRoute } from 'vue-router'
|
import { RouterView, useRoute } from 'vue-router'
|
||||||
import Copyright from '@/components/Copyright.vue'
|
import Copyright from '@/components/Copyright.vue'
|
||||||
import HeaderBlock from '@/components/HeaderBlock.vue'
|
import HeaderBlock from '@/components/HeaderBlock.vue'
|
||||||
|
import { buildMergedMenuItems } from '@/layouts/roleMenuItems'
|
||||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||||
import StudentSidebar from '@/layouts/sidebars/StudentSidebar.vue'
|
import StudentSidebar from '@/layouts/sidebars/StudentSidebar.vue'
|
||||||
|
|
||||||
const ui = useUIStore()
|
const ui = useUIStore()
|
||||||
|
const auth = useAuthStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const isMobile = ref(window.innerWidth < 1024)
|
const isMobile = ref(window.innerWidth < 1024)
|
||||||
@@ -57,52 +60,7 @@ onBeforeUnmount(() => window.removeEventListener('resize', onResize))
|
|||||||
const pageTitle = computed(() => route.meta?.title || 'پیشخوان')
|
const pageTitle = computed(() => route.meta?.title || 'پیشخوان')
|
||||||
const pageSubtitle = computed(() => route.meta?.subtitle || '')
|
const pageSubtitle = computed(() => route.meta?.subtitle || '')
|
||||||
|
|
||||||
const menuItems = computed(() => [
|
const menuItems = computed(() => buildMergedMenuItems(auth.roles, route))
|
||||||
{
|
|
||||||
title: 'داشبورد',
|
|
||||||
icon: 'monitor',
|
|
||||||
to: { name: 'student-dashboard' },
|
|
||||||
active: route.name === 'student-dashboard',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'آموزش',
|
|
||||||
icon: 'graduation-cap',
|
|
||||||
to: { name: 'student-terms' },
|
|
||||||
active: [
|
|
||||||
'student-terms',
|
|
||||||
'student-term-details',
|
|
||||||
'student-lesson-details',
|
|
||||||
'student-session-details',
|
|
||||||
'student-exam',
|
|
||||||
'student-courses',
|
|
||||||
'student-course-details',
|
|
||||||
].includes(route.name),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'خدمات',
|
|
||||||
icon: 'folder-simple-star',
|
|
||||||
to: { name: 'student-services' },
|
|
||||||
active: route.name === 'student-services',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'گواهینامه',
|
|
||||||
icon: 'certificate',
|
|
||||||
to: { name: 'student-certificates' },
|
|
||||||
active: route.name === 'student-certificates',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'ویرایش پروفایل',
|
|
||||||
icon: 'user-circle-check',
|
|
||||||
to: { name: 'student-profile' },
|
|
||||||
active: route.name === 'student-profile',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'تیکت',
|
|
||||||
icon: 'envelope-open',
|
|
||||||
to: { name: 'student-tickets' },
|
|
||||||
active: route.name === 'student-tickets',
|
|
||||||
},
|
|
||||||
])
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
// Per-role sidebar sections, kept as plain builder functions so any layout
|
||||||
|
// can request the union of sections for every role a user holds — additive
|
||||||
|
// multi-role access without each layout hardcoding its own single-role list.
|
||||||
|
// Only roles with a registered builder participate in the merge; a role
|
||||||
|
// without one (e.g. admin) contributes nothing and keeps its own standalone
|
||||||
|
// menu untouched.
|
||||||
|
|
||||||
|
export const buildStudentMenuItems = (route) => [
|
||||||
|
{
|
||||||
|
title: 'داشبورد',
|
||||||
|
icon: 'monitor',
|
||||||
|
to: { name: 'student-dashboard' },
|
||||||
|
active: route.name === 'student-dashboard',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'آموزش',
|
||||||
|
icon: 'graduation-cap',
|
||||||
|
to: { name: 'student-terms' },
|
||||||
|
active: [
|
||||||
|
'student-terms',
|
||||||
|
'student-term-details',
|
||||||
|
'student-lesson-details',
|
||||||
|
'student-session-details',
|
||||||
|
'student-exam',
|
||||||
|
'student-courses',
|
||||||
|
'student-course-details',
|
||||||
|
].includes(route.name),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'خدمات',
|
||||||
|
icon: 'folder-simple-star',
|
||||||
|
to: { name: 'student-services' },
|
||||||
|
active: route.name === 'student-services',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'مشاوره',
|
||||||
|
icon: 'chat-teardrop-text',
|
||||||
|
to: { name: 'student-consultants' },
|
||||||
|
active: route.name === 'student-consultants',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'گواهینامه',
|
||||||
|
icon: 'certificate',
|
||||||
|
to: { name: 'student-certificates' },
|
||||||
|
active: route.name === 'student-certificates',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'ویرایش پروفایل',
|
||||||
|
icon: 'user-circle-check',
|
||||||
|
to: { name: 'student-profile' },
|
||||||
|
active: route.name === 'student-profile',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'تیکت',
|
||||||
|
icon: 'envelope-open',
|
||||||
|
to: { name: 'student-tickets' },
|
||||||
|
active: route.name === 'student-tickets',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
export const buildMissionaryMenuItems = (route) => [
|
||||||
|
{
|
||||||
|
title: 'پیشخوان',
|
||||||
|
icon: 'menu',
|
||||||
|
to: { name: 'missionary-dashboard' },
|
||||||
|
active: route.name === 'missionary-dashboard',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'سامانه اعزام',
|
||||||
|
icon: 'user-sound',
|
||||||
|
to: { name: 'missionary-requests' },
|
||||||
|
active: route.name === 'missionary-requests',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'آموزش من',
|
||||||
|
icon: 'graduation-cap',
|
||||||
|
to: { name: 'missionary-education' },
|
||||||
|
active: route.name?.startsWith('missionary-education'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'تیکت',
|
||||||
|
icon: 'envelope-open',
|
||||||
|
to: { name: 'missionary-tickets' },
|
||||||
|
active: route.name === 'missionary-tickets',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
export const buildCounselorMenuItems = (route) => [
|
||||||
|
{
|
||||||
|
title: 'پیشخوان',
|
||||||
|
icon: 'menu',
|
||||||
|
to: { name: 'counselor-dashboard' },
|
||||||
|
active: route.name === 'counselor-dashboard',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'مشاوره',
|
||||||
|
icon: 'chat',
|
||||||
|
to: { name: 'counselor-consultations' },
|
||||||
|
active: route.name === 'counselor-consultations',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
const MENU_BUILDERS = {
|
||||||
|
student: buildStudentMenuItems,
|
||||||
|
missionary: buildMissionaryMenuItems,
|
||||||
|
counselor: buildCounselorMenuItems,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Union of every panel section unlocked by `roles`, in role order (roles
|
||||||
|
* come back from the API ordered by role id, so a user's base role's
|
||||||
|
* sections lead and each additional role's sections are appended after).
|
||||||
|
*/
|
||||||
|
export const buildMergedMenuItems = (roles, route) => {
|
||||||
|
const seen = new Set()
|
||||||
|
const items = []
|
||||||
|
for (const roleName of roles ?? []) {
|
||||||
|
const builder = MENU_BUILDERS[roleName]
|
||||||
|
if (!builder || seen.has(roleName)) continue
|
||||||
|
seen.add(roleName)
|
||||||
|
items.push(...builder(route))
|
||||||
|
}
|
||||||
|
return items
|
||||||
|
}
|
||||||
@@ -1,31 +1,53 @@
|
|||||||
<template>
|
<template>
|
||||||
<aside class="admin-sidebar">
|
<aside class="admin-sidebar">
|
||||||
<div class="admin-sidebar__logo">
|
<div class="admin-sidebar__logo">
|
||||||
<img :src="logo" alt="مدرسه بانو" />
|
<a :href="MAIN_SITE_URL">
|
||||||
|
<img :src="logo" alt="مدرسه بانو" />
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<nav class="admin-sidebar__nav">
|
<nav class="admin-sidebar__nav">
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="item in menuItems" :key="item.title" class="admin-sidebar__item">
|
<li v-for="(item, index) in menuItems" :key="item.title" class="admin-sidebar__item">
|
||||||
<component
|
<button
|
||||||
:is="item.to ? 'RouterLink' : 'div'"
|
v-if="item.children?.length"
|
||||||
|
type="button"
|
||||||
|
class="admin-sidebar__link"
|
||||||
|
:class="{ 'admin-sidebar__link--active': item.active }"
|
||||||
|
:aria-expanded="isExpanded(item)"
|
||||||
|
:aria-controls="submenuId(index)"
|
||||||
|
@click="toggle(item)"
|
||||||
|
>
|
||||||
|
<SvgIcon v-if="item.icon" :name="item.icon" :size="22" />
|
||||||
|
<span>{{ item.title }}</span>
|
||||||
|
<SvgIcon
|
||||||
|
name="caret-down"
|
||||||
|
:size="16"
|
||||||
|
class="admin-sidebar__chevron"
|
||||||
|
:class="{ 'admin-sidebar__chevron--expanded': isExpanded(item) }"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
<RouterLink
|
||||||
|
v-else
|
||||||
:to="item.to"
|
:to="item.to"
|
||||||
class="admin-sidebar__link"
|
class="admin-sidebar__link"
|
||||||
:class="{ 'admin-sidebar__link--active': item.active }"
|
:class="{ 'admin-sidebar__link--active': item.active }"
|
||||||
>
|
>
|
||||||
<SvgIcon v-if="item.icon" :name="item.icon" :size="22" />
|
<SvgIcon v-if="item.icon" :name="item.icon" :size="22" />
|
||||||
<span>{{ item.title }}</span>
|
<span>{{ item.title }}</span>
|
||||||
</component>
|
</RouterLink>
|
||||||
<ul v-if="item.children?.length" class="admin-sidebar__submenu">
|
<Transition v-if="item.children?.length" name="admin-sidebar__accordion">
|
||||||
<li v-for="child in item.children" :key="child.title">
|
<ul v-show="isExpanded(item)" :id="submenuId(index)" class="admin-sidebar__submenu">
|
||||||
<RouterLink
|
<li v-for="child in item.children" :key="child.title">
|
||||||
:to="child.to"
|
<RouterLink
|
||||||
class="admin-sidebar__sublink"
|
:to="child.to"
|
||||||
:class="{ 'admin-sidebar__sublink--active': child.active }"
|
class="admin-sidebar__sublink"
|
||||||
>
|
:class="{ 'admin-sidebar__sublink--active': child.active }"
|
||||||
{{ child.title }}
|
>
|
||||||
</RouterLink>
|
{{ child.title }}
|
||||||
</li>
|
</RouterLink>
|
||||||
</ul>
|
</li>
|
||||||
|
</ul>
|
||||||
|
</Transition>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -34,16 +56,44 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { ref, watch } from 'vue'
|
||||||
import { RouterLink } from 'vue-router'
|
import { RouterLink } from 'vue-router'
|
||||||
|
import { MAIN_SITE_URL } from '@/enums'
|
||||||
import { gallery } from '@/utils/gallery'
|
import { gallery } from '@/utils/gallery'
|
||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||||
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'
|
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'
|
||||||
|
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
menuItems: { type: Array, default: () => [] },
|
menuItems: { type: Array, default: () => [] },
|
||||||
})
|
})
|
||||||
|
|
||||||
const logo = gallery.logoPinkishRed
|
const logo = gallery.logoPinkishRed
|
||||||
|
const expandedItems = ref({})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.menuItems,
|
||||||
|
(items) => {
|
||||||
|
const next = { ...expandedItems.value }
|
||||||
|
items.forEach((item) => {
|
||||||
|
if (!item.children?.length) return
|
||||||
|
if (!(item.title in next)) next[item.title] = false
|
||||||
|
if (item.active) next[item.title] = true
|
||||||
|
})
|
||||||
|
expandedItems.value = next
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
const isExpanded = (item) => Boolean(expandedItems.value[item.title])
|
||||||
|
|
||||||
|
const toggle = (item) => {
|
||||||
|
expandedItems.value = {
|
||||||
|
...expandedItems.value,
|
||||||
|
[item.title]: !isExpanded(item),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const submenuId = (index) => `admin-sidebar-submenu-${index}`
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@@ -82,6 +132,7 @@ const logo = gallery.logoPinkishRed
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__link {
|
&__link {
|
||||||
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.625rem;
|
gap: 0.625rem;
|
||||||
@@ -91,6 +142,9 @@ const logo = gallery.logoPinkishRed
|
|||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
color: #4b5563;
|
color: #4b5563;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
text-align: start;
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
transition: background-color 0.15s, color 0.15s;
|
transition: background-color 0.15s, color 0.15s;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
@@ -105,6 +159,15 @@ const logo = gallery.logoPinkishRed
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__chevron {
|
||||||
|
margin-inline-start: auto;
|
||||||
|
transition: transform 0.2s ease;
|
||||||
|
|
||||||
|
&--expanded {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&__submenu {
|
&__submenu {
|
||||||
margin-top: 0.25rem !important;
|
margin-top: 0.25rem !important;
|
||||||
padding-inline-start: 1.5rem !important;
|
padding-inline-start: 1.5rem !important;
|
||||||
@@ -130,5 +193,23 @@ const logo = gallery.logoPinkishRed
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__accordion-enter-active,
|
||||||
|
&__accordion-leave-active {
|
||||||
|
overflow: hidden;
|
||||||
|
transition: max-height 0.2s ease, opacity 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__accordion-enter-from,
|
||||||
|
&__accordion-leave-to {
|
||||||
|
max-height: 0;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__accordion-enter-to,
|
||||||
|
&__accordion-leave-from {
|
||||||
|
max-height: 16rem;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<aside class="counselor-sidebar">
|
<aside class="counselor-sidebar">
|
||||||
<div class="counselor-sidebar__logo">
|
<div class="counselor-sidebar__logo">
|
||||||
<img :src="logo" alt="مدرسه بانو" />
|
<a :href="MAIN_SITE_URL">
|
||||||
|
<img :src="logo" alt="مدرسه بانو" />
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<nav class="counselor-sidebar__nav">
|
<nav class="counselor-sidebar__nav">
|
||||||
<ul>
|
<ul>
|
||||||
@@ -23,6 +25,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { MAIN_SITE_URL } from '@/enums'
|
||||||
import { gallery } from '@/utils/gallery'
|
import { gallery } from '@/utils/gallery'
|
||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||||
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'
|
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<aside class="student-sidebar" :style="{ backgroundImage: `url(${bgPattern})` }">
|
<aside class="student-sidebar" :style="{ backgroundImage: `url(${bgPattern})` }">
|
||||||
<div class="student-sidebar__logo">
|
<div class="student-sidebar__logo">
|
||||||
<img :src="logo" alt="مدرسه بانو" />
|
<a :href="MAIN_SITE_URL">
|
||||||
|
<img :src="logo" alt="مدرسه بانو" />
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<nav class="student-sidebar__nav">
|
<nav class="student-sidebar__nav">
|
||||||
<ul>
|
<ul>
|
||||||
@@ -23,6 +25,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { MAIN_SITE_URL } from '@/enums'
|
||||||
import { gallery } from '@/utils/gallery'
|
import { gallery } from '@/utils/gallery'
|
||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||||
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'
|
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export const statusGuard = (to) => {
|
|||||||
if (!tokenService.hasToken()) return
|
if (!tokenService.hasToken()) return
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
if (!auth.user) return
|
if (!auth.user) return
|
||||||
if (auth.role && auth.role !== 'student') return
|
if (!auth.roles.includes('student')) return
|
||||||
if (auth.user.status === 'approved') return
|
if (auth.user.status === 'approved') return
|
||||||
return { name: 'student-register' }
|
return { name: 'student-register' }
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ export const statusGuard = (to) => {
|
|||||||
export const roleGuard = (to) => {
|
export const roleGuard = (to) => {
|
||||||
if (!to.meta?.role) return
|
if (!to.meta?.role) return
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
if (auth.role !== to.meta.role) {
|
if (!auth.roles.includes(to.meta.role)) {
|
||||||
return { name: 'home' }
|
return { name: 'home' }
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -43,4 +43,8 @@ export const apiSaveRegisterData = (data) => http.post(endpoints.registerData, {
|
|||||||
export const apiGetRegistrationQuestionVideo = () =>
|
export const apiGetRegistrationQuestionVideo = () =>
|
||||||
http.get(endpoints.getRegistrationQuestionVideo)
|
http.get(endpoints.getRegistrationQuestionVideo)
|
||||||
|
|
||||||
export const apiUploadMedia = (formData) => http.post(endpoints.uploadMedia, formData)
|
// Media uploads (especially course videos) can legitimately take several
|
||||||
|
// minutes on slower connections. Keep the normal API timeout short, but give
|
||||||
|
// this endpoint enough time to complete the backend's 300 MB upload contract.
|
||||||
|
export const apiUploadMedia = (formData) =>
|
||||||
|
http.post(endpoints.uploadMedia, formData, { timeout: 10 * 60 * 1000 })
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const currentMe = {
|
|||||||
lastName: 'محمدی',
|
lastName: 'محمدی',
|
||||||
fullName: 'سجاد محمدی',
|
fullName: 'سجاد محمدی',
|
||||||
phoneNumber: '09123456789',
|
phoneNumber: '09123456789',
|
||||||
nationalCode: '0079827498',
|
nationalCode: '0079827497',
|
||||||
status: 'approved',
|
status: 'approved',
|
||||||
address: {
|
address: {
|
||||||
address: 'خیابان آزادی، پلاک ۱۲',
|
address: 'خیابان آزادی، پلاک ۱۲',
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { endpoints } from '@/services/api/endpoints'
|
|||||||
import { currentMe } from '@/services/mock/fixtures/me'
|
import { currentMe } from '@/services/mock/fixtures/me'
|
||||||
|
|
||||||
const fakeToken = 'mock-token-1234567890'
|
const fakeToken = 'mock-token-1234567890'
|
||||||
|
let registerData = {}
|
||||||
|
|
||||||
register('POST', endpoints.login, () => ({
|
register('POST', endpoints.login, () => ({
|
||||||
data: { user: currentMe, token: fakeToken },
|
data: { user: currentMe, token: fakeToken },
|
||||||
@@ -86,6 +87,13 @@ register('POST', endpoints.completeProfile, ({ data }) => ({
|
|||||||
data: { user: { ...currentMe, ...data } },
|
data: { user: { ...currentMe, ...data } },
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
register('GET', endpoints.registerData, () => ({ data: registerData }))
|
||||||
|
|
||||||
|
register('POST', endpoints.registerData, ({ data }) => {
|
||||||
|
registerData = { ...registerData, ...data?.data }
|
||||||
|
return { data: registerData }
|
||||||
|
})
|
||||||
|
|
||||||
register('GET', endpoints.getRegistrationQuestionVideo, () => ({
|
register('GET', endpoints.getRegistrationQuestionVideo, () => ({
|
||||||
data: { url: '', id: 0 },
|
data: { url: '', id: 0 },
|
||||||
}))
|
}))
|
||||||
|
|||||||
@@ -60,10 +60,21 @@ export const useCompleteProfileMutation = () => useMutation({ mutationFn: apiCom
|
|||||||
|
|
||||||
export const useUpdateProfileMutation = () => useMutation({ mutationFn: apiUpdateProfile })
|
export const useUpdateProfileMutation = () => useMutation({ mutationFn: apiUpdateProfile })
|
||||||
|
|
||||||
|
const getRegistrationVideoIfAvailable = async () => {
|
||||||
|
try {
|
||||||
|
return await apiGetRegistrationQuestionVideo()
|
||||||
|
} catch (error) {
|
||||||
|
// The migrated backend does not expose this optional content endpoint yet.
|
||||||
|
// Treat a missing route as "no tutorial uploaded" so registration remains usable.
|
||||||
|
if (error?.response?.status === 404) return {}
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const useGetRegistrationVideoQuery = (options = {}) =>
|
export const useGetRegistrationVideoQuery = (options = {}) =>
|
||||||
useQuery({
|
useQuery({
|
||||||
queryKey: authKeys.registrationVideo(),
|
queryKey: authKeys.registrationVideo(),
|
||||||
queryFn: () => apiGetRegistrationQuestionVideo(),
|
queryFn: getRegistrationVideoIfAvailable,
|
||||||
select: (response) => response?.data ?? response,
|
select: (response) => response?.data ?? response,
|
||||||
...options,
|
...options,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { ROLE_HOME_ROUTES } from '@/enums'
|
||||||
|
|
||||||
|
// Read by the WordPress site (madresebanoo.ir) to show/hide its "account"
|
||||||
|
// button and link it to the right dashboard, without ever seeing a real
|
||||||
|
// auth token. Must stay in sync with whatever the WP/Elementor side expects
|
||||||
|
// — see the implementation report for the exact contract.
|
||||||
|
const COOKIE_NAME = 'mb_auth_status'
|
||||||
|
const ROOT_DOMAIN = 'madresebanoo.ir'
|
||||||
|
|
||||||
|
const isOnRootDomain = () => {
|
||||||
|
const host = window.location.hostname
|
||||||
|
return host === ROOT_DOMAIN || host.endsWith(`.${ROOT_DOMAIN}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const cookieAttributes = () => {
|
||||||
|
const attrs = ['Path=/', 'SameSite=Lax']
|
||||||
|
// A Domain=.madresebanoo.ir cookie is only accepted by the browser when the
|
||||||
|
// current page is actually on that domain (prod). On local dev
|
||||||
|
// (127.0.0.1/localhost) we fall back to a host-only cookie so the sync
|
||||||
|
// logic is still exercised, instead of silently failing to set anything.
|
||||||
|
if (isOnRootDomain()) attrs.push(`Domain=.${ROOT_DOMAIN}`)
|
||||||
|
// Secure cookies are dropped by the browser on plain http, which local dev
|
||||||
|
// serves over. Only require it where it can actually work (prod, https).
|
||||||
|
if (window.location.protocol === 'https:') attrs.push('Secure')
|
||||||
|
return attrs
|
||||||
|
}
|
||||||
|
|
||||||
|
const writeCookie = (value, { expire = false } = {}) => {
|
||||||
|
const attrs = cookieAttributes()
|
||||||
|
attrs.push(expire ? 'Max-Age=0' : '') // no Max-Age on set = session cookie
|
||||||
|
// This cookie must be readable by a separate WordPress site with plain JS
|
||||||
|
// (no httpOnly), and needs Domain/SameSite attributes the CookieStore API
|
||||||
|
// doesn't uniformly support yet — document.cookie is the correct tool here.
|
||||||
|
// eslint-disable-next-line unicorn/no-document-cookie
|
||||||
|
document.cookie = [`${COOKIE_NAME}=${value}`, ...attrs].filter(Boolean).join('; ')
|
||||||
|
}
|
||||||
|
|
||||||
|
const dashboardPathFor = async (role) => {
|
||||||
|
try {
|
||||||
|
const { default: router } = await import('@/router')
|
||||||
|
const routeName = ROLE_HOME_ROUTES[role] || 'student-dashboard'
|
||||||
|
return router.resolve({ name: routeName }).path
|
||||||
|
} catch {
|
||||||
|
return '/dashboard'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets mb_auth_status to a non-sensitive JSON blob describing display state
|
||||||
|
* only: `{ loggedIn: true, dashboardPath }`. Never put the access token,
|
||||||
|
* password, or any credential in this cookie.
|
||||||
|
*/
|
||||||
|
export const syncAuthStatusCookie = async (role) => {
|
||||||
|
const dashboardPath = await dashboardPathFor(role)
|
||||||
|
const value = encodeURIComponent(JSON.stringify({ loggedIn: true, dashboardPath }))
|
||||||
|
writeCookie(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const clearAuthStatusCookie = () => {
|
||||||
|
writeCookie('', { expire: true })
|
||||||
|
}
|
||||||
+22
-4
@@ -2,31 +2,49 @@ import { computed, ref } from 'vue'
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
import { tokenService } from '@/services/api/token-service'
|
import { tokenService } from '@/services/api/token-service'
|
||||||
|
import { syncAuthStatusCookie, clearAuthStatusCookie } from '@/services/wp-sync/auth-status-cookie'
|
||||||
|
|
||||||
export const useAuthStore = defineStore('auth', () => {
|
export const useAuthStore = defineStore('auth', () => {
|
||||||
const user = ref(tokenService.getUserInfo())
|
const user = ref(tokenService.getUserInfo())
|
||||||
|
|
||||||
const isAuthenticated = computed(() => !!tokenService.getToken() && !!user.value)
|
const isAuthenticated = computed(() => !!tokenService.getToken() && !!user.value)
|
||||||
const role = computed(() => {
|
// Full set of roles this user holds — access should be additive across all
|
||||||
|
// of them, never just their first/"primary" one.
|
||||||
|
const roles = computed(() => {
|
||||||
const u = user.value
|
const u = user.value
|
||||||
if (!u) return null
|
if (!u) return []
|
||||||
if (Array.isArray(u.roles) && u.roles.length > 0) return u.roles[0]
|
if (Array.isArray(u.roles) && u.roles.length > 0) return u.roles
|
||||||
return u.role || u.roleName || null
|
if (u.role) return [u.role]
|
||||||
|
if (u.roleName) return [u.roleName]
|
||||||
|
return []
|
||||||
})
|
})
|
||||||
|
// Primary role, used only where a single default is needed (e.g. the
|
||||||
|
// landing route right after login) — never for access control.
|
||||||
|
const role = computed(() => roles.value[0] || null)
|
||||||
|
|
||||||
const setUser = (userData) => {
|
const setUser = (userData) => {
|
||||||
user.value = userData
|
user.value = userData
|
||||||
tokenService.saveUserInfo(userData)
|
tokenService.saveUserInfo(userData)
|
||||||
|
// Only a real, token-backed session should tell WordPress "logged in" —
|
||||||
|
// setUser is also used to stash a phone number mid-signup, before any
|
||||||
|
// token exists, so gate the display-state cookie on the actual token.
|
||||||
|
if (tokenService.hasToken()) {
|
||||||
|
syncAuthStatusCookie(role.value)
|
||||||
|
} else {
|
||||||
|
clearAuthStatusCookie()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearUser = () => {
|
const clearUser = () => {
|
||||||
user.value = null
|
user.value = null
|
||||||
tokenService.clearAll()
|
tokenService.clearAll()
|
||||||
|
clearAuthStatusCookie()
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
user,
|
user,
|
||||||
role,
|
role,
|
||||||
|
roles,
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
setUser,
|
setUser,
|
||||||
clearUser,
|
clearUser,
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ export function gregorianToJalaliString(isoString, separator = '/', persianDigit
|
|||||||
jd = jd.replace(/\d/g, (d) => enToFa[d])
|
jd = jd.replace(/\d/g, (d) => enToFa[d])
|
||||||
}
|
}
|
||||||
return `${jy}${separator}${jm}${separator}${jd}`
|
return `${jy}${separator}${jm}${separator}${jd}`
|
||||||
} catch (error) {
|
} catch {
|
||||||
console.error('Date conversion error:', error)
|
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,8 +82,7 @@ export function gregorianToJalaliStringLong(isoString, separator = '/', persianD
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ` ${jy}${separator}${jm}${separator}${jd}، ${hh}:${mm}`
|
return ` ${jy}${separator}${jm}${separator}${jd}، ${hh}:${mm}`
|
||||||
} catch (error) {
|
} catch {
|
||||||
console.error('Date conversion error:', error)
|
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,8 +96,7 @@ export function JalaliToGregorianString(jalaliStr) {
|
|||||||
2,
|
2,
|
||||||
'0'
|
'0'
|
||||||
)}T00:00:00.000Z`
|
)}T00:00:00.000Z`
|
||||||
} catch (error) {
|
} catch {
|
||||||
console.log('Jalali to Gregorian conversion error:', error)
|
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,8 +116,7 @@ export function JalaliToGregorianStringWithTime(jalaliDateTimeStr) {
|
|||||||
2,
|
2,
|
||||||
'0'
|
'0'
|
||||||
)}T${timePart}:00.000Z`
|
)}T${timePart}:00.000Z`
|
||||||
} catch (error) {
|
} catch {
|
||||||
console.log('Jalali to Gregorian with time conversion error:', error)
|
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,18 @@ export function handleApiError(error_) {
|
|||||||
const data = error_?.response?.data
|
const data = error_?.response?.data
|
||||||
const status = error_?.response?.status
|
const status = error_?.response?.status
|
||||||
|
|
||||||
|
if (error_?.code === 'ECONNABORTED') {
|
||||||
|
toast.error(
|
||||||
|
'زمان بارگذاری فایل به پایان رسید. لطفاً اتصال اینترنت را بررسی و دوباره تلاش کنید.'
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status === 413) {
|
||||||
|
toast.error('حجم فایل از حداکثر مجاز بیشتر است.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (status === 422 && data?.errors) {
|
if (status === 422 && data?.errors) {
|
||||||
Object.values(data.errors).forEach((messages) => {
|
Object.values(data.errors).forEach((messages) => {
|
||||||
const list = Array.isArray(messages) ? messages : [messages]
|
const list = Array.isArray(messages) ? messages : [messages]
|
||||||
|
|||||||
Reference in New Issue
Block a user