fix: user changes
This commit is contained in:
+24
-1
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<component :is="currentLayout" />
|
<component v-if="isReady" :is="currentLayout" />
|
||||||
<ConfirmModal />
|
<ConfirmModal />
|
||||||
<VueQueryDevtools />
|
<VueQueryDevtools />
|
||||||
</template>
|
</template>
|
||||||
@@ -9,6 +9,9 @@ import { storeToRefs } from 'pinia'
|
|||||||
import { computed, watch } from 'vue'
|
import { computed, watch } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { useModalStore } from '@/store/modal'
|
import { useModalStore } from '@/store/modal'
|
||||||
|
import { useAuthStore } from '@/store/auth'
|
||||||
|
import { useGetMeQuery } from '@/services/query/auth'
|
||||||
|
import { tokenService } from '@/services/api/token-service'
|
||||||
import AdminLayout from '@/layouts/AdminLayout.vue'
|
import AdminLayout from '@/layouts/AdminLayout.vue'
|
||||||
import PublicLayout from '@/layouts/PublicLayout.vue'
|
import PublicLayout from '@/layouts/PublicLayout.vue'
|
||||||
import StudentLayout from '@/layouts/StudentLayout.vue'
|
import StudentLayout from '@/layouts/StudentLayout.vue'
|
||||||
@@ -25,6 +28,26 @@ const layouts = {
|
|||||||
|
|
||||||
const currentLayout = computed(() => layouts[route.meta?.layout] || PublicLayout)
|
const currentLayout = computed(() => layouts[route.meta?.layout] || PublicLayout)
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
|
const hasToken = computed(() => tokenService.hasToken())
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: me,
|
||||||
|
isLoading: isMeLoading,
|
||||||
|
isFetched: isMeFetched,
|
||||||
|
} = useGetMeQuery({ enabled: hasToken })
|
||||||
|
|
||||||
|
watch(
|
||||||
|
me,
|
||||||
|
(value) => {
|
||||||
|
if (value) authStore.setUser(value)
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
const isReady = computed(() => !hasToken.value || isMeFetched.value || !isMeLoading.value)
|
||||||
|
|
||||||
const { modals } = storeToRefs(useModalStore())
|
const { modals } = storeToRefs(useModalStore())
|
||||||
watch(
|
watch(
|
||||||
() => modals.value.length,
|
() => modals.value.length,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
<div class="voice-recorder__actions">
|
<div class="voice-recorder__actions">
|
||||||
<button
|
<button
|
||||||
v-if="audioUrl && !isRecording"
|
v-if="audioUrl && !isRecording && !disabled"
|
||||||
type="button"
|
type="button"
|
||||||
class="voice-recorder__btn"
|
class="voice-recorder__btn"
|
||||||
:title="'ضبط مجدد'"
|
:title="'ضبط مجدد'"
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
export default function useYup(validationSchema) {
|
export default function useYup(validationSchema, getValues) {
|
||||||
const errors = ref({})
|
const errors = ref({})
|
||||||
|
|
||||||
|
const readFormValues = () => {
|
||||||
|
if (typeof getValues !== 'function') return {}
|
||||||
|
const v = getValues()
|
||||||
|
return v && typeof v === 'object' ? v : {}
|
||||||
|
}
|
||||||
|
|
||||||
const validate = async (values, options) => {
|
const validate = async (values, options) => {
|
||||||
const mergeOptions = { abortEarly: false, stripUnknown: true, ...options }
|
const mergeOptions = { abortEarly: false, stripUnknown: true, ...options }
|
||||||
try {
|
try {
|
||||||
@@ -30,7 +36,7 @@ export default function useYup(validationSchema) {
|
|||||||
const pathParts = field.split('.')
|
const pathParts = field.split('.')
|
||||||
const lastPart = pathParts.pop()
|
const lastPart = pathParts.pop()
|
||||||
let schemaContext = validationSchema
|
let schemaContext = validationSchema
|
||||||
let context = {}
|
let context = { ...readFormValues() }
|
||||||
if (pathParts.length > 0) {
|
if (pathParts.length > 0) {
|
||||||
pathParts.forEach((part) => {
|
pathParts.forEach((part) => {
|
||||||
if (part.includes('[')) {
|
if (part.includes('[')) {
|
||||||
@@ -47,7 +53,7 @@ export default function useYup(validationSchema) {
|
|||||||
await schemaContext.validateAt(lastPart, context)
|
await schemaContext.validateAt(lastPart, context)
|
||||||
errors.value[field] = null
|
errors.value[field] = null
|
||||||
} else {
|
} else {
|
||||||
await validationSchema.validateAt(field, { [field]: value })
|
await validationSchema.validateAt(field, { ...context, [field]: value })
|
||||||
errors.value[field] = null
|
errors.value[field] = null
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
+1
-3
@@ -175,10 +175,8 @@ export const TICKET_STATUS = Object.freeze({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const STUDENT_COURSE_STATUS = Object.freeze({
|
export const STUDENT_COURSE_STATUS = Object.freeze({
|
||||||
watching: 'در حال گذراندن',
|
active: 'در حال گذراندن',
|
||||||
waitForExam: 'در انتظار آزمون',
|
|
||||||
completed: 'تکمیل شده',
|
completed: 'تکمیل شده',
|
||||||
failed: 'عدم قبولی',
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const PRIORITY_STATUS = Object.freeze({
|
export const PRIORITY_STATUS = Object.freeze({
|
||||||
|
|||||||
@@ -1,305 +0,0 @@
|
|||||||
<template>
|
|
||||||
<BasicModal
|
|
||||||
title="افزودن دانشجو"
|
|
||||||
title-en="Add Student"
|
|
||||||
width="95%"
|
|
||||||
max-width="42rem"
|
|
||||||
min-width="auto"
|
|
||||||
:show-close-button="true"
|
|
||||||
>
|
|
||||||
<template #default="{ close }">
|
|
||||||
<div class="add-course-student">
|
|
||||||
<div class="add-course-student__search">
|
|
||||||
<SvgIcon name="user" :size="18" color="var(--color-thd-gray)" />
|
|
||||||
<input
|
|
||||||
v-model="searchInput"
|
|
||||||
type="text"
|
|
||||||
class="add-course-student__search-input"
|
|
||||||
placeholder="اسم دانشجو را وارد نمایید"
|
|
||||||
@input="onSearchInput"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<SkeletonLoaderBlock v-if="isLoading" :rows="4" :cols-per-row="1" />
|
|
||||||
|
|
||||||
<div v-else-if="users.length > 0" class="add-course-student__list">
|
|
||||||
<div v-for="user in users" :key="user.id" class="add-course-student__row">
|
|
||||||
<div class="add-course-student__main">
|
|
||||||
<div v-if="user.avatarUrl" class="add-course-student__avatar">
|
|
||||||
<img :src="user.avatarUrl" :alt="user?.name" />
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-else
|
|
||||||
class="add-course-student__avatar add-course-student__avatar--placeholder"
|
|
||||||
>
|
|
||||||
<SvgIcon name="user" :size="20" color="#bcbcbc" />
|
|
||||||
</div>
|
|
||||||
<div class="add-course-student__text">
|
|
||||||
<p class="add-course-student__name">{{ user?.name }}</p>
|
|
||||||
<p class="add-course-student__meta">
|
|
||||||
<span>{{ user.address?.province?.name || '—' }}</span>
|
|
||||||
<span class="add-course-student__sep">،</span>
|
|
||||||
<span>{{ user.address?.city?.name || '—' }}</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<CircleButton
|
|
||||||
v-if="isAttached(user.id)"
|
|
||||||
tooltip="حذف از دوره"
|
|
||||||
bg-color="rgba(104, 104, 104, 0.05)"
|
|
||||||
size="2.25rem"
|
|
||||||
type="button"
|
|
||||||
:loading="pendingId === user.id"
|
|
||||||
@click="onDetach(user)"
|
|
||||||
>
|
|
||||||
<template #icon>
|
|
||||||
<SvgIcon name="trash" :size="16" color="var(--color-error)" />
|
|
||||||
</template>
|
|
||||||
</CircleButton>
|
|
||||||
<CircleButton
|
|
||||||
v-else
|
|
||||||
tooltip="افزودن به دوره"
|
|
||||||
bg-color="rgba(104, 104, 104, 0.05)"
|
|
||||||
size="2.25rem"
|
|
||||||
type="button"
|
|
||||||
:loading="pendingId === user.id"
|
|
||||||
@click="onAttach(user)"
|
|
||||||
>
|
|
||||||
<template #icon>
|
|
||||||
<SvgIcon name="plus" :size="16" color="var(--color-sec-gray)" />
|
|
||||||
</template>
|
|
||||||
</CircleButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<NoItems v-else title="بدون نتیجه" desc="دانشجویی یافت نشد." />
|
|
||||||
|
|
||||||
<div class="add-course-student__divider" />
|
|
||||||
|
|
||||||
<div class="add-course-student__footer">
|
|
||||||
<BaseButton text="تایید" custom-class="add-course-student__close-btn" @click="close">
|
|
||||||
<template #appendIcon>
|
|
||||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
|
||||||
</template>
|
|
||||||
</BaseButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</BasicModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import useModal from '@/composables/useModal'
|
|
||||||
import useDebounce from '@/composables/useDebounce'
|
|
||||||
import { useQueryClient } from '@tanstack/vue-query'
|
|
||||||
import BasicModal from '@/components/BasicModal.vue'
|
|
||||||
import BaseButton from '@/components/BaseButton.vue'
|
|
||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
|
||||||
import NoItems from '@/components/blocks/NoItems.vue'
|
|
||||||
import CircleButton from '@/components/CircleButton.vue'
|
|
||||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
|
||||||
import { useAdminUsersListQuery } from '@/services/query/admin-users'
|
|
||||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
|
||||||
import {
|
|
||||||
adminCoursesKeys,
|
|
||||||
useAddAdminCourseStudentMutation,
|
|
||||||
useAdminCourseStudentsQuery,
|
|
||||||
useRemoveAdminCourseStudentMutation,
|
|
||||||
} from '@/services/query/admin-courses'
|
|
||||||
|
|
||||||
defineOptions({ name: 'AddCourseStudentModal' })
|
|
||||||
|
|
||||||
const queryClient = useQueryClient()
|
|
||||||
const { getModal } = useModal()
|
|
||||||
|
|
||||||
const modalData = computed(() => getModal('AddCourseStudentModal')?.data ?? {})
|
|
||||||
const courseId = computed(() => modalData.value.courseId ?? null)
|
|
||||||
|
|
||||||
const searchInput = ref('')
|
|
||||||
const searchQuery = ref('')
|
|
||||||
const userFilters = computed(() => ({ name: searchQuery.value }))
|
|
||||||
const userPagination = ref({ page: 1, perPage: 20 })
|
|
||||||
|
|
||||||
const { data: usersResponse, isLoading } = useAdminUsersListQuery(userFilters, userPagination)
|
|
||||||
const users = computed(() => usersResponse.value?.data ?? [])
|
|
||||||
|
|
||||||
const attachedFilters = computed(() => ({}))
|
|
||||||
const attachedPagination = ref({ page: 1, perPage: 200 })
|
|
||||||
const { data: attachedResponse } = useAdminCourseStudentsQuery(
|
|
||||||
courseId,
|
|
||||||
attachedFilters,
|
|
||||||
attachedPagination,
|
|
||||||
{ enabled: () => !!courseId.value }
|
|
||||||
)
|
|
||||||
const attachedIds = computed(() => new Set((attachedResponse.value?.data ?? []).map((u) => u.id)))
|
|
||||||
|
|
||||||
const isAttached = (id) => attachedIds.value.has(id)
|
|
||||||
|
|
||||||
const onSearchInput = useDebounce(() => {
|
|
||||||
searchQuery.value = searchInput.value || ''
|
|
||||||
userPagination.value = { ...userPagination.value, page: 1 }
|
|
||||||
}, 400)
|
|
||||||
|
|
||||||
const pendingId = ref(null)
|
|
||||||
|
|
||||||
const addMutation = useAddAdminCourseStudentMutation()
|
|
||||||
const removeMutation = useRemoveAdminCourseStudentMutation()
|
|
||||||
|
|
||||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminCoursesKeys.all })
|
|
||||||
|
|
||||||
const onAttach = async (user) => {
|
|
||||||
if (!courseId.value) return
|
|
||||||
pendingId.value = user.id
|
|
||||||
try {
|
|
||||||
await addMutation.mutateAsync({
|
|
||||||
courseId: courseId.value,
|
|
||||||
payload: { userIds: [user.id] },
|
|
||||||
})
|
|
||||||
invalidate()
|
|
||||||
} finally {
|
|
||||||
pendingId.value = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const onDetach = async (user) => {
|
|
||||||
if (!courseId.value) return
|
|
||||||
pendingId.value = user.id
|
|
||||||
try {
|
|
||||||
await removeMutation.mutateAsync({ courseId: courseId.value, userId: user.id })
|
|
||||||
invalidate()
|
|
||||||
} finally {
|
|
||||||
pendingId.value = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(courseId, () => {
|
|
||||||
searchInput.value = ''
|
|
||||||
searchQuery.value = ''
|
|
||||||
pendingId.value = null
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.add-course-student {
|
|
||||||
width: 100%;
|
|
||||||
text-align: start;
|
|
||||||
padding: 0.5rem 0.25rem;
|
|
||||||
|
|
||||||
&__search {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
margin-block: 1rem;
|
|
||||||
padding: 0 1rem;
|
|
||||||
height: 2.75rem;
|
|
||||||
border: 1px solid var(--color-thd-gray);
|
|
||||||
border-radius: 9999px;
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__search-input {
|
|
||||||
flex: 1;
|
|
||||||
border: none;
|
|
||||||
outline: none;
|
|
||||||
background: transparent;
|
|
||||||
font-family: var(--font-family-fa);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
color: #4b4b4b;
|
|
||||||
text-align: start;
|
|
||||||
|
|
||||||
&::placeholder {
|
|
||||||
color: var(--color-prim-gray);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__list {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.5rem;
|
|
||||||
max-height: 22rem;
|
|
||||||
overflow-y: auto;
|
|
||||||
padding-inline-end: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__row {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.625rem;
|
|
||||||
padding: 0.625rem 0.875rem;
|
|
||||||
background: rgba(255, 255, 255, 85%);
|
|
||||||
border-radius: 0.875rem;
|
|
||||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
|
||||||
}
|
|
||||||
|
|
||||||
&__main {
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.625rem;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__avatar {
|
|
||||||
width: 2.5rem;
|
|
||||||
height: 2.5rem;
|
|
||||||
border-radius: 9999px;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 1px solid #eee;
|
|
||||||
flex-shrink: 0;
|
|
||||||
|
|
||||||
img {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--placeholder {
|
|
||||||
background: #f5f5f5;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__text {
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__name {
|
|
||||||
font-family: var(--font-family-fa);
|
|
||||||
font-size: 0.95rem;
|
|
||||||
color: #4b4b4b;
|
|
||||||
margin: 0 0 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__meta {
|
|
||||||
font-family: var(--font-family-fa);
|
|
||||||
font-size: 0.75rem;
|
|
||||||
font-weight: 300;
|
|
||||||
color: #848484;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__sep {
|
|
||||||
color: #c4c4c4;
|
|
||||||
margin-inline: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__divider {
|
|
||||||
border-block-end: 1px solid var(--color-thd-gray);
|
|
||||||
margin-block: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__footer {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__close-btn {
|
|
||||||
min-width: 12rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<BasicModal width="95%" max-width="42rem" min-width="auto" :show-close-button="true">
|
<BasicModal
|
||||||
|
title="افزودن جلسه"
|
||||||
|
title-en="Add"
|
||||||
|
width="95%"
|
||||||
|
max-width="42rem"
|
||||||
|
min-width="auto"
|
||||||
|
:show-close-button="true"
|
||||||
|
>
|
||||||
<template #default="{ close }">
|
<template #default="{ close }">
|
||||||
<div class="add-session">
|
<div class="add-session">
|
||||||
<LineTitleBlock title="افزودن جلسه" title-en="Add" />
|
|
||||||
|
|
||||||
<div class="add-session__search">
|
<div class="add-session__search">
|
||||||
<SvgIcon name="book" :size="18" color="var(--color-thd-gray)" />
|
<SvgIcon name="book" :size="18" color="var(--color-thd-gray)" />
|
||||||
<input
|
<input
|
||||||
@@ -37,20 +42,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<CircleButton
|
<CircleButton
|
||||||
v-if="isAttached(session.id)"
|
|
||||||
tooltip="حذف از دوره"
|
|
||||||
bg-color="rgba(104, 104, 104, 0.05)"
|
|
||||||
size="2.25rem"
|
|
||||||
type="button"
|
|
||||||
:loading="pendingId === session.id"
|
|
||||||
@click="onDetach(session)"
|
|
||||||
>
|
|
||||||
<template #icon>
|
|
||||||
<SvgIcon name="trash" :size="16" color="var(--color-error)" />
|
|
||||||
</template>
|
|
||||||
</CircleButton>
|
|
||||||
<CircleButton
|
|
||||||
v-else
|
|
||||||
tooltip="افزودن به دوره"
|
tooltip="افزودن به دوره"
|
||||||
bg-color="rgba(104, 104, 104, 0.05)"
|
bg-color="rgba(104, 104, 104, 0.05)"
|
||||||
size="2.25rem"
|
size="2.25rem"
|
||||||
@@ -92,14 +83,13 @@ import SvgIcon from '@/components/icons/SvgIcon.vue'
|
|||||||
import NoItems from '@/components/blocks/NoItems.vue'
|
import NoItems from '@/components/blocks/NoItems.vue'
|
||||||
import CircleButton from '@/components/CircleButton.vue'
|
import CircleButton from '@/components/CircleButton.vue'
|
||||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||||
import { useAdminSessionsListQuery } from '@/services/query/admin-sessions'
|
import { adminCoursesKeys } from '@/services/query/admin-courses'
|
||||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||||
import {
|
import {
|
||||||
adminCoursesKeys,
|
adminSessionsKeys,
|
||||||
useAdminCourseSessionsQuery,
|
useAdminSessionsListQuery,
|
||||||
useAttachAdminCourseSessionMutation,
|
useUpdateAdminSessionMutation,
|
||||||
useDetachAdminCourseSessionMutation,
|
} from '@/services/query/admin-sessions'
|
||||||
} from '@/services/query/admin-courses'
|
|
||||||
|
|
||||||
defineOptions({ name: 'AddSessionToCourseModal' })
|
defineOptions({ name: 'AddSessionToCourseModal' })
|
||||||
|
|
||||||
@@ -111,8 +101,8 @@ const courseId = computed(() => modalData.value.courseId ?? null)
|
|||||||
|
|
||||||
const searchInput = ref('')
|
const searchInput = ref('')
|
||||||
const searchQuery = ref('')
|
const searchQuery = ref('')
|
||||||
const sessionFilters = computed(() => ({ title: searchQuery.value }))
|
const sessionFilters = computed(() => ({ search: searchQuery.value }))
|
||||||
const sessionPagination = ref({ page: 1, perPage: 20 })
|
const sessionPagination = ref({ page: 1, perPage: 10 })
|
||||||
|
|
||||||
const { data: sessionsResponse, isLoading } = useAdminSessionsListQuery(
|
const { data: sessionsResponse, isLoading } = useAdminSessionsListQuery(
|
||||||
sessionFilters,
|
sessionFilters,
|
||||||
@@ -120,18 +110,6 @@ const { data: sessionsResponse, isLoading } = useAdminSessionsListQuery(
|
|||||||
)
|
)
|
||||||
const sessions = computed(() => sessionsResponse.value?.data ?? [])
|
const sessions = computed(() => sessionsResponse.value?.data ?? [])
|
||||||
|
|
||||||
const attachedFilters = computed(() => ({}))
|
|
||||||
const attachedPagination = ref({ page: 1, perPage: 200 })
|
|
||||||
const { data: attachedResponse } = useAdminCourseSessionsQuery(
|
|
||||||
courseId,
|
|
||||||
attachedFilters,
|
|
||||||
attachedPagination,
|
|
||||||
{ enabled: () => !!courseId.value }
|
|
||||||
)
|
|
||||||
const attachedIds = computed(() => new Set((attachedResponse.value?.data ?? []).map((s) => s.id)))
|
|
||||||
|
|
||||||
const isAttached = (id) => attachedIds.value.has(id)
|
|
||||||
|
|
||||||
const teacherName = (session) => {
|
const teacherName = (session) => {
|
||||||
const t = session.teacher
|
const t = session.teacher
|
||||||
if (!t) return '—'
|
if (!t) return '—'
|
||||||
@@ -145,18 +123,20 @@ const onSearchInput = useDebounce(() => {
|
|||||||
|
|
||||||
const pendingId = ref(null)
|
const pendingId = ref(null)
|
||||||
|
|
||||||
const attachMutation = useAttachAdminCourseSessionMutation()
|
const updateSessionMutation = useUpdateAdminSessionMutation()
|
||||||
const detachMutation = useDetachAdminCourseSessionMutation()
|
|
||||||
|
|
||||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminCoursesKeys.all })
|
const invalidate = () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: adminCoursesKeys.all })
|
||||||
|
queryClient.invalidateQueries({ queryKey: adminSessionsKeys.all })
|
||||||
|
}
|
||||||
|
|
||||||
const onAttach = async (session) => {
|
const onAttach = async (session) => {
|
||||||
if (!courseId.value) return
|
if (!courseId.value) return
|
||||||
pendingId.value = session.id
|
pendingId.value = session.id
|
||||||
try {
|
try {
|
||||||
await attachMutation.mutateAsync({
|
await updateSessionMutation.mutateAsync({
|
||||||
courseId: courseId.value,
|
id: session.id,
|
||||||
payload: { sessionIds: [session.id] },
|
payload: { courseId: courseId.value },
|
||||||
})
|
})
|
||||||
invalidate()
|
invalidate()
|
||||||
} finally {
|
} finally {
|
||||||
@@ -164,17 +144,6 @@ const onAttach = async (session) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onDetach = async (session) => {
|
|
||||||
if (!courseId.value) return
|
|
||||||
pendingId.value = session.id
|
|
||||||
try {
|
|
||||||
await detachMutation.mutateAsync({ courseId: courseId.value, sessionId: session.id })
|
|
||||||
invalidate()
|
|
||||||
} finally {
|
|
||||||
pendingId.value = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(courseId, () => {
|
watch(courseId, () => {
|
||||||
searchInput.value = ''
|
searchInput.value = ''
|
||||||
searchQuery.value = ''
|
searchQuery.value = ''
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<BasicModal width="95%" max-width="80rem" min-width="auto" :show-close-button="true">
|
<BasicModal
|
||||||
|
title="جزئیات دوره"
|
||||||
|
title-en="details"
|
||||||
|
width="95%"
|
||||||
|
max-width="80rem"
|
||||||
|
min-width="auto"
|
||||||
|
:show-close-button="true"
|
||||||
|
>
|
||||||
<template #default="{ close }">
|
<template #default="{ close }">
|
||||||
<div class="course-details">
|
<div class="course-details">
|
||||||
<LineTitleBlock title="جزئیات دوره" title-en="details" />
|
|
||||||
|
|
||||||
<SkeletonLoaderBlock v-if="isLoading" :rows="3" :cols-per-row="1" />
|
<SkeletonLoaderBlock v-if="isLoading" :rows="3" :cols-per-row="1" />
|
||||||
|
|
||||||
<template v-else-if="course">
|
<template v-else-if="course">
|
||||||
@@ -14,14 +19,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="course-details__grid">
|
<div class="course-details__grid">
|
||||||
<LineInfoBlock title="عنوان دوره" :desc="course.title || '—'" />
|
<LineInfoBlock title="عنوان دوره" :desc="course.title || '—'" />
|
||||||
<LineInfoBlock
|
|
||||||
title="تاریخ شروع"
|
|
||||||
:numeric-desc="course.faStartDate || formatJalaaliDate(course.startDate) || '—'"
|
|
||||||
/>
|
|
||||||
<LineInfoBlock
|
|
||||||
title="تاریخ پایان"
|
|
||||||
:numeric-desc="course.faEndDate || formatJalaaliDate(course.endDate) || '—'"
|
|
||||||
/>
|
|
||||||
<LineInfoBlock title="تعداد جلسات" :numeric-desc="course.sessionsCount ?? 0" />
|
<LineInfoBlock title="تعداد جلسات" :numeric-desc="course.sessionsCount ?? 0" />
|
||||||
<LineInfoBlock title="پیشنیاز دوره" :desc="teacherName" />
|
<LineInfoBlock title="پیشنیاز دوره" :desc="teacherName" />
|
||||||
</div>
|
</div>
|
||||||
@@ -30,12 +27,8 @@
|
|||||||
<div v-if="course.description" class="course-details__description">
|
<div v-if="course.description" class="course-details__description">
|
||||||
<LineInfoBlock title="توضیحات دوره" :desc="course.description" />
|
<LineInfoBlock title="توضیحات دوره" :desc="course.description" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
|
||||||
|
|
||||||
<NoItems v-else title="یافت نشد" desc="اطلاعات این دوره در دسترس نیست." />
|
<section class="course-details__sessions">
|
||||||
|
|
||||||
<TabsBlock v-if="course" :tabs="tabs" v-model="activeTab">
|
|
||||||
<template #sessions>
|
|
||||||
<div class="course-details__panel-header">
|
<div class="course-details__panel-header">
|
||||||
<LineTitleBlock title="لیست جلسات" title-en="Sessions" />
|
<LineTitleBlock title="لیست جلسات" title-en="Sessions" />
|
||||||
<BaseButton
|
<BaseButton
|
||||||
@@ -60,70 +53,10 @@
|
|||||||
:pagination="sessionsPaginationMeta"
|
:pagination="sessionsPaginationMeta"
|
||||||
@update:page="setSessionsPage"
|
@update:page="setSessionsPage"
|
||||||
/>
|
/>
|
||||||
</template>
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #students>
|
<NoItems v-else title="یافت نشد" desc="اطلاعات این دوره در دسترس نیست." />
|
||||||
<div class="course-details__panel-header">
|
|
||||||
<LineTitleBlock title="دانشجویان" title-en="Students" />
|
|
||||||
<BaseButton
|
|
||||||
text="افزودن دانشجو به این دوره"
|
|
||||||
custom-class="course-details__panel-btn"
|
|
||||||
@click="onOpenAddStudent"
|
|
||||||
>
|
|
||||||
<template #appendIcon>
|
|
||||||
<SvgIcon name="arrow-left" :size="16" color="#fff" />
|
|
||||||
</template>
|
|
||||||
</BaseButton>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<SkeletonLoaderBlock v-if="studentsPending" :rows="4" :cols-per-row="1" />
|
|
||||||
<div v-else-if="students.length > 0">
|
|
||||||
<div
|
|
||||||
v-for="student in students"
|
|
||||||
:key="student.id"
|
|
||||||
class="course-details__student-row"
|
|
||||||
>
|
|
||||||
<div class="course-details__student-main">
|
|
||||||
<div v-if="studentAvatar(student)" class="course-details__avatar">
|
|
||||||
<img :src="studentAvatar(student)" :alt="student.name" />
|
|
||||||
</div>
|
|
||||||
<div v-else class="course-details__avatar course-details__avatar--placeholder">
|
|
||||||
<SvgIcon name="user" :size="20" color="#bcbcbc" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<p class="course-details__student-name">{{ student.name || '—' }}</p>
|
|
||||||
<p class="course-details__student-meta">
|
|
||||||
<span dir="ltr">{{ student.phone || '—' }}</span>
|
|
||||||
<template v-if="student.email">
|
|
||||||
<span class="course-details__sep">،</span>
|
|
||||||
<span dir="ltr">{{ student.email }}</span>
|
|
||||||
</template>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="student.phone" class="course-details__student-actions">
|
|
||||||
<CircleButton
|
|
||||||
tooltip="ارسال پیام"
|
|
||||||
bg-color="rgba(104, 104, 104, 0.05)"
|
|
||||||
size="2.25rem"
|
|
||||||
@click="onMessageStudent(student)"
|
|
||||||
>
|
|
||||||
<template #icon>
|
|
||||||
<SvgIcon name="chat" :size="16" color="var(--color-sec-gray)" />
|
|
||||||
</template>
|
|
||||||
</CircleButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<NoItems v-else title="بدون دانشجو" desc="دانشجویی به این دوره اضافه نشده است." />
|
|
||||||
|
|
||||||
<PaginationBlock
|
|
||||||
v-if="studentsPaginationMeta.lastPage > 1"
|
|
||||||
:pagination="studentsPaginationMeta"
|
|
||||||
@update:page="setStudentsPage"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</TabsBlock>
|
|
||||||
|
|
||||||
<div class="course-details__divider" />
|
<div class="course-details__divider" />
|
||||||
|
|
||||||
@@ -140,26 +73,20 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed } from 'vue'
|
||||||
import useModal from '@/composables/useModal'
|
import useModal from '@/composables/useModal'
|
||||||
import BasicModal from '@/components/BasicModal.vue'
|
import BasicModal from '@/components/BasicModal.vue'
|
||||||
import BaseButton from '@/components/BaseButton.vue'
|
import BaseButton from '@/components/BaseButton.vue'
|
||||||
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 CircleButton from '@/components/CircleButton.vue'
|
|
||||||
import TabsBlock from '@/components/blocks/TabsBlock.vue'
|
|
||||||
import { usePagination } from '@/composables/usePagination'
|
import { usePagination } from '@/composables/usePagination'
|
||||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||||
|
import { useAdminCourseQuery } from '@/services/query/admin-courses'
|
||||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||||
|
import { useAdminSessionsListQuery } from '@/services/query/admin-sessions'
|
||||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||||
import CourseSessionItem from '@/features/admin/courses/components/CourseSessionItem.vue'
|
import CourseSessionItem from '@/features/admin/courses/components/CourseSessionItem.vue'
|
||||||
import {
|
|
||||||
useAdminCourseQuery,
|
|
||||||
useAdminCourseSessionsQuery,
|
|
||||||
useCourseAttendeesQuery,
|
|
||||||
} from '@/services/query/admin-courses'
|
|
||||||
|
|
||||||
defineOptions({ name: 'CourseDetailsModal' })
|
defineOptions({ name: 'CourseDetailsModal' })
|
||||||
|
|
||||||
@@ -178,24 +105,17 @@ const teacherName = computed(() => {
|
|||||||
return `${t.firstName || ''} ${t.lastName || ''}`.trim() || t.fullName || '—'
|
return `${t.firstName || ''} ${t.lastName || ''}`.trim() || t.fullName || '—'
|
||||||
})
|
})
|
||||||
|
|
||||||
const tabs = [
|
const sessionsFilters = computed(() => ({ courseId: courseId.value }))
|
||||||
{ name: 'sessions', label: 'لیست جلسات', icon: 'list-bullets' },
|
|
||||||
{ name: 'students', label: 'دانشجویان', icon: 'users' },
|
|
||||||
]
|
|
||||||
const activeTab = ref('sessions')
|
|
||||||
|
|
||||||
const sessionsFilters = ref({})
|
|
||||||
const { pagination: sessionsPagination, setPage: setSessionsPage } = usePagination({
|
const { pagination: sessionsPagination, setPage: setSessionsPage } = usePagination({
|
||||||
page: 1,
|
page: 1,
|
||||||
perPage: 10,
|
perPage: 10,
|
||||||
})
|
})
|
||||||
|
|
||||||
const { data: sessionsData, isLoading: sessionsPending } = useAdminCourseSessionsQuery(
|
const { data: sessionsData, isLoading: sessionsPending } = useAdminSessionsListQuery(
|
||||||
courseId,
|
|
||||||
sessionsFilters,
|
sessionsFilters,
|
||||||
sessionsPagination,
|
sessionsPagination,
|
||||||
{
|
{
|
||||||
enabled: () => !!courseId.value && activeTab.value === 'sessions',
|
enabled: () => !!courseId.value,
|
||||||
keepPreviousData: true,
|
keepPreviousData: true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -207,43 +127,9 @@ const sessionsPaginationMeta = computed(() => ({
|
|||||||
...sessionsData.value?.meta,
|
...sessionsData.value?.meta,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const studentsFilters = ref({})
|
|
||||||
const { pagination: studentsPagination, setPage: setStudentsPage } = usePagination({
|
|
||||||
page: 1,
|
|
||||||
perPage: 10,
|
|
||||||
})
|
|
||||||
|
|
||||||
const { data: studentsData, isLoading: studentsPending } = useCourseAttendeesQuery(
|
|
||||||
courseId,
|
|
||||||
studentsFilters,
|
|
||||||
studentsPagination,
|
|
||||||
{
|
|
||||||
enabled: () => !!courseId.value && activeTab.value === 'students',
|
|
||||||
keepPreviousData: true,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const students = computed(() => studentsData.value?.data ?? [])
|
|
||||||
const studentsPaginationMeta = computed(() => ({
|
|
||||||
page: studentsPagination.value.page,
|
|
||||||
perPage: studentsPagination.value.perPage,
|
|
||||||
...studentsData.value?.meta,
|
|
||||||
}))
|
|
||||||
|
|
||||||
const studentAvatar = (student) => student.avatarUrl || student.avatarDownloadUrl || ''
|
|
||||||
|
|
||||||
const onOpenAddSession = () => {
|
const onOpenAddSession = () => {
|
||||||
openModal('AddSessionToCourseModal', { courseId: courseId.value })
|
openModal('AddSessionToCourseModal', { courseId: courseId.value })
|
||||||
}
|
}
|
||||||
|
|
||||||
const onOpenAddStudent = () => {
|
|
||||||
openModal('AddCourseStudentModal', { courseId: courseId.value })
|
|
||||||
}
|
|
||||||
|
|
||||||
const onMessageStudent = (student) => {
|
|
||||||
if (!student?.phone) return
|
|
||||||
window.location.href = `sms:${student.phone}`
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@@ -299,6 +185,10 @@ const onMessageStudent = (student) => {
|
|||||||
margin-block: 0.5rem 1rem;
|
margin-block: 0.5rem 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__sessions {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
&__panel-header {
|
&__panel-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -312,74 +202,6 @@ const onMessageStudent = (student) => {
|
|||||||
margin-inline-start: auto;
|
margin-inline-start: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__student-row {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.75rem;
|
|
||||||
padding: 0.625rem 0.875rem;
|
|
||||||
background: rgba(255, 255, 255, 85%);
|
|
||||||
border-radius: 0.875rem;
|
|
||||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__student-main {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.625rem;
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__avatar {
|
|
||||||
width: 2.5rem;
|
|
||||||
height: 2.5rem;
|
|
||||||
border-radius: 9999px;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 1px solid #eee;
|
|
||||||
flex-shrink: 0;
|
|
||||||
|
|
||||||
img {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--placeholder {
|
|
||||||
background: #f5f5f5;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__student-name {
|
|
||||||
font-family: var(--font-family-fa);
|
|
||||||
font-size: 0.95rem;
|
|
||||||
color: #4b4b4b;
|
|
||||||
margin: 0 0 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__student-meta {
|
|
||||||
font-family: var(--font-family-fa);
|
|
||||||
font-size: 0.75rem;
|
|
||||||
font-weight: 300;
|
|
||||||
color: #848484;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__sep {
|
|
||||||
color: #c4c4c4;
|
|
||||||
margin-inline: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__student-actions {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.375rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__divider {
|
&__divider {
|
||||||
border-block-end: 1px solid var(--color-thd-gray);
|
border-block-end: 1px solid var(--color-thd-gray);
|
||||||
margin-block: 1.5rem;
|
margin-block: 1.5rem;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="course-form__main-col">
|
<div class="course-form__main-col">
|
||||||
<LineTitleBlock title="اطلاعات دوره" title-en="Course Details" />
|
|
||||||
<div class="course-form__row">
|
<div class="course-form__row">
|
||||||
<div class="course-form__cell course-form__cell--third">
|
<div class="course-form__cell course-form__cell--third">
|
||||||
<TextField
|
<TextField
|
||||||
@@ -64,17 +63,6 @@
|
|||||||
@blur="validateAt('capacity', form.capacity)"
|
@blur="validateAt('capacity', form.capacity)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="course-form__cell course-form__cell--third">
|
|
||||||
<TextField
|
|
||||||
v-model="form.sessionsCount"
|
|
||||||
name="sessionsCount"
|
|
||||||
label="تعداد جلسه"
|
|
||||||
inputmode="numeric"
|
|
||||||
:convert-digits="true"
|
|
||||||
:error="errors.sessionsCount"
|
|
||||||
@blur="validateAt('sessionsCount', form.sessionsCount)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="course-form__cell course-form__cell--third">
|
<div class="course-form__cell course-form__cell--third">
|
||||||
<SelectField
|
<SelectField
|
||||||
v-model="form.prerequisites"
|
v-model="form.prerequisites"
|
||||||
@@ -152,7 +140,6 @@ import BaseButton from '@/components/BaseButton.vue'
|
|||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
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 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 { useUploadMediaMutation } from '@/services/query/auth'
|
import { useUploadMediaMutation } from '@/services/query/auth'
|
||||||
@@ -180,7 +167,6 @@ const form = ref({
|
|||||||
title: '',
|
title: '',
|
||||||
teacherId: '',
|
teacherId: '',
|
||||||
capacity: '',
|
capacity: '',
|
||||||
sessionsCount: '',
|
|
||||||
prerequisites: [],
|
prerequisites: [],
|
||||||
contentType: '',
|
contentType: '',
|
||||||
description: '',
|
description: '',
|
||||||
@@ -198,7 +184,10 @@ const contentTypeOptions = Object.entries(COURSE_CONTENT_TYPE).map(([value, labe
|
|||||||
const { validate, validateAt, errors } = useYup(courseSchema)
|
const { validate, validateAt, errors } = useYup(courseSchema)
|
||||||
|
|
||||||
const teacherSearch = ref('')
|
const teacherSearch = ref('')
|
||||||
const teacherFilters = computed(() => ({ name: teacherSearch.value }))
|
const teacherFilters = computed(() => ({
|
||||||
|
search: teacherSearch.value,
|
||||||
|
roles: 'teacher',
|
||||||
|
}))
|
||||||
const teacherPagination = ref({ page: 1, perPage: 10 })
|
const teacherPagination = ref({ page: 1, perPage: 10 })
|
||||||
const { data: teachersResponse } = useAdminUsersListQuery(teacherFilters, teacherPagination)
|
const { data: teachersResponse } = useAdminUsersListQuery(teacherFilters, teacherPagination)
|
||||||
const selectedTeacher = ref(null)
|
const selectedTeacher = ref(null)
|
||||||
@@ -247,7 +236,6 @@ watch(existingCourse, (course) => {
|
|||||||
title: course.title || '',
|
title: course.title || '',
|
||||||
teacherId: teacher?.id || course.teacherId || '',
|
teacherId: teacher?.id || course.teacherId || '',
|
||||||
capacity: course.capacity ?? '',
|
capacity: course.capacity ?? '',
|
||||||
sessionsCount: course.sessionsCount ?? '',
|
|
||||||
prerequisites: prereqs.map((p) => p.courseId ?? p.id).filter(Boolean),
|
prerequisites: prereqs.map((p) => p.courseId ?? p.id).filter(Boolean),
|
||||||
contentType: course.contentType || '',
|
contentType: course.contentType || '',
|
||||||
description: course.description || '',
|
description: course.description || '',
|
||||||
|
|||||||
@@ -62,7 +62,6 @@
|
|||||||
|
|
||||||
<AddOfferedCourseModal v-if="isModal('AddOfferedCourseModal')" />
|
<AddOfferedCourseModal v-if="isModal('AddOfferedCourseModal')" />
|
||||||
<CourseDetailsModal v-if="isModal('CourseDetailsModal')" />
|
<CourseDetailsModal v-if="isModal('CourseDetailsModal')" />
|
||||||
<AddCourseStudentModal v-if="isModal('AddCourseStudentModal')" />
|
|
||||||
<AddSessionToCourseModal v-if="isModal('AddSessionToCourseModal')" />
|
<AddSessionToCourseModal v-if="isModal('AddSessionToCourseModal')" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -83,7 +82,6 @@ import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
|||||||
import CoursesFilters from '@/features/admin/courses/components/CoursesFilters.vue'
|
import CoursesFilters from '@/features/admin/courses/components/CoursesFilters.vue'
|
||||||
import CourseDetailsModal from '@/features/admin/courses/components/modals/CourseDetailsModal.vue'
|
import CourseDetailsModal from '@/features/admin/courses/components/modals/CourseDetailsModal.vue'
|
||||||
import AddOfferedCourseModal from '@/features/admin/courses/components/modals/AddOfferedCourseModal.vue'
|
import AddOfferedCourseModal from '@/features/admin/courses/components/modals/AddOfferedCourseModal.vue'
|
||||||
import AddCourseStudentModal from '@/features/admin/courses/components/modals/AddCourseStudentModal.vue'
|
|
||||||
import AddSessionToCourseModal from '@/features/admin/courses/components/modals/AddSessionToCourseModal.vue'
|
import AddSessionToCourseModal from '@/features/admin/courses/components/modals/AddSessionToCourseModal.vue'
|
||||||
import {
|
import {
|
||||||
adminCoursesKeys,
|
adminCoursesKeys,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ export const courseSchema = object().shape({
|
|||||||
title: string().required().min(3).max(255),
|
title: string().required().min(3).max(255),
|
||||||
teacherId: mixed().required(),
|
teacherId: mixed().required(),
|
||||||
capacity: number().required().min(1),
|
capacity: number().required().min(1),
|
||||||
sessionsCount: number().required().min(1),
|
|
||||||
prerequisites: array().nullable().default([]),
|
prerequisites: array().nullable().default([]),
|
||||||
contentType: string().oneOf(['video', 'voice', 'text']).required(),
|
contentType: string().oneOf(['video', 'voice', 'text']).required(),
|
||||||
contentMediaId: number().nullable().notRequired(),
|
contentMediaId: number().nullable().notRequired(),
|
||||||
|
|||||||
@@ -17,15 +17,11 @@
|
|||||||
title="تاریخ شروع"
|
title="تاریخ شروع"
|
||||||
:numeric-desc="formatJalaaliDate(session.startsAt) || '—'"
|
:numeric-desc="formatJalaaliDate(session.startsAt) || '—'"
|
||||||
/>
|
/>
|
||||||
<LineInfoBlock
|
|
||||||
title="تاریخ پایان"
|
|
||||||
:numeric-desc="formatJalaaliDate(session.endsAt) || '—'"
|
|
||||||
/>
|
|
||||||
<LineInfoBlock title="مدت زمان جلسه" :numeric-desc="durationLabel" />
|
<LineInfoBlock title="مدت زمان جلسه" :numeric-desc="durationLabel" />
|
||||||
|
|
||||||
<LineInfoBlock title="نوع جلسه" :desc="sessionTypeLabel" />
|
<LineInfoBlock title="نوع جلسه" :desc="sessionTypeLabel" />
|
||||||
<LineInfoBlock title="دوره مرتبط" :desc="courseTitle" />
|
<LineInfoBlock title="دوره مرتبط" :desc="courseTitle" />
|
||||||
<LineInfoBlock title="متعلق به" :desc="termTitle" />
|
|
||||||
<LineInfoBlock title="محتوای جلسه" :desc="contentTypeLabel" />
|
<LineInfoBlock title="محتوای جلسه" :desc="contentTypeLabel" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -37,14 +33,14 @@
|
|||||||
<LineInfoBlock title="لینک جلسه" :desc="session.link" />
|
<LineInfoBlock title="لینک جلسه" :desc="session.link" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="mediaUrl || session.contentType" class="session-details__media">
|
<div v-if="mediaUrl || contentType" class="session-details__media">
|
||||||
<VideoPlayerBlock
|
<VideoPlayerBlock
|
||||||
v-if="session.contentType === 'video'"
|
v-if="contentType === 'video'"
|
||||||
:src="mediaUrl"
|
:src="mediaUrl"
|
||||||
:video-id="session.id"
|
:video-id="session.id"
|
||||||
/>
|
/>
|
||||||
<VoiceRecorder
|
<VoiceRecorder
|
||||||
v-else-if="session.contentType === 'voice'"
|
v-else-if="contentType === 'voice'"
|
||||||
:model-value="mediaUrl"
|
:model-value="mediaUrl"
|
||||||
:disabled="true"
|
:disabled="true"
|
||||||
/>
|
/>
|
||||||
@@ -112,21 +108,28 @@ const durationLabel = computed(() =>
|
|||||||
|
|
||||||
const courseTitle = computed(() => session.value?.course?.title || '—')
|
const courseTitle = computed(() => session.value?.course?.title || '—')
|
||||||
|
|
||||||
const termTitle = computed(
|
|
||||||
() => session.value?.course?.term?.title || session.value?.term?.title || '—'
|
|
||||||
)
|
|
||||||
|
|
||||||
const contentTypeLabel = computed(() => COURSE_CONTENT_TYPE[session.value?.contentType] || '—')
|
|
||||||
|
|
||||||
const isOnline = computed(() => session.value?.type === 'online')
|
const isOnline = computed(() => session.value?.type === 'online')
|
||||||
|
|
||||||
|
const collectionToContentType = (collectionName) => {
|
||||||
|
if (collectionName === 'videos') return 'video'
|
||||||
|
if (collectionName === 'voices') return 'voice'
|
||||||
|
if (collectionName === 'pdfs') return 'text'
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const media = computed(() => (Array.isArray(session.value?.media) ? session.value.media : []))
|
||||||
|
|
||||||
|
const contentMedia = computed(() => media.value.find((m) => m.collectionName !== 'cover'))
|
||||||
|
|
||||||
|
const contentType = computed(() => collectionToContentType(contentMedia.value?.collectionName))
|
||||||
|
|
||||||
|
const contentTypeLabel = computed(() => COURSE_CONTENT_TYPE[contentType.value] || '—')
|
||||||
|
|
||||||
const mediaUrl = computed(
|
const mediaUrl = computed(
|
||||||
() => session.value?.contentMedia?.url || session.value?.contentMedia?.downloadUrl || ''
|
() => contentMedia.value?.url || contentMedia.value?.downloadUrl || ''
|
||||||
)
|
)
|
||||||
|
|
||||||
const mediaFileName = computed(
|
const mediaFileName = computed(() => contentMedia.value?.fileName || 'فایل پیوست')
|
||||||
() => session.value?.contentMedia?.fileName || session.value?.contentMedia?.name || 'فایل پیوست'
|
|
||||||
)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ const emit = defineEmits(['delete'])
|
|||||||
const teacherName = computed(() => {
|
const teacherName = computed(() => {
|
||||||
const t = props.course.teacher
|
const t = props.course.teacher
|
||||||
if (!t) return '—'
|
if (!t) return '—'
|
||||||
return `${t.firstName || ''} ${t.lastName || ''}`.trim() || t.fullName || '—'
|
return t.name
|
||||||
})
|
})
|
||||||
|
|
||||||
const isActive = computed(() => props.course.isActive ?? false)
|
const isActive = computed(() => props.course.isActive ?? false)
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<BasicModal width="95%" max-width="42rem" min-width="auto" :show-close-button="true">
|
<BasicModal
|
||||||
|
title="افزودن دانشجو"
|
||||||
|
title-en="Add Student"
|
||||||
|
width="95%"
|
||||||
|
max-width="42rem"
|
||||||
|
min-width="auto"
|
||||||
|
:show-close-button="true"
|
||||||
|
>
|
||||||
<template #default="{ close }">
|
<template #default="{ close }">
|
||||||
<div class="add-term-student">
|
<div class="add-term-student">
|
||||||
<LineTitleBlock title="افزودن دانشجو" title-en="Add Student" />
|
|
||||||
|
|
||||||
<div class="add-term-student__search">
|
<div class="add-term-student__search">
|
||||||
<SvgIcon name="user" :size="18" color="var(--color-thd-gray)" />
|
<SvgIcon name="user" :size="18" color="var(--color-thd-gray)" />
|
||||||
<input
|
<input
|
||||||
@@ -37,20 +42,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<CircleButton
|
<CircleButton
|
||||||
v-if="isAttached(user.id)"
|
|
||||||
tooltip="حذف از ترم"
|
|
||||||
bg-color="rgba(104, 104, 104, 0.05)"
|
|
||||||
size="2.25rem"
|
|
||||||
type="button"
|
|
||||||
:loading="pendingId === user.id"
|
|
||||||
@click="onDetach(user)"
|
|
||||||
>
|
|
||||||
<template #icon>
|
|
||||||
<SvgIcon name="trash" :size="16" color="var(--color-error)" />
|
|
||||||
</template>
|
|
||||||
</CircleButton>
|
|
||||||
<CircleButton
|
|
||||||
v-else
|
|
||||||
tooltip="افزودن به ترم"
|
tooltip="افزودن به ترم"
|
||||||
bg-color="rgba(104, 104, 104, 0.05)"
|
bg-color="rgba(104, 104, 104, 0.05)"
|
||||||
size="2.25rem"
|
size="2.25rem"
|
||||||
@@ -91,15 +82,9 @@ import BaseButton from '@/components/BaseButton.vue'
|
|||||||
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 CircleButton from '@/components/CircleButton.vue'
|
import CircleButton from '@/components/CircleButton.vue'
|
||||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
|
||||||
import { useAdminUsersListQuery } from '@/services/query/admin-users'
|
import { useAdminUsersListQuery } from '@/services/query/admin-users'
|
||||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||||
import {
|
import { adminTermsKeys, useAddAdminTermStudentsMutation } from '@/services/query/admin-terms'
|
||||||
adminTermsKeys,
|
|
||||||
useAddAdminTermStudentsMutation,
|
|
||||||
useAdminTermStudentsQuery,
|
|
||||||
useRemoveAdminTermStudentMutation,
|
|
||||||
} from '@/services/query/admin-terms'
|
|
||||||
|
|
||||||
defineOptions({ name: 'AddTermStudentModal' })
|
defineOptions({ name: 'AddTermStudentModal' })
|
||||||
|
|
||||||
@@ -111,29 +96,13 @@ const termId = computed(() => modalData.value.termId ?? null)
|
|||||||
|
|
||||||
const searchInput = ref('')
|
const searchInput = ref('')
|
||||||
const searchQuery = ref('')
|
const searchQuery = ref('')
|
||||||
const userFilters = computed(() => ({ name: searchQuery.value }))
|
const userFilters = computed(() => ({ search: searchQuery.value }))
|
||||||
const userPagination = ref({ page: 1, perPage: 20 })
|
const userPagination = ref({ page: 1, perPage: 10 })
|
||||||
|
|
||||||
const { data: usersResponse, isLoading } = useAdminUsersListQuery(userFilters, userPagination)
|
const { data: usersResponse, isLoading } = useAdminUsersListQuery(userFilters, userPagination)
|
||||||
const users = computed(() => usersResponse.value?.data ?? [])
|
const users = computed(() => usersResponse.value?.data ?? [])
|
||||||
|
|
||||||
const attachedFilters = computed(() => ({}))
|
const userLabel = (user) => user.name.trim() || '—'
|
||||||
const attachedPagination = ref({ page: 1, perPage: 200 })
|
|
||||||
const { data: attachedResponse } = useAdminTermStudentsQuery(
|
|
||||||
termId,
|
|
||||||
attachedFilters,
|
|
||||||
attachedPagination,
|
|
||||||
{ enabled: () => !!termId.value }
|
|
||||||
)
|
|
||||||
const attachedIds = computed(() => new Set((attachedResponse.value?.data ?? []).map((u) => u.id)))
|
|
||||||
|
|
||||||
const isAttached = (id) => attachedIds.value.has(id)
|
|
||||||
|
|
||||||
const userLabel = (user) =>
|
|
||||||
`${user.firstName || ''} ${user.lastName || ''}`.trim() ||
|
|
||||||
user.fullName ||
|
|
||||||
user.phoneNumber ||
|
|
||||||
'—'
|
|
||||||
|
|
||||||
const onSearchInput = useDebounce(() => {
|
const onSearchInput = useDebounce(() => {
|
||||||
searchQuery.value = searchInput.value || ''
|
searchQuery.value = searchInput.value || ''
|
||||||
@@ -143,7 +112,6 @@ const onSearchInput = useDebounce(() => {
|
|||||||
const pendingId = ref(null)
|
const pendingId = ref(null)
|
||||||
|
|
||||||
const addMutation = useAddAdminTermStudentsMutation()
|
const addMutation = useAddAdminTermStudentsMutation()
|
||||||
const removeMutation = useRemoveAdminTermStudentMutation()
|
|
||||||
|
|
||||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminTermsKeys.all })
|
const invalidate = () => queryClient.invalidateQueries({ queryKey: adminTermsKeys.all })
|
||||||
|
|
||||||
@@ -153,7 +121,7 @@ const onAttach = async (user) => {
|
|||||||
try {
|
try {
|
||||||
await addMutation.mutateAsync({
|
await addMutation.mutateAsync({
|
||||||
termId: termId.value,
|
termId: termId.value,
|
||||||
payload: { userIds: [user.id] },
|
payload: { userId: user.id },
|
||||||
})
|
})
|
||||||
invalidate()
|
invalidate()
|
||||||
} finally {
|
} finally {
|
||||||
@@ -161,17 +129,6 @@ const onAttach = async (user) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onDetach = async (user) => {
|
|
||||||
if (!termId.value) return
|
|
||||||
pendingId.value = user.id
|
|
||||||
try {
|
|
||||||
await removeMutation.mutateAsync({ termId: termId.value, userId: user.id })
|
|
||||||
invalidate()
|
|
||||||
} finally {
|
|
||||||
pendingId.value = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(termId, () => {
|
watch(termId, () => {
|
||||||
searchInput.value = ''
|
searchInput.value = ''
|
||||||
searchQuery.value = ''
|
searchQuery.value = ''
|
||||||
@@ -293,7 +250,7 @@ watch(termId, () => {
|
|||||||
|
|
||||||
&__footer {
|
&__footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-start;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__close-btn {
|
&__close-btn {
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<BasicModal width="95%" max-width="80rem" min-width="auto" :show-close-button="true">
|
<BasicModal
|
||||||
<template #default="{ data, close }">
|
title="جزئیات ترم"
|
||||||
|
title-en="Term Details"
|
||||||
|
width="95%"
|
||||||
|
max-width="80rem"
|
||||||
|
min-width="auto"
|
||||||
|
:show-close-button="true"
|
||||||
|
>
|
||||||
|
<template #default="{ close }">
|
||||||
<div v-if="!term" class="term-details">
|
<div v-if="!term" class="term-details">
|
||||||
<p class="term-details__loading">در حال بارگذاری…</p>
|
<p class="term-details__loading">در حال بارگذاری…</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="term-details">
|
<div v-else class="term-details">
|
||||||
<section class="term-details__section">
|
<section class="term-details__section">
|
||||||
<LineTitleBlock title="جزئیات ترم" title-en="Term Details" />
|
|
||||||
<div class="term-details__overview">
|
<div class="term-details__overview">
|
||||||
<div class="term-details__image">
|
<div class="term-details__image">
|
||||||
<img v-if="term.image" :src="term.image" :alt="term.title" />
|
<img v-if="term.coverUrl" :src="term.coverUrl" :alt="term.title" />
|
||||||
<SvgIcon v-else name="book" :size="32" color="#bcbcbc" />
|
<SvgIcon v-else name="book" :size="32" color="#bcbcbc" />
|
||||||
</div>
|
</div>
|
||||||
<div class="term-details__overview-grid">
|
<div class="term-details__overview-grid">
|
||||||
@@ -51,19 +57,19 @@
|
|||||||
<div v-else-if="students.length > 0">
|
<div v-else-if="students.length > 0">
|
||||||
<div v-for="student in students" :key="student.id" class="term-details__student-row">
|
<div v-for="student in students" :key="student.id" class="term-details__student-row">
|
||||||
<div class="term-details__student-main">
|
<div class="term-details__student-main">
|
||||||
<div v-if="studentAvatar(student)" class="term-details__avatar">
|
<div v-if="studentAvatar(student?.user)" class="term-details__avatar">
|
||||||
<img :src="studentAvatar(student)" :alt="student.name" />
|
<img :src="studentAvatar(student?.user)" :alt="student.name" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="term-details__avatar term-details__avatar--placeholder">
|
<div v-else class="term-details__avatar term-details__avatar--placeholder">
|
||||||
<SvgIcon name="user" :size="20" color="#bcbcbc" />
|
<SvgIcon name="user" :size="20" color="#bcbcbc" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p class="term-details__student-name">{{ student.name || '—' }}</p>
|
<p class="term-details__student-name">{{ student?.user?.name || '—' }}</p>
|
||||||
<p class="term-details__student-meta">
|
<p class="term-details__student-meta">
|
||||||
<span dir="ltr">{{ student.phone || '—' }}</span>
|
<span dir="ltr">{{ student?.user.phone || '—' }}</span>
|
||||||
<template v-if="student.email">
|
<template v-if="student?.user.email">
|
||||||
<span class="term-details__sep">،</span>
|
<span class="term-details__sep">،</span>
|
||||||
<span dir="ltr">{{ student.email }}</span>
|
<span dir="ltr">{{ student?.user.email }}</span>
|
||||||
</template>
|
</template>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -114,7 +120,6 @@
|
|||||||
</BaseButton>
|
</BaseButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span class="term-details__data-tap" v-if="false">{{ data }}</span>
|
|
||||||
</template>
|
</template>
|
||||||
</BasicModal>
|
</BasicModal>
|
||||||
</template>
|
</template>
|
||||||
@@ -135,12 +140,12 @@ import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
|||||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||||
|
import { useAdminTermEnrolleesQuery, useAdminTermQuery } from '@/services/query/admin-terms'
|
||||||
import {
|
import {
|
||||||
adminCoursesKeys,
|
adminCoursesKeys,
|
||||||
useAdminCoursesListQuery,
|
useAdminCoursesListQuery,
|
||||||
useUpdateAdminCourseMutation,
|
useUpdateAdminCourseMutation,
|
||||||
} from '@/services/query/admin-courses'
|
} from '@/services/query/admin-courses'
|
||||||
import { useAdminTermQuery, useTermAttendeesQuery } from '@/services/query/admin-terms'
|
|
||||||
|
|
||||||
defineOptions({ name: 'TermDetailsModal' })
|
defineOptions({ name: 'TermDetailsModal' })
|
||||||
|
|
||||||
@@ -167,7 +172,7 @@ const {
|
|||||||
reset: resetStudentPagination,
|
reset: resetStudentPagination,
|
||||||
} = usePagination({ page: 1, perPage: 10 })
|
} = usePagination({ page: 1, perPage: 10 })
|
||||||
|
|
||||||
const { data: studentsData, isLoading: studentsPending } = useTermAttendeesQuery(
|
const { data: studentsData, isLoading: studentsPending } = useAdminTermEnrolleesQuery(
|
||||||
termId,
|
termId,
|
||||||
studentFilters,
|
studentFilters,
|
||||||
studentPagination,
|
studentPagination,
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ const form = ref({
|
|||||||
password: '',
|
password: '',
|
||||||
passwordConfirmation: '',
|
passwordConfirmation: '',
|
||||||
})
|
})
|
||||||
const { validate, validateAt, errors } = useYup(schema)
|
const { validate, validateAt, errors } = useYup(schema, () => form.value)
|
||||||
|
|
||||||
const registerMutation = useRegisterMutation()
|
const registerMutation = useRegisterMutation()
|
||||||
const { savePhoneNumber } = useAuth()
|
const { savePhoneNumber } = useAuth()
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ const form = ref({
|
|||||||
password: '',
|
password: '',
|
||||||
passwordConfirmation: '',
|
passwordConfirmation: '',
|
||||||
})
|
})
|
||||||
const { validate, validateAt, errors } = useYup(schema)
|
const { validate, validateAt, errors } = useYup(schema, () => form.value)
|
||||||
|
|
||||||
const resetMutation = useResetPasswordMutation()
|
const resetMutation = useResetPasswordMutation()
|
||||||
|
|
||||||
|
|||||||
@@ -215,26 +215,16 @@ const statusLabel = computed(
|
|||||||
font-family: var(--font-family-fa);
|
font-family: var(--font-family-fa);
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
|
|
||||||
&--watching {
|
&--active {
|
||||||
background: rgba(0, 112, 116, 8%);
|
background: rgba(0, 112, 116, 8%);
|
||||||
color: #007074;
|
color: #007074;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--waitForExam {
|
|
||||||
background: rgba(204, 154, 40, 8%);
|
|
||||||
color: #cc6f00;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--completed {
|
&--completed {
|
||||||
background: rgba(0, 154, 18, 8%);
|
background: rgba(0, 154, 18, 8%);
|
||||||
color: #009a12;
|
color: #009a12;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--failed {
|
|
||||||
background: rgba(204, 40, 49, 8%);
|
|
||||||
color: var(--color-error);
|
|
||||||
}
|
|
||||||
|
|
||||||
&--neutral {
|
&--neutral {
|
||||||
background: rgba(180, 180, 180, 8%);
|
background: rgba(180, 180, 180, 8%);
|
||||||
color: #686868;
|
color: #686868;
|
||||||
|
|||||||
@@ -11,12 +11,7 @@
|
|||||||
</BoxedIconTitleBlock>
|
</BoxedIconTitleBlock>
|
||||||
|
|
||||||
<SkeletonLoaderBlock v-if="isLoading && !exam" :rows="2" :cols-per-row="1" />
|
<SkeletonLoaderBlock v-if="isLoading && !exam" :rows="2" :cols-per-row="1" />
|
||||||
<StudentExamSummary
|
<StudentExamSummary v-else-if="exam" :exam="exam" @start="onStart" />
|
||||||
v-else-if="exam"
|
|
||||||
:exam="exam"
|
|
||||||
:starting="startMutation.isPending.value"
|
|
||||||
@start="onStart"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SimpleTitleIconBlock title="تعداد تلاش ها برای این آزمون" class="se__list-title">
|
<SimpleTitleIconBlock title="تعداد تلاش ها برای این آزمون" class="se__list-title">
|
||||||
<template #header-icon>
|
<template #header-icon>
|
||||||
@@ -38,7 +33,6 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { toast } from 'vue3-toastify'
|
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||||
@@ -46,10 +40,7 @@ import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
|||||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||||
import StudentExamSummary from '@/features/student/exams/components/StudentExamSummary.vue'
|
import StudentExamSummary from '@/features/student/exams/components/StudentExamSummary.vue'
|
||||||
import StudentExamAttemptItem from '@/features/student/exams/components/StudentExamAttemptItem.vue'
|
import StudentExamAttemptItem from '@/features/student/exams/components/StudentExamAttemptItem.vue'
|
||||||
import {
|
import { useStudentExamQuery } from '@/services/query/student-exams'
|
||||||
useStartStudentExamAttemptMutation,
|
|
||||||
useStudentExamQuery,
|
|
||||||
} from '@/services/query/student-exams'
|
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -62,15 +53,8 @@ const { data: exam, isLoading } = useStudentExamQuery(examId, {
|
|||||||
|
|
||||||
const attempts = computed(() => exam.value?.attempts ?? [])
|
const attempts = computed(() => exam.value?.attempts ?? [])
|
||||||
|
|
||||||
const startMutation = useStartStudentExamAttemptMutation()
|
const onStart = () => {
|
||||||
|
router.push({ name: 'student-take-exam', params: { id: examId.value } }).catch(() => {})
|
||||||
const onStart = async () => {
|
|
||||||
try {
|
|
||||||
await startMutation.mutateAsync({ id: examId.value })
|
|
||||||
router.push({ name: 'student-take-exam', params: { id: examId.value } })
|
|
||||||
} catch {
|
|
||||||
toast.error('شروع آزمون با خطا مواجه شد.')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -121,10 +121,13 @@ const submitMutation = useSubmitStudentExamAttemptMutation()
|
|||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
try {
|
try {
|
||||||
await submitMutation.mutateAsync({
|
const payload = {
|
||||||
id: examId.value,
|
answers: Object.entries(answers).map(([questionId, selectedOptionId]) => ({
|
||||||
payload: { answers: { ...answers } },
|
questionId: Number(questionId),
|
||||||
})
|
selectedOptionId,
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
await submitMutation.mutateAsync({ id: examId.value, payload })
|
||||||
toast.success('پاسخهای شما با موفقیت ثبت شد.')
|
toast.success('پاسخهای شما با موفقیت ثبت شد.')
|
||||||
router.push({ name: 'student-exam', params: { id: examId.value } })
|
router.push({ name: 'student-exam', params: { id: examId.value } })
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ 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 { formatJalaaliDate } from '@/utils/date-utils'
|
||||||
import TabsBlock from '@/components/blocks/TabsBlock.vue'
|
import TabsBlock from '@/components/blocks/TabsBlock.vue'
|
||||||
import { useStudentLessonQuery } from '@/services/query/student-lessons'
|
import { useStudentCourseQuery } from '@/services/query/student-courses'
|
||||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||||
import StudentExamItem from '@/features/student/exams/components/StudentExamItem.vue'
|
import StudentExamItem from '@/features/student/exams/components/StudentExamItem.vue'
|
||||||
@@ -95,7 +95,7 @@ const router = useRouter()
|
|||||||
|
|
||||||
const lessonId = computed(() => route.params.id)
|
const lessonId = computed(() => route.params.id)
|
||||||
|
|
||||||
const { data: lesson, isLoading } = useStudentLessonQuery(lessonId, {
|
const { data: lesson, isLoading } = useStudentCourseQuery(lessonId, {
|
||||||
enabled: () => !!lessonId.value,
|
enabled: () => !!lessonId.value,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export default [
|
|||||||
path: '/my-terms',
|
path: '/my-terms',
|
||||||
name: 'student-terms',
|
name: 'student-terms',
|
||||||
component: () => import('@/features/student/terms/pages/StudentTermsPage.vue'),
|
component: () => import('@/features/student/terms/pages/StudentTermsPage.vue'),
|
||||||
meta: { layout: 'student', role: 'student', title: 'دورههای آموزشی' },
|
meta: { layout: 'student', role: 'student', title: 'ترمهای آموزشی' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/my-terms/:id',
|
path: '/my-terms/:id',
|
||||||
|
|||||||
@@ -111,11 +111,12 @@ import { objectToFormData } from '@/utils/object-to-formdata'
|
|||||||
import VoiceRecorder from '@/components/form/VoiceRecorder.vue'
|
import VoiceRecorder from '@/components/form/VoiceRecorder.vue'
|
||||||
import ImageUploader from '@/components/form/ImageUploader.vue'
|
import ImageUploader from '@/components/form/ImageUploader.vue'
|
||||||
import VideoPlayerBlock from '@/components/blocks/VideoPlayerBlock.vue'
|
import VideoPlayerBlock from '@/components/blocks/VideoPlayerBlock.vue'
|
||||||
|
import { useUploadMediaMutation } from '@/services/query/auth'
|
||||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||||
import {
|
import {
|
||||||
useStudentSessionQuery,
|
useStudentSessionQuery,
|
||||||
useSubmitStudentSessionHomeworkMutation,
|
useSubmitStudentHomeworkMutation,
|
||||||
} from '@/services/query/student-sessions'
|
} from '@/services/query/student-sessions'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@@ -149,21 +150,39 @@ const errors = reactive({ audio: '', image: '' })
|
|||||||
|
|
||||||
const canSubmit = computed(() => !!(homeworkAudio.value || homeworkImage.value))
|
const canSubmit = computed(() => !!(homeworkAudio.value || homeworkImage.value))
|
||||||
|
|
||||||
const submitMutation = useSubmitStudentSessionHomeworkMutation()
|
const submitMutation = useSubmitStudentHomeworkMutation()
|
||||||
|
const uploadMediaMutation = useUploadMediaMutation()
|
||||||
|
|
||||||
|
const homeworkId = computed(() => session.value?.homeworkId ?? session.value?.homework?.id ?? null)
|
||||||
|
|
||||||
|
const uploadHomeworkFile = async (file) => {
|
||||||
|
const fd = objectToFormData({ file, purpose: 'homework_file', context: 'homework' })
|
||||||
|
const response = await uploadMediaMutation.mutateAsync(fd)
|
||||||
|
const payload = response?.data ?? response
|
||||||
|
return payload?.id ?? null
|
||||||
|
}
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
if (!canSubmit.value) {
|
if (!canSubmit.value) {
|
||||||
errors.audio = 'حداقل یک فایل صوتی یا تصویر ارسال کنید.'
|
errors.audio = 'حداقل یک فایل صوتی یا تصویر ارسال کنید.'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (!homeworkId.value) {
|
||||||
|
toast.error('تکلیفی برای این جلسه ثبت نشده است.')
|
||||||
|
return
|
||||||
|
}
|
||||||
errors.audio = ''
|
errors.audio = ''
|
||||||
errors.image = ''
|
errors.image = ''
|
||||||
try {
|
try {
|
||||||
const payload = { subType: 'homework' }
|
const files = [homeworkAudio.value, homeworkImage.value].filter(Boolean)
|
||||||
if (homeworkAudio.value) payload.audio = homeworkAudio.value
|
for (const file of files) {
|
||||||
if (homeworkImage.value) payload.image = homeworkImage.value
|
const mediaId = await uploadHomeworkFile(file)
|
||||||
const fd = objectToFormData(payload)
|
if (!mediaId) throw new Error('upload failed')
|
||||||
await submitMutation.mutateAsync({ id: sessionId.value, payload: fd })
|
await submitMutation.mutateAsync({
|
||||||
|
homeworkId: homeworkId.value,
|
||||||
|
payload: { mediaId },
|
||||||
|
})
|
||||||
|
}
|
||||||
toast.success('تکلیف با موفقیت ارسال شد.')
|
toast.success('تکلیف با موفقیت ارسال شد.')
|
||||||
homeworkAudio.value = null
|
homeworkAudio.value = null
|
||||||
homeworkImage.value = null
|
homeworkImage.value = null
|
||||||
|
|||||||
@@ -1,50 +1,42 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="student-term-item">
|
<div class="sti">
|
||||||
<div class="student-term-item__box">
|
<div class="sti__box">
|
||||||
<div class="student-term-item__accent" />
|
<div class="sti__box__image">
|
||||||
<div class="student-term-item__info">
|
<img v-if="term.coverUrl" :src="term.coverUrl" :alt="term.title" />
|
||||||
<p class="student-term-item__title">{{ term.title || '—' }}</p>
|
<SvgIcon v-else name="book" :size="32" color="#bcbcbc" />
|
||||||
<div class="student-term-item__teacher">
|
</div>
|
||||||
<SvgIcon name="user" :size="10" color="#bcbcbc" />
|
<div class="sti__info">
|
||||||
<span class="student-term-item__teacher-label">استـــــــاد:</span>
|
<p class="sti__title">{{ term.title || '—' }}</p>
|
||||||
<span class="student-term-item__teacher-name">{{ teacherName }}</span>
|
<div class="sti__teacher">
|
||||||
|
<span class="sti__teacher-label">تعداد دوره ها:</span>
|
||||||
|
<span class="sti__teacher-name">{{ term.coursesCount ?? 0 }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="student-term-item__meta">
|
<div class="sti__meta">
|
||||||
<div class="student-term-item__dates">
|
<div class="sti__dates">
|
||||||
<div class="student-term-item__date">
|
<div class="sti__date">
|
||||||
<span class="student-term-item__date-label">تاریخ پایان :</span>
|
<span class="sti__date-label">تاریخ پایان :</span>
|
||||||
<span class="student-term-item__date-value">{{ endDate }}</span>
|
<span class="sti__date-value">{{ endDate }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span class="student-term-item__date-divider" />
|
<span class="sti__date-divider" />
|
||||||
<div class="student-term-item__date">
|
<div class="sti__date">
|
||||||
<span class="student-term-item__date-label">تاریخ شروع :</span>
|
<span class="sti__date-label">تاریخ شروع :</span>
|
||||||
<span class="student-term-item__date-value">{{ startDate }}</span>
|
<span class="sti__date-value">{{ startDate }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="hasGpa" class="student-term-item__status student-term-item__status--gpa">
|
<div class="sti__status" :class="`sti__status--${status}`">
|
||||||
<span class="student-term-item__status-label">معدل دوره :</span>
|
<span class="sti__status-label">وضعیت دوره :</span>
|
||||||
<span class="student-term-item__status-value student-term-item__status-value--en">
|
<span class="sti__status-value">{{ statusLabel }}</span>
|
||||||
{{ gpaText }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-else
|
|
||||||
class="student-term-item__status"
|
|
||||||
:class="`student-term-item__status--${term.status || 'watching'}`"
|
|
||||||
>
|
|
||||||
<span class="student-term-item__status-label">وضعیت دوره :</span>
|
|
||||||
<span class="student-term-item__status-value">{{ statusLabel }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="showDetails" class="student-term-item__actions">
|
<div v-if="showDetails" class="sti__actions">
|
||||||
<BaseButton
|
<BaseButton
|
||||||
text="جزئیات دوره"
|
text="جزئیات ترم"
|
||||||
custom-class="student-term-item__details-btn"
|
custom-class="sti__details-btn"
|
||||||
@click="emit('show-details', term)"
|
@click="emit('show-details', enrollment)"
|
||||||
>
|
>
|
||||||
<template #appendIcon>
|
<template #appendIcon>
|
||||||
<SvgIcon name="arrow-left" :size="14" color="#fff" />
|
<SvgIcon name="arrow-left" :size="14" color="#fff" />
|
||||||
@@ -62,40 +54,25 @@ import SvgIcon from '@/components/icons/SvgIcon.vue'
|
|||||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
term: { type: Object, required: true },
|
enrollment: { type: Object, required: true },
|
||||||
showDetails: { type: Boolean, default: true },
|
showDetails: { type: Boolean, default: true },
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['show-details'])
|
const emit = defineEmits(['show-details'])
|
||||||
|
|
||||||
const teacherName = computed(() => {
|
const term = computed(() => props.enrollment.term ?? {})
|
||||||
const t = props.term.teacher
|
|
||||||
if (t) return `${t.firstName || ''} ${t.lastName || ''}`.trim() || t.fullName || '—'
|
|
||||||
return props.term.teacherName || '—'
|
|
||||||
})
|
|
||||||
|
|
||||||
const startDate = computed(
|
const status = computed(() => props.enrollment.status || 'active')
|
||||||
() => props.term.faStartDate || formatJalaaliDate(props.term.startDate) || '—'
|
|
||||||
)
|
|
||||||
|
|
||||||
const endDate = computed(() => props.term.faEndDate || formatJalaaliDate(props.term.endDate) || '—')
|
const statusLabel = computed(() => STUDENT_COURSE_STATUS[status.value] || '—')
|
||||||
|
|
||||||
const statusLabel = computed(
|
const startDate = computed(() => formatJalaaliDate(term.value.startsAt) || '—')
|
||||||
() => props.term.statusLabel || STUDENT_COURSE_STATUS[props.term.status] || '—'
|
|
||||||
)
|
|
||||||
|
|
||||||
const hasGpa = computed(
|
const endDate = computed(() => formatJalaaliDate(term.value.endsAt) || '—')
|
||||||
() => props.term.gpa !== undefined && props.term.gpa !== null && props.term.gpa !== ''
|
|
||||||
)
|
|
||||||
|
|
||||||
const gpaText = computed(() => {
|
|
||||||
const v = Number(props.term.gpa)
|
|
||||||
return Number.isFinite(v) ? v.toFixed(3).replace(/0+$/, '').replace(/\.$/, '') : props.term.gpa
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.student-term-item {
|
.sti {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column-reverse;
|
flex-direction: column-reverse;
|
||||||
gap: 0.625rem;
|
gap: 0.625rem;
|
||||||
@@ -114,6 +91,24 @@ const gpaText = computed(() => {
|
|||||||
&__box {
|
&__box {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
|
&__image {
|
||||||
|
width: 2.5rem;
|
||||||
|
height: 2.5rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
background: #f5f5f5;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__info {
|
&__info {
|
||||||
@@ -136,6 +131,7 @@ const gpaText = computed(() => {
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__teacher {
|
&__teacher {
|
||||||
@@ -175,34 +171,15 @@ const gpaText = computed(() => {
|
|||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
&--watching {
|
&--active {
|
||||||
background: rgba(0, 112, 116, 4%);
|
background: rgba(0, 112, 116, 4%);
|
||||||
color: #007074;
|
color: #007074;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--waitForExam {
|
|
||||||
background: rgba(116, 102, 0, 4%);
|
|
||||||
color: #746a00;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--completed {
|
&--completed {
|
||||||
background: rgba(0, 154, 18, 6%);
|
background: rgba(0, 154, 18, 6%);
|
||||||
color: #009a12;
|
color: #009a12;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--failed {
|
|
||||||
background: rgba(204, 40, 49, 6%);
|
|
||||||
color: #cc2831;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--gpa {
|
|
||||||
background: rgba(0, 112, 116, 6%);
|
|
||||||
color: #007074;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__status-value--en {
|
|
||||||
font-family: var(--font-family-en);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__status-label {
|
&__status-label {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="student-term-summary">
|
<div class="student-term-summary">
|
||||||
<div class="student-term-summary__cover">
|
<div class="student-term-summary__cover">
|
||||||
<img v-if="term.image" :src="term.image" :alt="term.title" />
|
<img v-if="term.coverUrl" :src="term.coverUrl" :alt="term.title" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="student-term-summary__info">
|
<div class="student-term-summary__info">
|
||||||
<div
|
<div
|
||||||
class="student-term-summary__status"
|
class="student-term-summary__status"
|
||||||
:class="`student-term-summary__status--${term.status || 'watching'}`"
|
:class="`student-term-summary__status--${status}`"
|
||||||
>
|
>
|
||||||
<span class="student-term-summary__status-label">وضعیت دوره :</span>
|
<span class="student-term-summary__status-label">وضعیت دوره :</span>
|
||||||
<span class="student-term-summary__status-value">{{ statusLabel }}</span>
|
<span class="student-term-summary__status-value">{{ statusLabel }}</span>
|
||||||
@@ -43,24 +43,24 @@ import SvgIcon from '@/components/icons/SvgIcon.vue'
|
|||||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
term: { type: Object, required: true },
|
enrollment: { type: Object, required: true },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const term = computed(() => props.enrollment.term ?? {})
|
||||||
|
|
||||||
|
const status = computed(() => props.enrollment.status || 'active')
|
||||||
|
|
||||||
|
const statusLabel = computed(() => STUDENT_COURSE_STATUS[status.value] || '—')
|
||||||
|
|
||||||
const teacherName = computed(() => {
|
const teacherName = computed(() => {
|
||||||
const t = props.term.teacher
|
const t = term.value.teacher
|
||||||
if (t) return `${t.firstName || ''} ${t.lastName || ''}`.trim() || t.fullName || '—'
|
if (t) return `${t.firstName || ''} ${t.lastName || ''}`.trim() || t.fullName || '—'
|
||||||
return props.term.teacherName || '—'
|
return term.value.teacherName || '—'
|
||||||
})
|
})
|
||||||
|
|
||||||
const startDate = computed(
|
const startDate = computed(() => formatJalaaliDate(term.value.startsAt) || '—')
|
||||||
() => props.term.faStartDate || formatJalaaliDate(props.term.startDate) || '—'
|
|
||||||
)
|
|
||||||
|
|
||||||
const endDate = computed(() => props.term.faEndDate || formatJalaaliDate(props.term.endDate) || '—')
|
const endDate = computed(() => formatJalaaliDate(term.value.endsAt) || '—')
|
||||||
|
|
||||||
const statusLabel = computed(
|
|
||||||
() => props.term.statusLabel || STUDENT_COURSE_STATUS[props.term.status] || '—'
|
|
||||||
)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@@ -124,25 +124,15 @@ const statusLabel = computed(
|
|||||||
font-family: var(--font-family-fa);
|
font-family: var(--font-family-fa);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
&--watching {
|
&--active {
|
||||||
background: rgba(0, 112, 116, 4%);
|
background: rgba(0, 112, 116, 4%);
|
||||||
color: #007074;
|
color: #007074;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--waitForExam {
|
|
||||||
background: rgba(116, 102, 0, 4%);
|
|
||||||
color: #746a00;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--completed {
|
&--completed {
|
||||||
background: rgba(0, 154, 18, 6%);
|
background: rgba(0, 154, 18, 6%);
|
||||||
color: #009a12;
|
color: #009a12;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--failed {
|
|
||||||
background: rgba(204, 40, 49, 6%);
|
|
||||||
color: #cc2831;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__status-label {
|
&__status-label {
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
</template>
|
</template>
|
||||||
</BoxedIconTitleBlock>
|
</BoxedIconTitleBlock>
|
||||||
|
|
||||||
<SkeletonLoaderBlock v-if="isLoading && !term" :rows="2" :cols-per-row="1" />
|
<SkeletonLoaderBlock v-if="isLoading && !enrollment" :rows="2" :cols-per-row="1" />
|
||||||
<StudentTermSummary v-else-if="term" :term="term" />
|
<StudentTermSummary v-else-if="enrollment" :enrollment="enrollment" />
|
||||||
|
|
||||||
<SimpleTitleIconBlock title="همه درس ها" class="student-term-details__list-title">
|
<SimpleTitleIconBlock title="همه درس ها" class="student-term-details__list-title">
|
||||||
<template #header-icon>
|
<template #header-icon>
|
||||||
@@ -49,11 +49,11 @@ const router = useRouter()
|
|||||||
|
|
||||||
const termId = computed(() => route.params.id)
|
const termId = computed(() => route.params.id)
|
||||||
|
|
||||||
const { data: term, isLoading } = useStudentTermQuery(termId, {
|
const { data: enrollment, isLoading } = useStudentTermQuery(termId, {
|
||||||
enabled: () => !!termId.value,
|
enabled: () => !!termId.value,
|
||||||
})
|
})
|
||||||
|
|
||||||
const lessons = computed(() => term.value?.courses ?? term.value?.lessons ?? [])
|
const lessons = computed(() => enrollment.value?.term?.courses ?? [])
|
||||||
|
|
||||||
const onShowLesson = (lesson) => {
|
const onShowLesson = (lesson) => {
|
||||||
router.push({ name: 'student-lesson-details', params: { id: lesson.id } }).catch(() => {})
|
router.push({ name: 'student-lesson-details', params: { id: lesson.id } }).catch(() => {})
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
<div class="student-terms">
|
<div class="student-terms">
|
||||||
<BoxedIconTitleBlock
|
<BoxedIconTitleBlock
|
||||||
class="student-terms__heading"
|
class="student-terms__heading"
|
||||||
title="دورههای آموزشی"
|
title="ترمهای آموزشی"
|
||||||
desc="دورهها و آموزشهای گذراندهشده خود را مشاهده کنید."
|
desc="ترمها و آموزشهای گذراندهشده خود را مشاهده کنید."
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<SvgIcon name="book" :size="24" color="var(--color-primary)" />
|
<SvgIcon name="book" :size="24" color="var(--color-primary)" />
|
||||||
@@ -15,13 +15,13 @@
|
|||||||
<SkeletonLoaderBlock v-if="currentPending" :rows="4" :cols-per-row="1" />
|
<SkeletonLoaderBlock v-if="currentPending" :rows="4" :cols-per-row="1" />
|
||||||
<div v-else-if="currentTerms.length > 0">
|
<div v-else-if="currentTerms.length > 0">
|
||||||
<StudentTermItem
|
<StudentTermItem
|
||||||
v-for="term in currentTerms"
|
v-for="enrollment in currentTerms"
|
||||||
:key="term.id"
|
:key="enrollment.id"
|
||||||
:term="term"
|
:enrollment="enrollment"
|
||||||
@show-details="onShowDetails"
|
@show-details="onShowDetails"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<NoItems v-else title="دورهای نیست" desc="در حال حاضر دورهای در حال گذراندن ندارید." />
|
<NoItems v-else title="ترمای نیست" desc="در حال حاضر ترمای در حال گذراندن ندارید." />
|
||||||
<PaginationBlock :pagination="currentMeta" @update:page="setCurrentPage" />
|
<PaginationBlock :pagination="currentMeta" @update:page="setCurrentPage" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -29,14 +29,14 @@
|
|||||||
<SkeletonLoaderBlock v-if="endedPending" :rows="4" :cols-per-row="1" />
|
<SkeletonLoaderBlock v-if="endedPending" :rows="4" :cols-per-row="1" />
|
||||||
<div v-else-if="endedTerms.length > 0">
|
<div v-else-if="endedTerms.length > 0">
|
||||||
<StudentTermItem
|
<StudentTermItem
|
||||||
v-for="term in endedTerms"
|
v-for="enrollment in endedTerms"
|
||||||
:key="term.id"
|
:key="enrollment.id"
|
||||||
:term="term"
|
:enrollment="enrollment"
|
||||||
:showDetails="false"
|
:showDetails="false"
|
||||||
@show-details="onShowDetails"
|
@show-details="onShowDetails"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<NoItems v-else title="موردی نیست" desc="هنوز دورهای را تمام نکردهاید." />
|
<NoItems v-else title="موردی نیست" desc="هنوز ترمای را تمام نکردهاید." />
|
||||||
<PaginationBlock :pagination="endedMeta" @update:page="setEndedPage" />
|
<PaginationBlock :pagination="endedMeta" @update:page="setEndedPage" />
|
||||||
</template>
|
</template>
|
||||||
</TabsBlock>
|
</TabsBlock>
|
||||||
@@ -59,13 +59,13 @@ import StudentTermItem from '@/features/student/terms/components/StudentTermItem
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{ name: 'current', label: 'دوره های در حال گذراندن', icon: 'list-bullets' },
|
{ name: 'current', label: 'ترم های در حال گذراندن', icon: 'list-bullets' },
|
||||||
{ name: 'ended', label: 'دوره های تکمیل شده', icon: 'list-bullets' },
|
{ name: 'ended', label: 'ترم های تکمیل شده', icon: 'list-bullets' },
|
||||||
]
|
]
|
||||||
const activeTab = ref('current')
|
const activeTab = ref('current')
|
||||||
|
|
||||||
const currentFilters = ref({ status: 'current' })
|
const currentFilters = ref({ status: 'active' })
|
||||||
const endedFilters = ref({ status: 'ended' })
|
const endedFilters = ref({ status: 'completed' })
|
||||||
|
|
||||||
const { pagination: currentPagination, setPage: setCurrentPage } = usePagination({
|
const { pagination: currentPagination, setPage: setCurrentPage } = usePagination({
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -97,6 +97,7 @@ const { data: endedData, isLoading: endedPending } = useStudentTermsListQuery(
|
|||||||
|
|
||||||
const currentTerms = computed(() => currentData.value?.data ?? [])
|
const currentTerms = computed(() => currentData.value?.data ?? [])
|
||||||
const endedTerms = computed(() => endedData.value?.data ?? [])
|
const endedTerms = computed(() => endedData.value?.data ?? [])
|
||||||
|
console.log({ endedTerms: endedData.value })
|
||||||
|
|
||||||
const currentMeta = computed(() => ({
|
const currentMeta = computed(() => ({
|
||||||
page: currentPagination.value.page,
|
page: currentPagination.value.page,
|
||||||
|
|||||||
@@ -11,24 +11,3 @@ export const apiUpdateAdminCourse = (id, payload) =>
|
|||||||
http.patch(buildUrl(endpoints.updateCourse, { id }), payload)
|
http.patch(buildUrl(endpoints.updateCourse, { id }), payload)
|
||||||
|
|
||||||
export const apiDeleteAdminCourse = (id) => http.delete(buildUrl(endpoints.deleteCourse, { id }))
|
export const apiDeleteAdminCourse = (id) => http.delete(buildUrl(endpoints.deleteCourse, { id }))
|
||||||
|
|
||||||
export const apiGetAdminCourseStudents = (courseId, params) =>
|
|
||||||
http.get(buildUrl(endpoints.listCourseStudents, { courseId }), { params })
|
|
||||||
|
|
||||||
export const apiGetCourseAttendees = (courseId, params) =>
|
|
||||||
http.get(buildUrl(endpoints.getCourseAttendees, { courseId }), { params })
|
|
||||||
|
|
||||||
export const apiAddAdminCourseStudent = (courseId, payload) =>
|
|
||||||
http.post(buildUrl(endpoints.addCourseStudent, { courseId }), payload)
|
|
||||||
|
|
||||||
export const apiRemoveAdminCourseStudent = (courseId, userId) =>
|
|
||||||
http.delete(buildUrl(endpoints.removeCourseStudent, { courseId, userId }))
|
|
||||||
|
|
||||||
export const apiGetAdminCourseSessions = (courseId, params) =>
|
|
||||||
http.get(buildUrl(endpoints.listCourseSessions, { courseId }), { params })
|
|
||||||
|
|
||||||
export const apiAttachAdminCourseSession = (courseId, payload) =>
|
|
||||||
http.post(buildUrl(endpoints.attachCourseSession, { courseId }), payload)
|
|
||||||
|
|
||||||
export const apiDetachAdminCourseSession = (courseId, sessionId) =>
|
|
||||||
http.delete(buildUrl(endpoints.detachCourseSession, { courseId, sessionId }))
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ export const apiCloneAdminTerm = (id) => http.post(buildUrl(endpoints.cloneTerm,
|
|||||||
export const apiGetAdminTermStudents = (termId, params) =>
|
export const apiGetAdminTermStudents = (termId, params) =>
|
||||||
http.get(buildUrl(endpoints.listUserTerm, { termId }), { params })
|
http.get(buildUrl(endpoints.listUserTerm, { termId }), { params })
|
||||||
|
|
||||||
export const apiGetTermAttendees = (termId, params) =>
|
export const apiGetAdminTermEnrollees = (termId, params) =>
|
||||||
http.get(buildUrl(endpoints.getTermAttendees, { termId }), { params })
|
http.get(buildUrl(endpoints.getTermEnrollees, { termId }), { params })
|
||||||
|
|
||||||
export const apiAddAdminTermStudents = (termId, payload) =>
|
export const apiAddAdminTermStudents = (termId, payload) =>
|
||||||
http.post(buildUrl(endpoints.addUserTerm, { termId }), payload)
|
http.post(buildUrl(endpoints.addUserTerm, { termId }), payload)
|
||||||
|
|||||||
@@ -23,16 +23,12 @@ export const endpoints = {
|
|||||||
citiesList: '/provinces/:provinceId/cities',
|
citiesList: '/provinces/:provinceId/cities',
|
||||||
|
|
||||||
// ─── Student-facing ────────────────────────────────────────────────────────
|
// ─── Student-facing ────────────────────────────────────────────────────────
|
||||||
getStudentCourses: '/student/courses',
|
// Courses, sessions, exams use the shared backend-aligned endpoints below
|
||||||
showStudentCourse: '/student/courses/:id',
|
// (/courses, /sessions/:id, /exams/:id, /exams/:id/submit) — the backend
|
||||||
getStudentTerms: '/student/terms',
|
// infers role from the auth token and scopes the response. Terms have a
|
||||||
showStudentTerm: '/student/terms/:id',
|
// dedicated student route (returns the membership row with the nested term).
|
||||||
showStudentLesson: '/student/lessons/:id',
|
getStudentTerms: '/student/my-terms',
|
||||||
showStudentSession: '/student/sessions/:id',
|
showStudentTerm: '/student/my-terms/:id',
|
||||||
submitStudentSessionHomework: '/student/sessions/:id/homework',
|
|
||||||
showStudentExam: '/student/exams/:id',
|
|
||||||
startStudentExamAttempt: '/student/exams/:id/attempts',
|
|
||||||
submitStudentExamAttempt: '/student/exams/:id/submit',
|
|
||||||
|
|
||||||
getMissionaryProfile: '/student/missionary/profile',
|
getMissionaryProfile: '/student/missionary/profile',
|
||||||
getMissionaryRequests: '/student/missionary/requests',
|
getMissionaryRequests: '/student/missionary/requests',
|
||||||
@@ -71,7 +67,7 @@ export const endpoints = {
|
|||||||
showTerm: '/terms/:id',
|
showTerm: '/terms/:id',
|
||||||
updateTerm: '/terms/:id',
|
updateTerm: '/terms/:id',
|
||||||
deleteTerm: '/terms/:id',
|
deleteTerm: '/terms/:id',
|
||||||
getTermAttendees: '/terms/:termId/attendees',
|
getTermEnrollees: '/admin/terms/:termId/enrollees',
|
||||||
|
|
||||||
// ─── Backend-aligned: Courses ──────────────────────────────────────────────
|
// ─── Backend-aligned: Courses ──────────────────────────────────────────────
|
||||||
getCoursesList: '/courses',
|
getCoursesList: '/courses',
|
||||||
@@ -79,7 +75,6 @@ export const endpoints = {
|
|||||||
showCourse: '/courses/:id',
|
showCourse: '/courses/:id',
|
||||||
updateCourse: '/courses/:id',
|
updateCourse: '/courses/:id',
|
||||||
deleteCourse: '/courses/:id',
|
deleteCourse: '/courses/:id',
|
||||||
getCourseAttendees: '/courses/:courseId/attendees',
|
|
||||||
|
|
||||||
// ─── Backend-aligned: Sessions ─────────────────────────────────────────────
|
// ─── Backend-aligned: Sessions ─────────────────────────────────────────────
|
||||||
getSessionsList: '/sessions',
|
getSessionsList: '/sessions',
|
||||||
@@ -120,21 +115,13 @@ export const endpoints = {
|
|||||||
// Terms — clone + status + students-in-term + courses-in-term
|
// Terms — clone + status + students-in-term + courses-in-term
|
||||||
cloneTerm: '/admin/terms/:id/clone',
|
cloneTerm: '/admin/terms/:id/clone',
|
||||||
listUserTerm: '/admin/terms/:termId/students',
|
listUserTerm: '/admin/terms/:termId/students',
|
||||||
addUserTerm: '/admin/terms/:termId/students',
|
addUserTerm: '/admin/terms/:termId/enrollees',
|
||||||
removeUserTerm: '/admin/terms/:termId/students/:userId',
|
removeUserTerm: '/admin/terms/:termId/students/:userId',
|
||||||
changeLeaveStatus: '/admin/terms/:termId/students/:userId/toggle-leave',
|
changeLeaveStatus: '/admin/terms/:termId/students/:userId/toggle-leave',
|
||||||
listCourseTerm: '/admin/terms/:termId/courses',
|
listCourseTerm: '/admin/terms/:termId/courses',
|
||||||
addCourseTerm: '/admin/terms/:termId/courses',
|
addCourseTerm: '/admin/terms/:termId/courses',
|
||||||
removeCourseTerm: '/admin/terms/:termId/courses/:courseId',
|
removeCourseTerm: '/admin/terms/:termId/courses/:courseId',
|
||||||
|
|
||||||
// Courses — students-in-course + attach/detach sessions (backend uses 1:N via session.course_id)
|
|
||||||
listCourseStudents: '/admin/courses/:courseId/students',
|
|
||||||
addCourseStudent: '/admin/courses/:courseId/students',
|
|
||||||
removeCourseStudent: '/admin/courses/:courseId/students/:userId',
|
|
||||||
listCourseSessions: '/admin/courses/:courseId/sessions',
|
|
||||||
attachCourseSession: '/admin/courses/:courseId/sessions',
|
|
||||||
detachCourseSession: '/admin/courses/:courseId/sessions/:sessionId',
|
|
||||||
|
|
||||||
// Sessions — attendance roster
|
// Sessions — attendance roster
|
||||||
getSessionsAttendance: '/admin/sessions/:sessionId/attendances',
|
getSessionsAttendance: '/admin/sessions/:sessionId/attendances',
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { http } from '@/services/api/http'
|
import { http } from '@/services/api/http'
|
||||||
import { buildUrl, endpoints } from '@/services/api/endpoints'
|
import { buildUrl, endpoints } from '@/services/api/endpoints'
|
||||||
|
|
||||||
export const apiGetStudentCourses = (params) => http.get(endpoints.getStudentCourses, { params })
|
export const apiGetStudentCourses = (params) => http.get(endpoints.getCoursesList, { params })
|
||||||
|
|
||||||
export const apiShowStudentCourse = (id) => http.get(buildUrl(endpoints.showStudentCourse, { id }))
|
export const apiShowStudentCourse = (id) => http.get(buildUrl(endpoints.showCourse, { id }))
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import { http } from '@/services/api/http'
|
import { http } from '@/services/api/http'
|
||||||
import { buildUrl, endpoints } from '@/services/api/endpoints'
|
import { buildUrl, endpoints } from '@/services/api/endpoints'
|
||||||
|
|
||||||
export const apiShowStudentExam = (id) => http.get(buildUrl(endpoints.showStudentExam, { id }))
|
export const apiShowStudentExam = (id) => http.get(buildUrl(endpoints.showExam, { id }))
|
||||||
|
|
||||||
export const apiStartStudentExamAttempt = (id) =>
|
|
||||||
http.post(buildUrl(endpoints.startStudentExamAttempt, { id }))
|
|
||||||
|
|
||||||
export const apiSubmitStudentExamAttempt = (id, payload) =>
|
export const apiSubmitStudentExamAttempt = (id, payload) =>
|
||||||
http.post(buildUrl(endpoints.submitStudentExamAttempt, { id }), payload)
|
http.post(buildUrl(endpoints.submitExam, { examId: id }), payload)
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
import { http } from '@/services/api/http'
|
|
||||||
import { buildUrl, endpoints } from '@/services/api/endpoints'
|
|
||||||
|
|
||||||
export const apiShowStudentLesson = (id) => http.get(buildUrl(endpoints.showStudentLesson, { id }))
|
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
import { http } from '@/services/api/http'
|
import { http } from '@/services/api/http'
|
||||||
import { buildUrl, endpoints } from '@/services/api/endpoints'
|
import { buildUrl, endpoints } from '@/services/api/endpoints'
|
||||||
|
|
||||||
export const apiShowStudentSession = (id) =>
|
export const apiShowStudentSession = (id) => http.get(buildUrl(endpoints.showSession, { id }))
|
||||||
http.get(buildUrl(endpoints.showStudentSession, { id }))
|
|
||||||
|
|
||||||
export const apiSubmitStudentSessionHomework = (id, formData) =>
|
export const apiSubmitStudentHomework = (homeworkId, payload) =>
|
||||||
http.post(buildUrl(endpoints.submitStudentSessionHomework, { id }), formData)
|
http.post(buildUrl(endpoints.submitHomework, { homeworkId }), payload)
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
import { register } from '@/services/mock/registry'
|
|
||||||
import { endpoints } from '@/services/api/endpoints'
|
|
||||||
import { findOrThrow, paginate } from '@/services/mock/helpers'
|
|
||||||
import { studentCourses } from '@/services/mock/fixtures/student-courses'
|
|
||||||
|
|
||||||
const filterByStatus = (status) => {
|
|
||||||
if (!status) return studentCourses
|
|
||||||
if (status === 'current') {
|
|
||||||
return studentCourses.filter((c) => ['watching', 'waitForExam'].includes(c.status))
|
|
||||||
}
|
|
||||||
if (status === 'ended') {
|
|
||||||
return studentCourses.filter((c) => ['completed', 'failed'].includes(c.status))
|
|
||||||
}
|
|
||||||
return studentCourses.filter((c) => c.status === status)
|
|
||||||
}
|
|
||||||
|
|
||||||
register('GET', endpoints.getStudentCourses, ({ query }) => {
|
|
||||||
const list = filterByStatus(query.status)
|
|
||||||
return paginate(list, query)
|
|
||||||
})
|
|
||||||
|
|
||||||
register('GET', endpoints.showStudentCourse, ({ params }) => ({
|
|
||||||
data: findOrThrow(studentCourses, params.id),
|
|
||||||
}))
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import { register } from '@/services/mock/registry'
|
|
||||||
import { endpoints } from '@/services/api/endpoints'
|
|
||||||
import { studentExams } from '@/services/mock/fixtures/student-exams'
|
|
||||||
|
|
||||||
register('GET', endpoints.showStudentExam, ({ params }) => {
|
|
||||||
const exam = studentExams.find((e) => String(e.id) === String(params.id))
|
|
||||||
if (exam) return { data: exam }
|
|
||||||
const fallback = studentExams[1]
|
|
||||||
return { data: { ...fallback, id: params.id } }
|
|
||||||
})
|
|
||||||
|
|
||||||
register('POST', endpoints.startStudentExamAttempt, ({ params }) => ({
|
|
||||||
data: { id: params.id, status: 'started', message: 'آزمون آغاز شد' },
|
|
||||||
}))
|
|
||||||
|
|
||||||
register('POST', endpoints.submitStudentExamAttempt, ({ params, data }) => {
|
|
||||||
const answers = data?.answers || {}
|
|
||||||
const total = Object.keys(answers).length
|
|
||||||
return {
|
|
||||||
data: {
|
|
||||||
id: params.id,
|
|
||||||
submitted: true,
|
|
||||||
score: total > 0 ? (12 + Math.random() * 6).toFixed(2) : 0,
|
|
||||||
message: 'پاسخهای شما با موفقیت ثبت شد.',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { register } from '@/services/mock/registry'
|
|
||||||
import { endpoints } from '@/services/api/endpoints'
|
|
||||||
import { studentLessons } from '@/services/mock/fixtures/student-lessons'
|
|
||||||
|
|
||||||
register('GET', endpoints.showStudentLesson, ({ params }) => {
|
|
||||||
const lesson = studentLessons.find((l) => String(l.id) === String(params.id))
|
|
||||||
if (lesson) return { data: lesson }
|
|
||||||
// fallback so any term/lesson combo resolves
|
|
||||||
const fallback = studentLessons[0]
|
|
||||||
return { data: { ...fallback, id: params.id } }
|
|
||||||
})
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import { register } from '@/services/mock/registry'
|
|
||||||
import { endpoints } from '@/services/api/endpoints'
|
|
||||||
import { studentSessions } from '@/services/mock/fixtures/student-sessions'
|
|
||||||
|
|
||||||
register('GET', endpoints.showStudentSession, ({ params }) => {
|
|
||||||
const session = studentSessions.find((s) => String(s.id) === String(params.id))
|
|
||||||
if (session) return { data: session }
|
|
||||||
const fallback = studentSessions[0]
|
|
||||||
return { data: { ...fallback, id: params.id } }
|
|
||||||
})
|
|
||||||
|
|
||||||
register('POST', endpoints.submitStudentSessionHomework, ({ params }) => ({
|
|
||||||
data: { id: params.id, status: 'submitted', message: 'تکلیف با موفقیت ارسال شد' },
|
|
||||||
}))
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { register } from '@/services/mock/registry'
|
|
||||||
import { endpoints } from '@/services/api/endpoints'
|
|
||||||
import { findOrThrow, paginate } from '@/services/mock/helpers'
|
|
||||||
import { studentTerms } from '@/services/mock/fixtures/student-terms'
|
|
||||||
|
|
||||||
const CURRENT_STATUSES = new Set(['watching', 'waitForExam'])
|
|
||||||
const ENDED_STATUSES = new Set(['completed', 'failed'])
|
|
||||||
|
|
||||||
register('GET', endpoints.getStudentTerms, ({ query }) => {
|
|
||||||
let list = [...studentTerms]
|
|
||||||
if (query.status === 'current') {
|
|
||||||
list = list.filter((t) => CURRENT_STATUSES.has(t.status))
|
|
||||||
} else if (query.status === 'ended') {
|
|
||||||
list = list.filter((t) => ENDED_STATUSES.has(t.status))
|
|
||||||
}
|
|
||||||
return paginate(list, query)
|
|
||||||
})
|
|
||||||
|
|
||||||
register('GET', endpoints.showStudentTerm, ({ params }) => ({
|
|
||||||
data: findOrThrow(studentTerms, params.id),
|
|
||||||
}))
|
|
||||||
@@ -2,15 +2,8 @@ import { cleanFilters } from '@/utils/clean-filters'
|
|||||||
import { useMutation, useQuery } from '@tanstack/vue-query'
|
import { useMutation, useQuery } from '@tanstack/vue-query'
|
||||||
import {
|
import {
|
||||||
apiAddAdminCourse,
|
apiAddAdminCourse,
|
||||||
apiAddAdminCourseStudent,
|
|
||||||
apiAttachAdminCourseSession,
|
|
||||||
apiDeleteAdminCourse,
|
apiDeleteAdminCourse,
|
||||||
apiDetachAdminCourseSession,
|
|
||||||
apiGetAdminCourseSessions,
|
|
||||||
apiGetAdminCourseStudents,
|
|
||||||
apiGetAdminCourses,
|
apiGetAdminCourses,
|
||||||
apiGetCourseAttendees,
|
|
||||||
apiRemoveAdminCourseStudent,
|
|
||||||
apiShowAdminCourse,
|
apiShowAdminCourse,
|
||||||
apiUpdateAdminCourse,
|
apiUpdateAdminCourse,
|
||||||
} from '@/services/api/admin-courses'
|
} from '@/services/api/admin-courses'
|
||||||
@@ -19,22 +12,6 @@ export const adminCoursesKeys = {
|
|||||||
all: ['admin', 'courses'],
|
all: ['admin', 'courses'],
|
||||||
list: (filters, pagination) => ['admin', 'courses', 'list', filters, pagination],
|
list: (filters, pagination) => ['admin', 'courses', 'list', filters, pagination],
|
||||||
detail: (id) => ['admin', 'courses', 'detail', id],
|
detail: (id) => ['admin', 'courses', 'detail', id],
|
||||||
students: (courseId, filters, pagination) => [
|
|
||||||
'admin',
|
|
||||||
'courses',
|
|
||||||
'students',
|
|
||||||
courseId,
|
|
||||||
filters,
|
|
||||||
pagination,
|
|
||||||
],
|
|
||||||
sessions: (courseId, filters, pagination) => [
|
|
||||||
'admin',
|
|
||||||
'courses',
|
|
||||||
'sessions',
|
|
||||||
courseId,
|
|
||||||
filters,
|
|
||||||
pagination,
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useAdminCoursesListQuery = (filtersRef, paginationRef, options = {}) =>
|
export const useAdminCoursesListQuery = (filtersRef, paginationRef, options = {}) =>
|
||||||
@@ -67,60 +44,3 @@ export const useUpdateAdminCourseMutation = () =>
|
|||||||
|
|
||||||
export const useDeleteAdminCourseMutation = () =>
|
export const useDeleteAdminCourseMutation = () =>
|
||||||
useMutation({ mutationFn: (id) => apiDeleteAdminCourse(id) })
|
useMutation({ mutationFn: (id) => apiDeleteAdminCourse(id) })
|
||||||
|
|
||||||
export const useAdminCourseStudentsQuery = (courseIdRef, filtersRef, paginationRef, options = {}) =>
|
|
||||||
useQuery({
|
|
||||||
queryKey: ['admin', 'courses', 'students', courseIdRef, filtersRef, paginationRef],
|
|
||||||
queryFn: () =>
|
|
||||||
apiGetAdminCourseStudents(courseIdRef.value, {
|
|
||||||
...cleanFilters(filtersRef?.value || {}),
|
|
||||||
...paginationRef?.value,
|
|
||||||
}),
|
|
||||||
...options,
|
|
||||||
})
|
|
||||||
|
|
||||||
export const useCourseAttendeesQuery = (courseIdRef, filtersRef, paginationRef, options = {}) =>
|
|
||||||
useQuery({
|
|
||||||
queryKey: ['courses', 'attendees', courseIdRef, filtersRef, paginationRef],
|
|
||||||
queryFn: () =>
|
|
||||||
apiGetCourseAttendees(courseIdRef.value, {
|
|
||||||
...cleanFilters(filtersRef?.value || {}),
|
|
||||||
...paginationRef?.value,
|
|
||||||
}),
|
|
||||||
select: (response) => ({
|
|
||||||
data: response?.data?.items ?? response?.data ?? [],
|
|
||||||
meta: response?.data?.meta ?? response?.meta,
|
|
||||||
}),
|
|
||||||
...options,
|
|
||||||
})
|
|
||||||
|
|
||||||
export const useAddAdminCourseStudentMutation = () =>
|
|
||||||
useMutation({
|
|
||||||
mutationFn: ({ courseId, payload }) => apiAddAdminCourseStudent(courseId, payload),
|
|
||||||
})
|
|
||||||
|
|
||||||
export const useRemoveAdminCourseStudentMutation = () =>
|
|
||||||
useMutation({
|
|
||||||
mutationFn: ({ courseId, userId }) => apiRemoveAdminCourseStudent(courseId, userId),
|
|
||||||
})
|
|
||||||
|
|
||||||
export const useAdminCourseSessionsQuery = (courseIdRef, filtersRef, paginationRef, options = {}) =>
|
|
||||||
useQuery({
|
|
||||||
queryKey: ['admin', 'courses', 'sessions', courseIdRef, filtersRef, paginationRef],
|
|
||||||
queryFn: () =>
|
|
||||||
apiGetAdminCourseSessions(courseIdRef.value, {
|
|
||||||
...cleanFilters(filtersRef?.value || {}),
|
|
||||||
...paginationRef?.value,
|
|
||||||
}),
|
|
||||||
...options,
|
|
||||||
})
|
|
||||||
|
|
||||||
export const useAttachAdminCourseSessionMutation = () =>
|
|
||||||
useMutation({
|
|
||||||
mutationFn: ({ courseId, payload }) => apiAttachAdminCourseSession(courseId, payload),
|
|
||||||
})
|
|
||||||
|
|
||||||
export const useDetachAdminCourseSessionMutation = () =>
|
|
||||||
useMutation({
|
|
||||||
mutationFn: ({ courseId, sessionId }) => apiDetachAdminCourseSession(courseId, sessionId),
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import {
|
|||||||
apiDeleteAdminTerm,
|
apiDeleteAdminTerm,
|
||||||
apiGetAdminTerms,
|
apiGetAdminTerms,
|
||||||
apiGetAdminTermCourses,
|
apiGetAdminTermCourses,
|
||||||
|
apiGetAdminTermEnrollees,
|
||||||
apiGetAdminTermStudents,
|
apiGetAdminTermStudents,
|
||||||
apiGetTermAttendees,
|
|
||||||
apiRemoveAdminTermCourse,
|
apiRemoveAdminTermCourse,
|
||||||
apiRemoveAdminTermStudent,
|
apiRemoveAdminTermStudent,
|
||||||
apiShowAdminTerm,
|
apiShowAdminTerm,
|
||||||
@@ -29,9 +29,10 @@ export const adminTermsKeys = {
|
|||||||
filters,
|
filters,
|
||||||
pagination,
|
pagination,
|
||||||
],
|
],
|
||||||
attendees: (termId, filters, pagination) => [
|
enrollees: (termId, filters, pagination) => [
|
||||||
|
'admin',
|
||||||
'terms',
|
'terms',
|
||||||
'attendees',
|
'enrollees',
|
||||||
termId,
|
termId,
|
||||||
filters,
|
filters,
|
||||||
pagination,
|
pagination,
|
||||||
@@ -88,11 +89,11 @@ export const useAdminTermStudentsQuery = (termIdRef, filtersRef, paginationRef,
|
|||||||
...options,
|
...options,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const useTermAttendeesQuery = (termIdRef, filtersRef, paginationRef, options = {}) =>
|
export const useAdminTermEnrolleesQuery = (termIdRef, filtersRef, paginationRef, options = {}) =>
|
||||||
useQuery({
|
useQuery({
|
||||||
queryKey: ['terms', 'attendees', termIdRef, filtersRef, paginationRef],
|
queryKey: ['admin', 'terms', 'enrollees', termIdRef, filtersRef, paginationRef],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
apiGetTermAttendees(termIdRef.value, {
|
apiGetAdminTermEnrollees(termIdRef.value, {
|
||||||
...cleanFilters(filtersRef?.value || {}),
|
...cleanFilters(filtersRef?.value || {}),
|
||||||
...paginationRef?.value,
|
...paginationRef?.value,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export const useGetMeQuery = (options = {}) =>
|
|||||||
useQuery({
|
useQuery({
|
||||||
queryKey: authKeys.me(),
|
queryKey: authKeys.me(),
|
||||||
queryFn: () => apiGetMe(),
|
queryFn: () => apiGetMe(),
|
||||||
select: (response) => response?.data?.user ?? response?.data ?? response,
|
select: (response) => response?.data ?? response,
|
||||||
...options,
|
...options,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,15 @@ export const studentCoursesKeys = {
|
|||||||
detail: (id) => ['student', 'courses', 'detail', id],
|
detail: (id) => ['student', 'courses', 'detail', id],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const adaptCourseResponse = (response) => {
|
||||||
|
const course = response?.data ?? response
|
||||||
|
if (!course) return course
|
||||||
|
return {
|
||||||
|
...course,
|
||||||
|
image: course.image ?? course.coverUrl ?? null,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const useStudentCoursesListQuery = (filtersRef, paginationRef, options = {}) =>
|
export const useStudentCoursesListQuery = (filtersRef, paginationRef, options = {}) =>
|
||||||
useQuery({
|
useQuery({
|
||||||
queryKey: ['student', 'courses', 'list', filtersRef, paginationRef],
|
queryKey: ['student', 'courses', 'list', filtersRef, paginationRef],
|
||||||
@@ -23,6 +32,6 @@ export const useStudentCourseQuery = (idRef, options = {}) =>
|
|||||||
useQuery({
|
useQuery({
|
||||||
queryKey: ['student', 'courses', 'detail', idRef],
|
queryKey: ['student', 'courses', 'detail', idRef],
|
||||||
queryFn: () => apiShowStudentCourse(idRef.value),
|
queryFn: () => apiShowStudentCourse(idRef.value),
|
||||||
select: (response) => response?.data ?? response,
|
select: adaptCourseResponse,
|
||||||
...options,
|
...options,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
import { useMutation, useQuery } from '@tanstack/vue-query'
|
import { useMutation, useQuery } from '@tanstack/vue-query'
|
||||||
import {
|
import { apiShowStudentExam, apiSubmitStudentExamAttempt } from '@/services/api/student-exams'
|
||||||
apiShowStudentExam,
|
|
||||||
apiStartStudentExamAttempt,
|
|
||||||
apiSubmitStudentExamAttempt,
|
|
||||||
} from '@/services/api/student-exams'
|
|
||||||
|
|
||||||
export const studentExamsKeys = {
|
export const studentExamsKeys = {
|
||||||
detail: (id) => ['student', 'exams', 'detail', id],
|
detail: (id) => ['student', 'exams', 'detail', id],
|
||||||
@@ -17,9 +13,6 @@ export const useStudentExamQuery = (idRef, options = {}) =>
|
|||||||
...options,
|
...options,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const useStartStudentExamAttemptMutation = () =>
|
|
||||||
useMutation({ mutationFn: ({ id }) => apiStartStudentExamAttempt(id) })
|
|
||||||
|
|
||||||
export const useSubmitStudentExamAttemptMutation = () =>
|
export const useSubmitStudentExamAttemptMutation = () =>
|
||||||
useMutation({
|
useMutation({
|
||||||
mutationFn: ({ id, payload }) => apiSubmitStudentExamAttempt(id, payload),
|
mutationFn: ({ id, payload }) => apiSubmitStudentExamAttempt(id, payload),
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
import { useQuery } from '@tanstack/vue-query'
|
|
||||||
import { apiShowStudentLesson } from '@/services/api/student-lessons'
|
|
||||||
|
|
||||||
export const studentLessonsKeys = {
|
|
||||||
detail: (id) => ['student', 'lessons', 'detail', id],
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useStudentLessonQuery = (idRef, options = {}) =>
|
|
||||||
useQuery({
|
|
||||||
queryKey: ['student', 'lessons', 'detail', idRef],
|
|
||||||
queryFn: () => apiShowStudentLesson(idRef.value),
|
|
||||||
select: (response) => response?.data ?? response,
|
|
||||||
...options,
|
|
||||||
})
|
|
||||||
@@ -1,22 +1,32 @@
|
|||||||
import { useMutation, useQuery } from '@tanstack/vue-query'
|
import { useMutation, useQuery } from '@tanstack/vue-query'
|
||||||
import {
|
import { apiShowStudentSession, apiSubmitStudentHomework } from '@/services/api/student-sessions'
|
||||||
apiShowStudentSession,
|
|
||||||
apiSubmitStudentSessionHomework,
|
|
||||||
} from '@/services/api/student-sessions'
|
|
||||||
|
|
||||||
export const studentSessionsKeys = {
|
export const studentSessionsKeys = {
|
||||||
detail: (id) => ['student', 'sessions', 'detail', id],
|
detail: (id) => ['student', 'sessions', 'detail', id],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const adaptSessionResponse = (response) => {
|
||||||
|
const session = response?.data ?? response ?? {}
|
||||||
|
const media = Array.isArray(session.media) ? session.media : []
|
||||||
|
const byCollection = (name) => media.find((m) => m.collectionName === name)
|
||||||
|
return {
|
||||||
|
...session,
|
||||||
|
videoUrl: byCollection('videos')?.url ?? null,
|
||||||
|
audioUrl: byCollection('voices')?.url ?? null,
|
||||||
|
pdfUrl: byCollection('pdfs')?.url ?? null,
|
||||||
|
poster: byCollection('cover')?.url ?? null,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const useStudentSessionQuery = (idRef, options = {}) =>
|
export const useStudentSessionQuery = (idRef, options = {}) =>
|
||||||
useQuery({
|
useQuery({
|
||||||
queryKey: ['student', 'sessions', 'detail', idRef],
|
queryKey: ['student', 'sessions', 'detail', idRef],
|
||||||
queryFn: () => apiShowStudentSession(idRef.value),
|
queryFn: () => apiShowStudentSession(idRef.value),
|
||||||
select: (response) => response?.data ?? response,
|
select: adaptSessionResponse,
|
||||||
...options,
|
...options,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const useSubmitStudentSessionHomeworkMutation = () =>
|
export const useSubmitStudentHomeworkMutation = () =>
|
||||||
useMutation({
|
useMutation({
|
||||||
mutationFn: ({ id, payload }) => apiSubmitStudentSessionHomework(id, payload),
|
mutationFn: ({ homeworkId, payload }) => apiSubmitStudentHomework(homeworkId, payload),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ export const useStudentTermsListQuery = (filtersRef, paginationRef, options = {}
|
|||||||
...cleanFilters(filtersRef.value),
|
...cleanFilters(filtersRef.value),
|
||||||
...paginationRef.value,
|
...paginationRef.value,
|
||||||
}),
|
}),
|
||||||
|
select: (response) => {
|
||||||
|
const payload = response?.data ?? response ?? {}
|
||||||
|
return {
|
||||||
|
data: Array.isArray(payload.items) ? payload.items : payload ?? [],
|
||||||
|
meta: payload.meta,
|
||||||
|
}
|
||||||
|
},
|
||||||
...options,
|
...options,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user