Files
banu-front/src/features/admin/assignments/components/AssignmentItem.vue
T
sajjadtalkhabi 74227d5021 fix
2026-05-21 15:51:32 +03:30

204 lines
5.2 KiB
Vue

<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.course?.title || assignment.courseTitle || '—' }}
</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 SvgIcon from '@/components/icons/SvgIcon.vue'
import { formatJalaaliDate } from '@/utils/date-utils'
import CircleButton from '@/components/CircleButton.vue'
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>