first commit
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
<template>
|
||||
<div class="assignment-item">
|
||||
<div class="assignment-item__main">
|
||||
<p class="assignment-item__title">{{ assignment.title || '—' }}</p>
|
||||
<div class="assignment-item__sub">
|
||||
<span class="assignment-item__sub-label">دوره:</span>
|
||||
<span class="assignment-item__sub-value">
|
||||
{{ assignment.courseTemplate?.title || assignment.courseTemplateTitle || '—' }}
|
||||
</span>
|
||||
<span class="assignment-item__dot">|</span>
|
||||
<span class="assignment-item__sub-label">جلسه:</span>
|
||||
<span class="assignment-item__sub-value">
|
||||
{{ assignment.session?.title || assignment.sessionTitle || '—' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="assignment-item__meta">
|
||||
<div class="assignment-item__pill">
|
||||
<span class="assignment-item__pill-label">مدت زمان ارسال:</span>
|
||||
<span class="assignment-item__pill-value">{{ duration }}</span>
|
||||
</div>
|
||||
<div class="assignment-item__pill">
|
||||
<span class="assignment-item__pill-label">تعداد فرستندگان:</span>
|
||||
<span class="assignment-item__pill-value">{{ submissions }}</span>
|
||||
</div>
|
||||
<div class="assignment-item__pill">
|
||||
<span class="assignment-item__pill-label">تاریخ ثبت:</span>
|
||||
<span class="assignment-item__pill-value">{{ createdAt }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="assignment-item__actions">
|
||||
<CircleButton
|
||||
tooltip="تکالیف ارسالشده"
|
||||
bg-color="rgba(0, 112, 116, 0.08)"
|
||||
size="2.5rem"
|
||||
@click="emit('show-submissions', assignment)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="users-three" :size="18" color="#007074" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="حذف"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('delete', assignment)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="18" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="ویرایش"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('edit', assignment)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="pencil" :size="18" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<BaseButton
|
||||
text="جزئیات تکلیف"
|
||||
custom-class="assignment-item__details-btn"
|
||||
@click="emit('show-details', assignment)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
const props = defineProps({
|
||||
assignment: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['edit', 'delete', 'show-details', 'show-submissions'])
|
||||
|
||||
const duration = computed(() =>
|
||||
props.assignment.durationDays == null ? '—' : `${props.assignment.durationDays} روز`
|
||||
)
|
||||
|
||||
const submissions = computed(() =>
|
||||
props.assignment.submissionsCount == null ? '—' : `${props.assignment.submissionsCount} نفر`
|
||||
)
|
||||
|
||||
const createdAt = computed(
|
||||
() => props.assignment.faCreatedAt || formatJalaaliDate(props.assignment.createdAt) || '—'
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.assignment-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.625rem;
|
||||
padding: 0.75rem;
|
||||
background: rgba(255, 255, 255, 50%);
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
border-radius: 0.875rem;
|
||||
margin-bottom: 0.625rem;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
flex-flow: row wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__main {
|
||||
flex: 1 1 25%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__sub-label {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
&__sub-value {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&__dot {
|
||||
color: #c4c4c4;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 41%;
|
||||
}
|
||||
|
||||
&__pill {
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
padding: 0.25rem 1rem;
|
||||
border-radius: 0.875rem;
|
||||
line-height: 1.5;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__pill-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 300;
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__pill-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 500;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
flex: 1 1 100%;
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
}
|
||||
|
||||
&__details-btn {
|
||||
min-width: 8rem;
|
||||
padding: 0 0.875rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,175 @@
|
||||
<template>
|
||||
<form class="assignments-filters" @submit.prevent="onSubmit">
|
||||
<div class="assignments-filters__grid">
|
||||
<TextField v-model="form.title" name="title" label="عنوان تکلیف">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="book" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.courseTemplateId"
|
||||
name="courseTemplateId"
|
||||
label="دوره الگو"
|
||||
:options="templateOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchTemplates"
|
||||
/>
|
||||
<SelectField
|
||||
v-model="form.sessionId"
|
||||
name="sessionId"
|
||||
label="جلسه"
|
||||
:options="sessionOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchSessions"
|
||||
/>
|
||||
<DatePickerField v-model="form.fromDate" name="fromDate" label="از تاریخ" :max="todayIso" />
|
||||
<DatePickerField v-model="form.toDate" name="toDate" label="تا تاریخ" :max="todayIso" />
|
||||
</div>
|
||||
|
||||
<div class="assignments-filters__actions">
|
||||
<CircleButton
|
||||
v-if="hasFilters"
|
||||
tooltip="حذف فیلتر"
|
||||
bg-color="transparent"
|
||||
size="2.5rem"
|
||||
type="button"
|
||||
@click="onReset"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="close" :size="20" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="اعمال فیلتر"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
type="submit"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="funnel" :size="20" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import { useAdminCourseTemplatesListQuery } from '@/services/query/admin-course-templates'
|
||||
import { useAdminSessionsListQuery } from '@/services/query/admin-sessions'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
title: '',
|
||||
courseTemplateId: '',
|
||||
sessionId: '',
|
||||
fromDate: '',
|
||||
toDate: '',
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'apply', 'reset'])
|
||||
|
||||
const emptyForm = () => ({
|
||||
title: '',
|
||||
courseTemplateId: '',
|
||||
sessionId: '',
|
||||
fromDate: '',
|
||||
toDate: '',
|
||||
})
|
||||
const form = ref({ ...emptyForm(), ...props.modelValue })
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(next) => {
|
||||
form.value = { ...emptyForm(), ...next }
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const todayIso = new Date().toISOString()
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: templatesResponse } = useAdminCourseTemplatesListQuery(
|
||||
templateFilters,
|
||||
templatePagination
|
||||
)
|
||||
const templateOptions = computed(() => templatesResponse.value?.data ?? [])
|
||||
|
||||
const sessionSearch = ref('')
|
||||
const sessionListFilters = computed(() => ({
|
||||
title: sessionSearch.value,
|
||||
courseTemplateId: form.value.courseTemplateId || undefined,
|
||||
}))
|
||||
const sessionPagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: sessionsResponse } = useAdminSessionsListQuery(sessionListFilters, sessionPagination)
|
||||
const sessionOptions = computed(() => sessionsResponse.value?.data ?? [])
|
||||
|
||||
const searchTemplates = useDebounce((q) => {
|
||||
templateSearch.value = q || ''
|
||||
}, 400)
|
||||
const searchSessions = useDebounce((q) => {
|
||||
sessionSearch.value = q || ''
|
||||
}, 400)
|
||||
|
||||
const hasFilters = computed(() =>
|
||||
Object.values(form.value).some((v) => v !== '' && v !== null && v !== undefined)
|
||||
)
|
||||
|
||||
const onSubmit = () => {
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('apply', { ...form.value })
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
form.value = emptyForm()
|
||||
emit('update:modelValue', { ...form.value })
|
||||
emit('reset')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.assignments-filters {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
|
||||
&__grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding-top: 1.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,325 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="64rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<form class="add-assignment" @submit.prevent="onSubmit(close)">
|
||||
<LineTitleBlock
|
||||
:title="isEditMode ? 'ویرایش تکلیف' : 'افزودن تکلیف جدید'"
|
||||
:title-en="isEditMode ? 'Edit Assignment' : 'Add Assignment'"
|
||||
/>
|
||||
|
||||
<div class="add-assignment__grid">
|
||||
<TextField
|
||||
v-model="form.title"
|
||||
name="title"
|
||||
label="عنوان تکلیف"
|
||||
:error="errors.title"
|
||||
@blur="validateAt('title', form.title)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="book" :size="20" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.courseTemplateId"
|
||||
name="courseTemplateId"
|
||||
label="دوره مرتبط"
|
||||
:options="templateOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchTemplates"
|
||||
:error="errors.courseTemplateId"
|
||||
@update:model-value="onCourseChange"
|
||||
/>
|
||||
<SelectField
|
||||
v-model="form.sessionId"
|
||||
name="sessionId"
|
||||
label="جلسه مرتبط"
|
||||
:options="sessionOptions"
|
||||
option-label="title"
|
||||
option-value="id"
|
||||
:searchable="true"
|
||||
:on-search="searchSessions"
|
||||
:disabled="!form.courseTemplateId"
|
||||
:error="errors.sessionId"
|
||||
/>
|
||||
<DatePickerField
|
||||
v-model="form.startDate"
|
||||
name="startDate"
|
||||
label="تاریخ شروع"
|
||||
:error="errors.startDate"
|
||||
/>
|
||||
<DatePickerField
|
||||
v-model="form.endDate"
|
||||
name="endDate"
|
||||
label="تاریخ پایان"
|
||||
:error="errors.endDate"
|
||||
/>
|
||||
<SelectField
|
||||
v-model="form.priority"
|
||||
name="priority"
|
||||
label="اولویت"
|
||||
:options="priorityOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:error="errors.priority"
|
||||
/>
|
||||
<div class="add-assignment__cell--full">
|
||||
<TextareaField
|
||||
v-model="form.description"
|
||||
name="description"
|
||||
label="توضیحات تکلیف"
|
||||
:row="5"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="add-assignment__files">
|
||||
<LineTitleBlock title="فایلهای تکلیف" title-en="Assignment Files" />
|
||||
<FileUploader
|
||||
v-model="attachments"
|
||||
accept=".mp4,.mov,.avi,.mp3,.wav,.jpg,.jpeg,.png,.pdf,.txt,.doc,.docx"
|
||||
:multiple="true"
|
||||
:max-files="10"
|
||||
context="assignment"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="add-assignment__divider" />
|
||||
|
||||
<div class="add-assignment__actions">
|
||||
<BaseButton
|
||||
variant="transparent"
|
||||
text="منصرف شدم"
|
||||
custom-class="add-assignment__btn-cancel"
|
||||
@click="close"
|
||||
>
|
||||
<template #prependIcon>
|
||||
<SvgIcon name="caret-right" :size="14" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
text="تایید اطلاعات"
|
||||
:loading="submitting"
|
||||
custom-class="add-assignment__btn-submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import DatePickerField from '@/components/form/DatePickerField.vue'
|
||||
import FileUploader from '@/components/form/FileUploader.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import useYup from '@/composables/useYup'
|
||||
import {
|
||||
adminAssignmentsKeys,
|
||||
useAddAdminAssignmentMutation,
|
||||
useAdminAssignmentQuery,
|
||||
useUpdateAdminAssignmentMutation,
|
||||
} from '@/services/query/admin-assignments'
|
||||
import { useAdminCourseTemplatesListQuery } from '@/services/query/admin-course-templates'
|
||||
import { useAdminSessionsListQuery } from '@/services/query/admin-sessions'
|
||||
import useDebounce from '@/composables/useDebounce'
|
||||
import { ASSIGNMENT_PRIORITY } from '@/enums'
|
||||
import { assignmentSchema } from '@/features/admin/assignments/schema'
|
||||
|
||||
defineOptions({ name: 'AddAssignmentModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('AddAssignmentModal')?.data ?? {})
|
||||
const assignmentId = computed(() => modalData.value.id ?? null)
|
||||
const isEditMode = computed(() => !!assignmentId.value)
|
||||
|
||||
const priorityOptions = Object.entries(ASSIGNMENT_PRIORITY).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))
|
||||
|
||||
const form = ref({
|
||||
title: '',
|
||||
courseTemplateId: '',
|
||||
sessionId: '',
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
priority: 'mandatory',
|
||||
description: '',
|
||||
})
|
||||
|
||||
const attachments = ref([])
|
||||
|
||||
const schema = assignmentSchema
|
||||
|
||||
const { validate, validateAt, errors, resetErrors } = useYup(schema)
|
||||
|
||||
const templateSearch = ref('')
|
||||
const templateFilters = computed(() => ({ title: templateSearch.value }))
|
||||
const templatePagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: templatesResponse } = useAdminCourseTemplatesListQuery(
|
||||
templateFilters,
|
||||
templatePagination
|
||||
)
|
||||
const selectedTemplate = ref(null)
|
||||
const templateOptions = computed(() => {
|
||||
const base = templatesResponse.value?.data ?? []
|
||||
if (selectedTemplate.value && !base.some((t) => t.id === selectedTemplate.value.id)) {
|
||||
return [...base, selectedTemplate.value]
|
||||
}
|
||||
return base
|
||||
})
|
||||
|
||||
const sessionSearch = ref('')
|
||||
const sessionFilters = computed(() => ({
|
||||
title: sessionSearch.value,
|
||||
courseTemplateId: form.value.courseTemplateId,
|
||||
}))
|
||||
const sessionPagination = ref({ page: 1, perPage: 30 })
|
||||
const { data: sessionsResponse } = useAdminSessionsListQuery(sessionFilters, sessionPagination, {
|
||||
enabled: () => !!form.value.courseTemplateId,
|
||||
})
|
||||
const selectedSession = ref(null)
|
||||
const sessionOptions = computed(() => {
|
||||
const base = sessionsResponse.value?.data ?? []
|
||||
if (selectedSession.value && !base.some((s) => s.id === selectedSession.value.id)) {
|
||||
return [...base, selectedSession.value]
|
||||
}
|
||||
return base
|
||||
})
|
||||
|
||||
const searchTemplates = useDebounce((q) => {
|
||||
templateSearch.value = q || ''
|
||||
}, 400)
|
||||
const searchSessions = useDebounce((q) => {
|
||||
sessionSearch.value = q || ''
|
||||
}, 400)
|
||||
|
||||
const onCourseChange = (value) => {
|
||||
form.value.courseTemplateId = value
|
||||
form.value.sessionId = ''
|
||||
selectedSession.value = null
|
||||
}
|
||||
|
||||
const { data: existingAssignment } = useAdminAssignmentQuery(assignmentId, {
|
||||
enabled: () => !!assignmentId.value,
|
||||
})
|
||||
|
||||
watch(existingAssignment, (assignment) => {
|
||||
if (!assignment) return
|
||||
const tpl = assignment.courseTemplate
|
||||
const sessionEntity = assignment.session
|
||||
if (tpl) selectedTemplate.value = tpl
|
||||
if (sessionEntity) selectedSession.value = sessionEntity
|
||||
form.value = {
|
||||
title: assignment.title || '',
|
||||
courseTemplateId: tpl?.id || assignment.courseTemplateId || '',
|
||||
sessionId: sessionEntity?.id || assignment.sessionId || '',
|
||||
startDate: assignment.startDate || '',
|
||||
endDate: assignment.endDate || '',
|
||||
priority: assignment.priority || 'mandatory',
|
||||
description: assignment.description || '',
|
||||
}
|
||||
attachments.value = Array.isArray(assignment.attachments)
|
||||
? assignment.attachments.map((file) => ({
|
||||
id: file.id,
|
||||
name: file.title || `فایل ${file.id}`,
|
||||
url: file.fileUrl || '',
|
||||
type: file.type || 'other',
|
||||
}))
|
||||
: []
|
||||
})
|
||||
|
||||
const addMutation = useAddAdminAssignmentMutation()
|
||||
const updateMutation = useUpdateAdminAssignmentMutation()
|
||||
|
||||
const submitting = computed(() => addMutation.isPending.value || updateMutation.isPending.value)
|
||||
|
||||
const onSubmit = async (close) => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
const finalPayload = {
|
||||
...payload,
|
||||
attachments: attachments.value.map((file, index) => ({
|
||||
fileId: file.id,
|
||||
type: file.type || 'other',
|
||||
title: file.name,
|
||||
order: index + 1,
|
||||
})),
|
||||
}
|
||||
if (isEditMode.value) {
|
||||
await updateMutation.mutateAsync({ id: assignmentId.value, payload: finalPayload })
|
||||
} else {
|
||||
await addMutation.mutateAsync(finalPayload)
|
||||
}
|
||||
await queryClient.invalidateQueries({ queryKey: adminAssignmentsKeys.all })
|
||||
resetErrors()
|
||||
close()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.add-assignment {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
padding: 0.5rem 0;
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
margin-block: 0.75rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__cell--full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
&__files {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.5rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
&__btn-submit {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,205 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="جزئیات تکلیف"
|
||||
title-en="Assignment Details"
|
||||
width="95%"
|
||||
max-width="60rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ close }">
|
||||
<div class="assignment-details">
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="3" :cols-per-row="1" />
|
||||
<template v-else-if="assignment">
|
||||
<div class="assignment-details__head">
|
||||
<p class="assignment-details__title">{{ assignment.title || '—' }}</p>
|
||||
<p class="assignment-details__sub">
|
||||
<span>
|
||||
دوره:
|
||||
{{ assignment.courseTemplate?.title || assignment.courseTemplateTitle || '—' }}
|
||||
</span>
|
||||
<span class="assignment-details__sep">|</span>
|
||||
<span>جلسه: {{ assignment.session?.title || assignment.sessionTitle || '—' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="assignment-details__grid">
|
||||
<LineInfoBlock
|
||||
title="تاریخ شروع"
|
||||
:numeric-desc="formatJalaaliDate(assignment.startDate) || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="تاریخ پایان"
|
||||
:numeric-desc="formatJalaaliDate(assignment.endDate) || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="مدت زمان"
|
||||
:numeric-desc="
|
||||
assignment.durationDays != null ? `${assignment.durationDays} روز` : '—'
|
||||
"
|
||||
/>
|
||||
<LineInfoBlock title="اولویت" :desc="ASSIGNMENT_PRIORITY[assignment.priority] || '—'" />
|
||||
<LineInfoBlock
|
||||
title="تعداد فرستندگان"
|
||||
:numeric-desc="assignment.submissionsCount ?? 0"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="تاریخ ثبت"
|
||||
:numeric-desc="
|
||||
assignment.faCreatedAt || formatJalaaliDate(assignment.createdAt) || '—'
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="assignment.description" class="assignment-details__desc">
|
||||
<LineInfoBlock title="توضیحات" :desc="assignment.description" />
|
||||
</div>
|
||||
|
||||
<div v-if="assignment.attachments?.length" class="assignment-details__attachments">
|
||||
<LineTitleBlock title="فایلهای تکلیف" title-en="Attachments" />
|
||||
<ul class="assignment-details__attachments-list">
|
||||
<li v-for="file in assignment.attachments" :key="file.id">
|
||||
<a
|
||||
:href="file.fileUrl || '#'"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="assignment-details__file"
|
||||
>
|
||||
<SvgIcon name="file" :size="16" color="var(--color-prim-gray)" />
|
||||
<span>{{ file.title || `فایل ${file.id}` }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
<NoItems v-else title="یافت نشد" desc="اطلاعات این تکلیف در دسترس نیست." />
|
||||
|
||||
<div class="assignment-details__divider" />
|
||||
|
||||
<div class="assignment-details__footer">
|
||||
<BaseButton text="بستن" custom-class="assignment-details__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { useAdminAssignmentQuery } from '@/services/query/admin-assignments'
|
||||
import { ASSIGNMENT_PRIORITY } from '@/enums'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'AssignmentDetailsModal' })
|
||||
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('AssignmentDetailsModal')?.data ?? {})
|
||||
const assignmentId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const { data: assignment, isLoading } = useAdminAssignmentQuery(assignmentId, {
|
||||
enabled: () => !!assignmentId.value,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.assignment-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__head {
|
||||
margin: 1rem 0 0.5rem;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1.1rem;
|
||||
font-weight: 500;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #535353;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: #c4c4c4;
|
||||
}
|
||||
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.25rem;
|
||||
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__desc,
|
||||
&__attachments {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
&__attachments-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
&__file {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
color: var(--color-primary);
|
||||
text-decoration: none;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 10rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+350
@@ -0,0 +1,350 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="55rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ close }">
|
||||
<div class="submission-details">
|
||||
<LineTitleBlock title="جزئیات تکلیف" title-en="Submission Details" />
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="3" :cols-per-row="1" />
|
||||
<template v-else-if="submission">
|
||||
<div class="submission-details__person">
|
||||
<div v-if="submission.user?.avatarUrl" class="submission-details__avatar">
|
||||
<img :src="submission.user.avatarUrl" :alt="userName" />
|
||||
</div>
|
||||
<div v-else class="submission-details__avatar submission-details__avatar--placeholder">
|
||||
<SvgIcon name="user" :size="32" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="submission-details__person-grid">
|
||||
<LineInfoBlock title="نام و نام خانوادگی" :desc="userName" />
|
||||
<LineInfoBlock
|
||||
title="وضعیت تحصیلی"
|
||||
:desc="EDUCATION_STATUS[submission.user?.profile?.educationStatus] || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="آخرین مدرک تحصیلی (طلبه)"
|
||||
:desc="SEMINARY_LEVEL[submission.user?.profile?.seminaryLevel] || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="آخرین مدرک تحصیلی"
|
||||
:desc="UNIVERSITY_LEVEL[submission.user?.profile?.universityLevel] || '—'"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="submission-details__assignment">
|
||||
<p class="submission-details__assignment-title">{{ assignmentTitle }}</p>
|
||||
<div class="submission-details__assignment-meta">
|
||||
<span>ترم: {{ submission.termTitle || '—' }}</span>
|
||||
<span class="submission-details__sep">|</span>
|
||||
<span>دوره: {{ submission.courseTemplateTitle || '—' }}</span>
|
||||
<span class="submission-details__sep">|</span>
|
||||
<span>جلسه: {{ submission.sessionTitle || '—' }}</span>
|
||||
<span class="submission-details__sep">|</span>
|
||||
<span>تاریخ: {{ submittedAt }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="submission-details__row">
|
||||
<LineInfoBlock title="پاسخ دانشجو" :desc="submission.userDescription || '—'" />
|
||||
</div>
|
||||
|
||||
<div v-if="submission.attachments?.length" class="submission-details__attachments">
|
||||
<p class="submission-details__attachments-title">فایلهای ارسالی</p>
|
||||
<ul>
|
||||
<li v-for="file in submission.attachments" :key="file.id">
|
||||
<a
|
||||
:href="file.fileUrl || '#'"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="submission-details__file"
|
||||
>
|
||||
<SvgIcon name="file" :size="16" color="var(--color-prim-gray)" />
|
||||
<span>{{ file.title || `فایل ${file.id}` }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<form class="submission-details__review" @submit.prevent="onSubmit(close)">
|
||||
<div class="submission-details__review-grid">
|
||||
<TextField
|
||||
v-model="form.score"
|
||||
name="score"
|
||||
label="نمره"
|
||||
inputmode="numeric"
|
||||
:convert-digits="true"
|
||||
:error="errors.score"
|
||||
@blur="validateAt('score', form.score)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="check" :size="18" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
<SelectField
|
||||
v-model="form.status"
|
||||
name="status"
|
||||
label="وضعیت"
|
||||
:options="statusOptions"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:error="errors.status"
|
||||
/>
|
||||
</div>
|
||||
<TextareaField
|
||||
v-model="form.reviewerNote"
|
||||
name="reviewerNote"
|
||||
label="بازخورد"
|
||||
:row="4"
|
||||
/>
|
||||
|
||||
<div class="submission-details__divider" />
|
||||
|
||||
<div class="submission-details__actions">
|
||||
<BaseButton
|
||||
variant="transparent"
|
||||
text="بستن"
|
||||
custom-class="submission-details__btn-cancel"
|
||||
@click="close"
|
||||
/>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
text="ثبت بازخورد"
|
||||
:loading="reviewMutation.isPending.value"
|
||||
custom-class="submission-details__btn-submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
<NoItems v-else title="موردی یافت نشد" desc="جزئیات این تکلیف در دسترس نیست." />
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import SelectField from '@/components/form/SelectField.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import useYup from '@/composables/useYup'
|
||||
import {
|
||||
adminAssignmentsKeys,
|
||||
useAdminAssignmentSubmissionQuery,
|
||||
useReviewAdminAssignmentSubmissionMutation,
|
||||
} from '@/services/query/admin-assignments'
|
||||
import { EDUCATION_STATUS, SEMINARY_LEVEL, UNIVERSITY_LEVEL } from '@/enums'
|
||||
import { assignmentSubmissionReviewSchema } from '@/features/admin/assignments/schema'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'AssignmentSubmissionDetailsModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('AssignmentSubmissionDetailsModal')?.data ?? {})
|
||||
const assignmentId = computed(() => modalData.value.assignmentId ?? null)
|
||||
const submissionId = computed(() => modalData.value.submissionId ?? null)
|
||||
|
||||
const { data: fetched, isLoading } = useAdminAssignmentSubmissionQuery(assignmentId, submissionId, {
|
||||
enabled: () => !!assignmentId.value && !!submissionId.value,
|
||||
})
|
||||
|
||||
const submission = computed(() => fetched.value || modalData.value.submission || null)
|
||||
|
||||
const userName = computed(() => {
|
||||
const u = submission.value?.user
|
||||
if (!u) return '—'
|
||||
return `${u.firstName || ''} ${u.lastName || ''}`.trim() || u.fullName || '—'
|
||||
})
|
||||
|
||||
const assignmentTitle = computed(
|
||||
() => submission.value?.assignment?.title || modalData.value.assignmentTitle || '—'
|
||||
)
|
||||
|
||||
const submittedAt = computed(
|
||||
() => submission.value?.faSubmittedAt || formatJalaaliDate(submission.value?.submittedAt) || '—'
|
||||
)
|
||||
|
||||
const statusOptions = [
|
||||
{ value: 'pending', label: 'در انتظار بررسی' },
|
||||
{ value: 'approved', label: 'تایید شده' },
|
||||
{ value: 'rejected', label: 'رد شده' },
|
||||
{ value: 'needs_revision', label: 'نیازمند اصلاح' },
|
||||
]
|
||||
|
||||
const schema = assignmentSubmissionReviewSchema
|
||||
|
||||
const { validate, validateAt, errors } = useYup(schema)
|
||||
|
||||
const form = ref({ score: '', status: 'approved', reviewerNote: '' })
|
||||
|
||||
watch(submission, (sub) => {
|
||||
if (!sub) return
|
||||
form.value = {
|
||||
score: sub.score ?? '',
|
||||
status: sub.status || 'approved',
|
||||
reviewerNote: sub.reviewerNote || '',
|
||||
}
|
||||
})
|
||||
|
||||
const reviewMutation = useReviewAdminAssignmentSubmissionMutation()
|
||||
|
||||
const onSubmit = async (close) => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
await reviewMutation.mutateAsync({
|
||||
assignmentId: assignmentId.value,
|
||||
submissionId: submissionId.value,
|
||||
payload,
|
||||
})
|
||||
await queryClient.invalidateQueries({ queryKey: adminAssignmentsKeys.all })
|
||||
close()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.submission-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__person {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
margin: 1rem 0 1.25rem;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 4.9rem;
|
||||
height: 4.9rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
background: #f5f5f5;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__person-grid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.25rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__assignment {
|
||||
border-inline-end: 3px solid #ebebeb;
|
||||
padding-inline-end: 0.875rem;
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
&__assignment-title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__assignment-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__sep {
|
||||
color: #d6d6d6;
|
||||
}
|
||||
|
||||
&__row {
|
||||
margin-block: 0.5rem;
|
||||
}
|
||||
|
||||
&__attachments {
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
&__attachments-title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
color: var(--color-prim-gray);
|
||||
margin: 0 0 0.5rem;
|
||||
}
|
||||
|
||||
&__file {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
color: var(--color-primary);
|
||||
text-decoration: none;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
padding: 0.25rem 0;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
&__review {
|
||||
margin-top: 1.25rem;
|
||||
}
|
||||
|
||||
&__review-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
&__btn-submit {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,237 @@
|
||||
<template>
|
||||
<BasicModal width="95%" max-width="60rem" min-width="auto" :show-close-button="true">
|
||||
<template #default="{ data, close }">
|
||||
<div class="assignment-submissions">
|
||||
<LineTitleBlock title="تکالیف فرستادگان" title-en="Delegates’ Submissions" />
|
||||
<p v-if="data?.title" class="assignment-submissions__assignment">{{ data.title }}</p>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="4" :cols-per-row="1" />
|
||||
<div v-else-if="submissions.length > 0" class="assignment-submissions__list">
|
||||
<div
|
||||
v-for="submission in submissions"
|
||||
:key="submission.id"
|
||||
class="assignment-submissions__row"
|
||||
>
|
||||
<div class="assignment-submissions__user">
|
||||
<div v-if="submission.user?.avatarUrl" class="assignment-submissions__avatar">
|
||||
<img :src="submission.user.avatarUrl" :alt="userName(submission.user)" />
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="assignment-submissions__avatar assignment-submissions__avatar--placeholder"
|
||||
>
|
||||
<SvgIcon name="user" :size="20" color="#bcbcbc" />
|
||||
</div>
|
||||
<div>
|
||||
<p class="assignment-submissions__name">{{ userName(submission.user) }}</p>
|
||||
<p class="assignment-submissions__location">
|
||||
{{ locationFromAddress(submission.user) || '—' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="assignment-submissions__pill">
|
||||
<span class="assignment-submissions__pill-label">تاریخ ارسال:</span>
|
||||
<span class="assignment-submissions__pill-value">{{ submittedAt(submission) }}</span>
|
||||
</div>
|
||||
|
||||
<BaseButton
|
||||
text="جزئیات"
|
||||
custom-class="assignment-submissions__details-btn"
|
||||
@click="onShowDetails(submission)"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="caret-left" :size="14" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
<NoItems v-else title="موردی یافت نشد" desc="تکلیفی ارسال نشده است." />
|
||||
|
||||
<PaginationBlock :pagination="paginationMeta" @update:page="setPage" />
|
||||
|
||||
<div class="assignment-submissions__divider" />
|
||||
|
||||
<div class="assignment-submissions__footer">
|
||||
<BaseButton text="بستن" custom-class="assignment-submissions__close-btn" @click="close">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import PaginationBlock from '@/components/blocks/PaginationBlock.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { usePagination } from '@/composables/usePagination'
|
||||
import { useAdminAssignmentSubmissionsQuery } from '@/services/query/admin-assignments'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'AssignmentSubmissionsModal' })
|
||||
|
||||
const { getModal, openModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('AssignmentSubmissionsModal')?.data ?? {})
|
||||
const assignmentId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const filters = ref({})
|
||||
const { pagination, setPage } = usePagination({ page: 1, perPage: 10 })
|
||||
|
||||
const { data, isLoading } = useAdminAssignmentSubmissionsQuery(assignmentId, filters, pagination, {
|
||||
enabled: () => !!assignmentId.value,
|
||||
keepPreviousData: true,
|
||||
})
|
||||
|
||||
const submissions = computed(() => data.value?.data ?? [])
|
||||
const paginationMeta = computed(() => ({
|
||||
page: pagination.value.page,
|
||||
perPage: pagination.value.perPage,
|
||||
...data.value?.meta,
|
||||
}))
|
||||
|
||||
const userName = (user) =>
|
||||
`${user?.firstName || ''} ${user?.lastName || ''}`.trim() || user?.fullName || '—'
|
||||
|
||||
const locationFromAddress = (user) => {
|
||||
const province = user?.address?.province?.name || ''
|
||||
const city = user?.address?.city?.name || ''
|
||||
return [province, city].filter(Boolean).join('، ')
|
||||
}
|
||||
|
||||
const submittedAt = (sub) => sub.faSubmittedAt || formatJalaaliDate(sub.submittedAt) || '—'
|
||||
|
||||
const onShowDetails = (submission) => {
|
||||
openModal('AssignmentSubmissionDetailsModal', {
|
||||
assignmentId: assignmentId.value,
|
||||
submissionId: submission.id,
|
||||
submission,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.assignment-submissions {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__assignment {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
color: var(--color-prim-gray);
|
||||
margin: 0 0 0.75rem;
|
||||
}
|
||||
|
||||
&__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: rgba(255, 255, 255, 60%);
|
||||
border-radius: 0.875rem;
|
||||
box-shadow: 0 4px 10px -6px rgba(241, 241, 241, 70%);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&__user {
|
||||
flex: 1 1 40%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 2.75rem;
|
||||
height: 2.75rem;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
background: #f5f5f5;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&--placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__location {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
color: #989898;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__pill {
|
||||
background: rgba(107, 107, 107, 5%);
|
||||
border-radius: 0.875rem;
|
||||
padding: 0.375rem 1rem;
|
||||
text-align: center;
|
||||
min-width: 9rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__pill-label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
margin-inline-end: 0.25rem;
|
||||
}
|
||||
|
||||
&__pill-value {
|
||||
font-family: var(--font-family-en);
|
||||
font-size: 0.7rem;
|
||||
color: #535353;
|
||||
}
|
||||
|
||||
&__details-btn {
|
||||
min-width: 5rem;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1.25rem;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&__close-btn {
|
||||
min-width: 12rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user