first commit
This commit is contained in:
@@ -0,0 +1,295 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
title="جزئیات کاربر"
|
||||
title-en="User details"
|
||||
width="95%"
|
||||
max-width="70rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ close }">
|
||||
<div class="user-details">
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="4" :cols-per-row="1" />
|
||||
|
||||
<template v-else-if="user">
|
||||
<div class="user-details__section">
|
||||
<div v-if="isStudent && !user.profileCompleted" class="user-details__notice">
|
||||
<SvgIcon name="warning" :size="20" color="var(--color-primary)" />
|
||||
<span>اطلاعات ثبت نام این دانشجو کامل نیست.</span>
|
||||
</div>
|
||||
|
||||
<div class="user-details__head">
|
||||
<div class="user-details__avatar">
|
||||
<img v-if="user.avatarUrl" :src="user.avatarUrl" :alt="fullName" />
|
||||
<SvgIcon v-else name="user" :size="48" color="#cbd5e1" />
|
||||
</div>
|
||||
<div class="user-details__identity">
|
||||
<div class="user-details__status" :class="statusModifier">
|
||||
<span class="user-details__status-dot" />
|
||||
<span>{{ user.status === 'blocked' ? 'غیر فعال' : 'فعال' }}</span>
|
||||
</div>
|
||||
<p class="user-details__label">نام و نام خانوادگی</p>
|
||||
<p class="user-details__name">{{ fullName || '—' }}</p>
|
||||
<p class="user-details__role">
|
||||
<span class="user-details__role-key">نقش:</span>
|
||||
<span class="user-details__role-val">{{ roleText }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="user-details__grid">
|
||||
<LineInfoBlock
|
||||
title="تاریخ تولد"
|
||||
:numeric-desc="user.faBirthDate || formatJalaaliDate(user.birthDate) || '—'"
|
||||
/>
|
||||
<LineInfoBlock title="شماره تماس" :numeric-desc="user.phoneNumber || '—'" />
|
||||
<LineInfoBlock title="کد ملی" :numeric-desc="user.nationalCode || '—'" />
|
||||
<LineInfoBlock title="وضعیت تاهل" :desc="MARITAL_STATUS[user.maritalStatus] || '—'" />
|
||||
<LineInfoBlock title="جنسیت" :desc="GENDER[user.gender] || '—'" />
|
||||
<LineInfoBlock title="استان" :desc="user.address?.province?.name || '—'" />
|
||||
<LineInfoBlock title="شهر" :desc="user.address?.city?.name || '—'" />
|
||||
</div>
|
||||
|
||||
<LineInfoBlock title="آدرس" :desc="user.address?.address || '—'" />
|
||||
<LineInfoBlock title="بیوگرافی" :desc="user.bio || '—'" />
|
||||
</div>
|
||||
|
||||
<div v-if="isStudent && user.profileCompleted" class="user-details__section">
|
||||
<LineTitleBlock title="اطلاعات تحصیلی و شغلی" title-en="Academic information" />
|
||||
<div class="user-details__grid">
|
||||
<LineInfoBlock
|
||||
title="وضعیت تحصیلی"
|
||||
:desc="EDUCATION_STATUS[user.educationStatus] || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="آخرین مدرک حوزوی"
|
||||
:desc="SEMINARY_LEVEL[user.seminaryLevel] || '—'"
|
||||
/>
|
||||
<LineInfoBlock
|
||||
title="آخرین مدرک دانشگاهی"
|
||||
:desc="UNIVERSITY_LEVEL[user.universityLevel] || '—'"
|
||||
/>
|
||||
<LineInfoBlock title="نام حوزه/دانشگاه" :desc="user.universityName || '—'" />
|
||||
</div>
|
||||
<LineInfoBlock title="گرایش/رشته تحصیلی" :desc="user.fieldOfStudy || '—'" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<NoItems v-else title="یافت نشد" desc="اطلاعات این کاربر در دسترس نیست." />
|
||||
|
||||
<div class="user-details__divider" />
|
||||
<div class="user-details__footer">
|
||||
<BaseButton text="تایید" custom-class="user-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 { useAdminUserQuery } from '@/services/query/admin-users'
|
||||
import {
|
||||
EDUCATION_STATUS,
|
||||
GENDER,
|
||||
MARITAL_STATUS,
|
||||
ROLE_LABELS,
|
||||
SEMINARY_LEVEL,
|
||||
UNIVERSITY_LEVEL,
|
||||
} from '@/enums'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
|
||||
defineOptions({ name: 'UserDetailsModal' })
|
||||
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('UserDetailsModal')?.data ?? {})
|
||||
const userId = computed(() => modalData.value.id ?? null)
|
||||
|
||||
const { data: user, isLoading } = useAdminUserQuery(userId, {
|
||||
enabled: () => !!userId.value,
|
||||
})
|
||||
|
||||
const fullName = computed(() =>
|
||||
`${user.value?.firstName || ''} ${user.value?.lastName || ''}`.trim()
|
||||
)
|
||||
|
||||
const roleName = computed(() => {
|
||||
const first = user.value?.roles?.[0]
|
||||
return typeof first === 'string' ? first : first?.name
|
||||
})
|
||||
|
||||
const roleText = computed(() => {
|
||||
const name = roleName.value
|
||||
return name ? ROLE_LABELS[name] || name : 'بدون نقش'
|
||||
})
|
||||
|
||||
const isStudent = computed(() => roleName.value === 'student')
|
||||
|
||||
const statusModifier = computed(() =>
|
||||
user.value?.status === 'blocked'
|
||||
? 'user-details__status--blocked'
|
||||
: 'user-details__status--active'
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.user-details {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
|
||||
&__section {
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
&__notice {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 1rem;
|
||||
margin-bottom: 0.625rem;
|
||||
border-radius: 0.5rem;
|
||||
background-color: rgba(var(--color-primary-rgb, 0, 0, 0), 5%);
|
||||
color: var(--color-primary);
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.875rem;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
width: 5rem;
|
||||
height: 5rem;
|
||||
border-radius: 9999px;
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
&__identity {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.125rem;
|
||||
}
|
||||
|
||||
&__status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.7rem;
|
||||
|
||||
&--active {
|
||||
color: #35c245;
|
||||
|
||||
.user-details__status-dot {
|
||||
background-color: #35c245;
|
||||
}
|
||||
}
|
||||
|
||||
&--blocked {
|
||||
color: var(--color-error);
|
||||
|
||||
.user-details__status-dot {
|
||||
background-color: var(--color-error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__status-dot {
|
||||
width: 0.5rem;
|
||||
height: 0.5rem;
|
||||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
color: #b7b7b7;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.95rem;
|
||||
font-weight: 500;
|
||||
color: #4b4b4b;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__role {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
margin: 0.25rem 0 0;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 0.375rem;
|
||||
background-color: rgba(0, 0, 0, 4%);
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
&__role-key {
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
&__role-val {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&__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);
|
||||
}
|
||||
}
|
||||
|
||||
&__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>
|
||||
Reference in New Issue
Block a user