fix: test

This commit is contained in:
sajjadtalkhabi
2026-05-28 15:40:22 +03:30
parent fc0aa2586e
commit 3f3c66a02d
25 changed files with 406 additions and 104 deletions
@@ -14,12 +14,9 @@
<div class="assignment-details__head">
<p class="assignment-details__title">{{ assignment.title || '—' }}</p>
<p class="assignment-details__sub">
<span>
دوره:
{{ assignment.course?.title || assignment.courseTitle || '—' }}
</span>
<span>دوره: {{ courseTitle }}</span>
<span class="assignment-details__sep">|</span>
<span>جلسه: {{ assignment.session?.title || assignment.sessionTitle || '—' }}</span>
<span>جلسه: {{ sessionTitle }}</span>
</p>
</div>
@@ -28,21 +25,10 @@
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="deadlineLabel" />
<LineInfoBlock title="مدت زمان" :numeric-desc="durationLabel" />
<LineInfoBlock title="اولویت" :desc="priorityLabel" />
<LineInfoBlock title="تعداد فرستندگان" :numeric-desc="submittersLabel" />
<LineInfoBlock
title="تاریخ ثبت"
:numeric-desc="
@@ -55,18 +41,18 @@
<LineInfoBlock title="توضیحات" :desc="assignment.description" />
</div>
<div v-if="assignment.attachments?.length" class="assignment-details__attachments">
<div v-if="attachmentItems.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">
<li v-for="file in attachmentItems" :key="file.id">
<a
:href="file.fileUrl || '#'"
:href="file.url || '#'"
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>
<span>{{ file.title }}</span>
</a>
</li>
</ul>
@@ -112,6 +98,65 @@ const assignmentId = computed(() => modalData.value.id ?? null)
const { data: assignment, isLoading } = useAdminAssignmentQuery(assignmentId, {
enabled: () => !!assignmentId.value,
})
const courseTitle = computed(
() =>
assignment.value?.session?.course?.title ||
assignment.value?.course?.title ||
assignment.value?.courseTitle ||
'—'
)
const sessionTitle = computed(
() => assignment.value?.session?.title || assignment.value?.sessionTitle || '—'
)
const deadlineRaw = computed(() => assignment.value?.endDate || assignment.value?.deadline || '')
const deadlineLabel = computed(() => formatJalaaliDate(deadlineRaw.value) || '—')
const durationLabel = computed(() => {
if (assignment.value?.durationDays != null) return `${assignment.value.durationDays} روز`
const start = assignment.value?.startDate || assignment.value?.createdAt
const end = deadlineRaw.value
if (!start || !end) return '—'
const diff = Math.ceil((new Date(end).getTime() - new Date(start).getTime()) / 86_400_000)
return diff >= 0 ? `${diff} روز` : '—'
})
const priorityLabel = computed(() => {
const priority =
assignment.value?.priority ||
(typeof assignment.value?.isPriority === 'boolean'
? assignment.value.isPriority
? 'mandatory'
: 'optional'
: null)
return ASSIGNMENT_PRIORITY[priority] || '—'
})
const submittersLabel = computed(
() => assignment.value?.submittersCount ?? assignment.value?.submissionsCount ?? 0
)
const attachmentItems = computed(() => {
const media = assignment.value?.media
if (Array.isArray(media) && media.length > 0) {
return media.map((m) => ({
id: m.id,
title: m.fileName || `فایل ${m.id}`,
url: m.url || m.downloadUrl || '',
}))
}
const legacy = assignment.value?.attachments
if (Array.isArray(legacy)) {
return legacy.map((a) => ({
id: a.id,
title: a.title || `فایل ${a.id}`,
url: a.fileUrl || '',
}))
}
return []
})
</script>
<style lang="scss" scoped>