Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 55ed80e652 | |||
| bdb77786f2 | |||
| d227b1c8f4 | |||
| fdc52381db | |||
| c0fe9e9918 | |||
| 8743d37a7d | |||
| fc1c249033 |
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="course-item">
|
||||
<div class="course-item__main">
|
||||
<div v-if="course.image" class="course-item__image">
|
||||
<img :src="course.image" :alt="course.title" />
|
||||
<div v-if="course.coverUrl" class="course-item__image">
|
||||
<img :src="course.coverUrl" :alt="course.title" />
|
||||
</div>
|
||||
<div v-else class="course-item__image course-item__image--placeholder">
|
||||
<SvgIcon name="book" :size="22" color="#bcbcbc" />
|
||||
@@ -30,14 +30,13 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="course-item__actions">
|
||||
<div v-if="!isActive" class="course-item__status">
|
||||
<span class="course-item__status-badge">
|
||||
<span class="course-item__status-dot" />
|
||||
غیرفعال
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="course-item__actions">
|
||||
<ToggleSwitch
|
||||
:model-value="!!isActive"
|
||||
@update:model-value="emit('change-status', { id: course.id, isActive: !isActive })"
|
||||
@@ -192,10 +191,6 @@ const isActive = computed(() => props.course.isActive ?? false)
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&__status {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
&__status-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -217,6 +212,7 @@ const isActive = computed(() => props.course.isActive ?? false)
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
|
||||
@@ -154,7 +154,7 @@ const form = ref({
|
||||
templateId: '',
|
||||
title: '',
|
||||
capacity: '',
|
||||
imageId: null,
|
||||
coverMediaId: null,
|
||||
isActive: false,
|
||||
})
|
||||
|
||||
@@ -212,10 +212,10 @@ watch(existingCourse, (course) => {
|
||||
templateId: '',
|
||||
title: course.title || '',
|
||||
capacity: course.capacity ?? '',
|
||||
imageId: course.imageId || null,
|
||||
coverMediaId: course.coverMediaId || null,
|
||||
isActive: course.isActive ?? false,
|
||||
}
|
||||
if (course.image) image.value = { url: course.image }
|
||||
if (course.coverUrl) image.value = { url: course.coverUrl }
|
||||
})
|
||||
|
||||
const uploadMutation = useUploadMediaMutation()
|
||||
@@ -225,8 +225,8 @@ const onImageCropped = async (file) => {
|
||||
const formData = objectToFormData({ file, purpose: 'cover', context: 'course' })
|
||||
const response = await uploadMutation.mutateAsync(formData)
|
||||
const payload = response?.data ?? response
|
||||
image.value = { url: payload?.url, uploadId: payload?.uploadId, ...payload }
|
||||
form.value.imageId = payload?.uploadId || payload?.id
|
||||
image.value = { url: payload?.url, ...payload }
|
||||
form.value.coverMediaId = payload?.id
|
||||
} catch {
|
||||
/* handled globally */
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<template v-else-if="course">
|
||||
<div class="course-details__hero">
|
||||
<div class="course-details__image">
|
||||
<img v-if="course.image" :src="course.image" :alt="course.title" />
|
||||
<img v-if="course.coverUrl" :src="course.coverUrl" :alt="course.title" />
|
||||
<SvgIcon v-else name="book" :size="32" color="#bcbcbc" />
|
||||
</div>
|
||||
<div class="course-details__grid">
|
||||
|
||||
@@ -24,6 +24,6 @@ export const offeredCourseSchema = object().shape({
|
||||
.required()
|
||||
.integer('ظرفیت باید عدد صحیح باشد')
|
||||
.min(1, 'ظرفیت باید حداقل ۱ نفر باشد'),
|
||||
imageId: string().nullable().notRequired(),
|
||||
coverMediaId: number().typeError('شناسه تصویر دوره باید عدد باشد').nullable().notRequired(),
|
||||
isActive: boolean().nullable().notRequired(),
|
||||
})
|
||||
|
||||
@@ -241,6 +241,17 @@ export default [
|
||||
subtitle: 'لیست خدمات را مشاهده و مدیریت نمایید.',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/service-types',
|
||||
name: 'admin-service-types',
|
||||
component: () => import('@/features/admin/services/pages/ServiceTypesPage.vue'),
|
||||
meta: {
|
||||
layout: 'admin',
|
||||
role: 'admin',
|
||||
title: 'مرکز خدمات',
|
||||
subtitle: 'انواع خدمات قابل درخواست توسط کاربران را مدیریت کنید.',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/consultations',
|
||||
name: 'admin-consultations',
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<div class="service-type-item">
|
||||
<div class="service-type-item__main">
|
||||
<p class="service-type-item__title">{{ serviceType.title }}</p>
|
||||
<p class="service-type-item__desc">{{ serviceType.description || '—' }}</p>
|
||||
</div>
|
||||
|
||||
<div class="service-type-item__actions">
|
||||
<CircleButton
|
||||
tooltip="ویرایش"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('edit', serviceType)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="pencil" :size="18" color="var(--color-primary)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
<CircleButton
|
||||
tooltip="حذف"
|
||||
bg-color="rgba(104, 104, 104, 0.05)"
|
||||
size="2.5rem"
|
||||
@click="emit('delete', serviceType)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="trash" :size="18" color="var(--color-error)" />
|
||||
</template>
|
||||
</CircleButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import CircleButton from '@/components/CircleButton.vue'
|
||||
|
||||
defineProps({
|
||||
serviceType: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['edit', 'delete'])
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.service-type-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
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;
|
||||
|
||||
&__main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1rem;
|
||||
color: #4b4b4b;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
|
||||
&__desc {
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.8125rem;
|
||||
color: #848484;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,138 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
:title="isEditMode ? 'ویرایش نوع خدمت' : 'افزودن نوع خدمت'"
|
||||
title-en="Service Type"
|
||||
width="95%"
|
||||
max-width="40rem"
|
||||
min-width="auto"
|
||||
:show-close-button="true"
|
||||
>
|
||||
<template #default="{ close }">
|
||||
<form class="service-type-form" @submit.prevent="onSubmit(close)">
|
||||
<TextField
|
||||
v-model="form.title"
|
||||
name="title"
|
||||
label="عنوان نوع خدمت"
|
||||
placeholder="مثال: خدمات رفاهی"
|
||||
:error="errors.title"
|
||||
@blur="validateAt('title', form.title)"
|
||||
/>
|
||||
|
||||
<TextareaField
|
||||
v-model="form.description"
|
||||
name="description"
|
||||
label="توضیحات"
|
||||
placeholder="توضیح کوتاهی درباره این نوع خدمت بنویسید"
|
||||
:row="4"
|
||||
:error="errors.description"
|
||||
/>
|
||||
|
||||
<div class="service-type-form__divider" />
|
||||
|
||||
<div class="service-type-form__actions">
|
||||
<BaseButton
|
||||
variant="transparent"
|
||||
text="منصرف شدم"
|
||||
custom-class="service-type-form__btn-cancel"
|
||||
@click="close"
|
||||
>
|
||||
<template #prependIcon>
|
||||
<SvgIcon name="caret-right" :size="14" color="var(--color-sec-gray)" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
:text="isEditMode ? 'ذخیره تغییرات' : 'افزودن'"
|
||||
:loading="submitting"
|
||||
custom-class="service-type-form__btn-submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import useYup from '@/composables/useYup'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import { serviceTypeSchema } from '@/features/admin/services/schema/service-type'
|
||||
import {
|
||||
serviceTypesKeys,
|
||||
useAddServiceTypeMutation,
|
||||
useUpdateServiceTypeMutation,
|
||||
} from '@/services/query/service-types'
|
||||
|
||||
defineOptions({ name: 'ServiceTypeFormModal' })
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { getModal } = useModal()
|
||||
|
||||
const modalData = computed(() => getModal('ServiceTypeFormModal')?.data ?? {})
|
||||
const editingServiceType = computed(() => modalData.value.serviceType ?? null)
|
||||
const isEditMode = computed(() => !!editingServiceType.value)
|
||||
|
||||
const form = ref({
|
||||
title: editingServiceType.value?.title ?? '',
|
||||
description: editingServiceType.value?.description ?? '',
|
||||
})
|
||||
|
||||
const { validate, validateAt, errors } = useYup(serviceTypeSchema)
|
||||
|
||||
const addMutation = useAddServiceTypeMutation()
|
||||
const updateMutation = useUpdateServiceTypeMutation()
|
||||
const submitting = computed(() => addMutation.isPending.value || updateMutation.isPending.value)
|
||||
|
||||
const onSubmit = async (close) => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
|
||||
if (isEditMode.value) {
|
||||
await updateMutation.mutateAsync({ id: editingServiceType.value.id, payload })
|
||||
} else {
|
||||
await addMutation.mutateAsync(payload)
|
||||
}
|
||||
await queryClient.invalidateQueries({ queryKey: serviceTypesKeys.all })
|
||||
close()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.service-type-form {
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
padding: 0.5rem 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
|
||||
&__divider {
|
||||
border-block-end: 1px solid var(--color-thd-gray);
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
&__btn-cancel {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
&__btn-submit {
|
||||
min-width: 10rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,4 +1,6 @@
|
||||
export { default as SendMessageModal } from './components/modals/SendMessageModal.vue'
|
||||
export { default as ServiceDetailsModal } from './components/modals/ServiceDetailsModal.vue'
|
||||
export { default as ServiceTypeFormModal } from './components/modals/ServiceTypeFormModal.vue'
|
||||
export { default as ServiceItem } from './components/ServiceItem.vue'
|
||||
export { default as ServiceTypeItem } from './components/ServiceTypeItem.vue'
|
||||
export { default as ServicesFilters } from './components/ServicesFilters.vue'
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<div class="service-types-page">
|
||||
<BoxedIconTitleBlock
|
||||
class="service-types-page__heading"
|
||||
title="انواع خدمات"
|
||||
desc="در این قسمت میتوانید نوعهای خدمت قابل درخواست توسط کاربران را تعریف کنید."
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon name="users-three" :size="24" color="var(--color-primary)" />
|
||||
</template>
|
||||
</BoxedIconTitleBlock>
|
||||
|
||||
<div class="service-types-page__list-header">
|
||||
<SimpleTitleIconBlock title="لیست انواع خدمات" class="service-types-page__list-title">
|
||||
<template #header-icon>
|
||||
<SvgIcon name="list-bullets" :size="16" color="#bcbcbc" />
|
||||
</template>
|
||||
</SimpleTitleIconBlock>
|
||||
<BaseButton text="افزودن نوع خدمت" custom-class="service-types-page__add-btn" @click="onAdd">
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="plus" :size="18" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="4" :cols-per-row="1" />
|
||||
<div v-else-if="serviceTypes.length > 0">
|
||||
<ServiceTypeItem
|
||||
v-for="serviceType in serviceTypes"
|
||||
:key="serviceType.id"
|
||||
:service-type="serviceType"
|
||||
@edit="onEdit"
|
||||
@delete="onAskDelete"
|
||||
/>
|
||||
</div>
|
||||
<NoItems v-else title="موردی نیست" desc="هنوز هیچ نوع خدمتی تعریف نشده است." />
|
||||
|
||||
<ServiceTypeFormModal v-if="isModal('ServiceTypeFormModal')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import useModal from '@/composables/useModal'
|
||||
import { useQueryClient } from '@tanstack/vue-query'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import BoxedIconTitleBlock from '@/components/blocks/BoxedIconTitleBlock.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import SimpleTitleIconBlock from '@/components/blocks/SimpleTitleIconBlock.vue'
|
||||
import ServiceTypeItem from '@/features/admin/services/components/ServiceTypeItem.vue'
|
||||
import ServiceTypeFormModal from '@/features/admin/services/components/modals/ServiceTypeFormModal.vue'
|
||||
import {
|
||||
serviceTypesKeys,
|
||||
useServiceTypesListQuery,
|
||||
useDeleteServiceTypeMutation,
|
||||
} from '@/services/query/service-types'
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { openModal, isModal } = useModal()
|
||||
|
||||
const { data, isLoading } = useServiceTypesListQuery()
|
||||
const serviceTypes = computed(() => data.value ?? [])
|
||||
|
||||
const onAdd = () => openModal('ServiceTypeFormModal')
|
||||
const onEdit = (serviceType) => openModal('ServiceTypeFormModal', { serviceType })
|
||||
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: serviceTypesKeys.all })
|
||||
const deleteMutation = useDeleteServiceTypeMutation()
|
||||
|
||||
const onAskDelete = (serviceType) => {
|
||||
openModal('ConfirmModal', {
|
||||
title: `حذف نوع خدمت «${serviceType.title}»`,
|
||||
message:
|
||||
'بعد از حذف امکان بازگشت وجود ندارد، آیا مطمئن هستید که میخواهید این نوع خدمت را حذف کنید؟',
|
||||
onConfirm: () => deleteMutation.mutate(serviceType.id, { onSuccess: invalidate }),
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.service-types-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
&__heading {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
&__list-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
margin-bottom: 0.375rem;
|
||||
}
|
||||
|
||||
&__list-title {
|
||||
flex: 1;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&__add-btn {
|
||||
min-width: fit-content;
|
||||
padding: 0 1.25rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,6 @@
|
||||
import { object, string } from 'yup'
|
||||
|
||||
export const serviceTypeSchema = object().shape({
|
||||
title: string().trim().required('عنوان نوع خدمت را وارد کنید').max(255, 'عنوان طولانی است'),
|
||||
description: string().trim().nullable().notRequired().max(2000, 'توضیحات طولانی است'),
|
||||
})
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="course-item">
|
||||
<div class="course-item__main">
|
||||
<div v-if="course.image" class="course-item__image">
|
||||
<img :src="course.image" :alt="course.title" />
|
||||
<div v-if="course.coverUrl" class="course-item__image">
|
||||
<img :src="course.coverUrl" :alt="course.title" />
|
||||
</div>
|
||||
<div v-else class="course-item__image course-item__image--placeholder">
|
||||
<SvgIcon name="book" :size="22" color="#bcbcbc" />
|
||||
|
||||
@@ -0,0 +1,392 @@
|
||||
<template>
|
||||
<div class="user-evaluation">
|
||||
<div class="user-evaluation__header">
|
||||
<LineTitleBlock
|
||||
class="user-evaluation__title"
|
||||
title="سیستم ارزیابی کاربر"
|
||||
title-en="User Evaluation System"
|
||||
/>
|
||||
<BaseButton
|
||||
text="دانلود PDF"
|
||||
:loading="pdfLoading"
|
||||
:disabled="isLoading || !evaluation"
|
||||
custom-class="user-evaluation__pdf-btn"
|
||||
data-pdf-ignore
|
||||
@click="onSaveAsPdf"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="16" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<SkeletonLoaderBlock v-if="isLoading" :rows="2" :cols-per-row="3" />
|
||||
|
||||
<div v-else-if="evaluation" ref="pdfContent" class="user-evaluation__content">
|
||||
<header class="user-evaluation__pdf-header">
|
||||
<h1>سیستم ارزیابی کاربر</h1>
|
||||
<p>{{ fullName }}</p>
|
||||
</header>
|
||||
|
||||
<section class="user-evaluation__section">
|
||||
<p class="user-evaluation__section-title">مشخصات هویتی</p>
|
||||
<div class="user-evaluation__identity-grid">
|
||||
<LineInfoBlock title="نام و نام خانوادگی" :numeric-desc="fullName" />
|
||||
<LineInfoBlock title="شماره تماس" :numeric-desc="user?.phone || '—'" />
|
||||
<LineInfoBlock title="کد ملی" :numeric-desc="user?.nationalCode || '—'" />
|
||||
<LineInfoBlock title="نقش" :desc="roleText" />
|
||||
<LineInfoBlock title="تاریخ عضویت" :numeric-desc="joinDateLabel" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="user-evaluation__section">
|
||||
<p class="user-evaluation__section-title">خلاصه عملکرد</p>
|
||||
<div class="user-evaluation__stats">
|
||||
<div v-for="(stat, i) in stats" :key="i" class="user-evaluation__stat-card">
|
||||
<div class="user-evaluation__stat-icon">
|
||||
<SvgIcon :name="stat.icon" :size="20" color="var(--color-primary)" />
|
||||
</div>
|
||||
<div class="user-evaluation__stat-text">
|
||||
<p class="user-evaluation__stat-label">{{ stat.label }}</p>
|
||||
<p class="user-evaluation__stat-value">
|
||||
{{ stat.value }}
|
||||
<span v-if="stat.unit" class="user-evaluation__stat-unit">{{ stat.unit }}</span>
|
||||
</p>
|
||||
<p v-if="stat.subtitle" class="user-evaluation__stat-subtitle">
|
||||
{{ stat.subtitle }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<NoItems v-else title="موردی نیست" desc="اطلاعات ارزیابی این کاربر در دسترس نیست." />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { toast } from 'vue3-toastify'
|
||||
import { ROLE_LABELS } from '@/enums'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import NoItems from '@/components/blocks/NoItems.vue'
|
||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import { useAdminUserEvaluationQuery } from '@/services/query/admin-users'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
|
||||
const props = defineProps({
|
||||
userId: { type: [Number, String], required: true },
|
||||
user: { type: Object, default: null },
|
||||
})
|
||||
|
||||
const userIdRef = computed(() => props.userId)
|
||||
const { data: evaluation, isLoading } = useAdminUserEvaluationQuery(userIdRef, {
|
||||
enabled: () => !!userIdRef.value,
|
||||
})
|
||||
|
||||
const fullName = computed(() => props.user?.name || '—')
|
||||
|
||||
const roleText = computed(() => {
|
||||
const names = (props.user?.roles || [])
|
||||
.map((r) => (typeof r === 'string' ? r : r?.name))
|
||||
.filter(Boolean)
|
||||
if (names.length === 0) return 'بدون نقش'
|
||||
return names.map((name) => ROLE_LABELS[name] || name).join('، ')
|
||||
})
|
||||
|
||||
const joinDateLabel = computed(() => formatJalaaliDate(props.user?.createdAt) || '—')
|
||||
|
||||
const formatMembershipDuration = (days) => {
|
||||
if (days == null) return '—'
|
||||
if (days < 1) return 'کمتر از یک روز'
|
||||
const years = Math.floor(days / 365)
|
||||
const months = Math.floor((days % 365) / 30)
|
||||
const remDays = Math.floor(days % 30)
|
||||
const parts = []
|
||||
if (years) parts.push(`${years} سال`)
|
||||
if (months) parts.push(`${months} ماه`)
|
||||
if (!years && !months) parts.push(`${remDays} روز`)
|
||||
return parts.join(' و ')
|
||||
}
|
||||
|
||||
const stats = computed(() => {
|
||||
const e = evaluation.value || {}
|
||||
const exams = e.exams || {}
|
||||
const assignments = e.assignments || {}
|
||||
|
||||
return [
|
||||
{
|
||||
icon: 'video',
|
||||
label: 'جلسات مشاهدهشده',
|
||||
value: e.sessions_viewed ?? 0,
|
||||
unit: 'جلسه',
|
||||
},
|
||||
{
|
||||
icon: 'check-square',
|
||||
label: 'آزمونهای شرکتکرده',
|
||||
value: exams.taken ?? 0,
|
||||
unit: 'آزمون',
|
||||
subtitle: `قبولشده: ${exams.passed ?? 0}`,
|
||||
},
|
||||
{
|
||||
icon: 'certificate',
|
||||
label: 'میانگین امتیاز',
|
||||
value: exams.average_score_percent ?? '—',
|
||||
unit: exams.average_score_percent == null ? '' : '%',
|
||||
},
|
||||
{
|
||||
icon: 'file',
|
||||
label: 'تکالیف انجامشده',
|
||||
value: assignments.completed ?? 0,
|
||||
unit: 'تکلیف',
|
||||
subtitle: `تاییدشده: ${assignments.accepted ?? 0}`,
|
||||
},
|
||||
{
|
||||
icon: 'book',
|
||||
label: 'ترم فعلی',
|
||||
value: e.current_term?.title || 'بدون ترم',
|
||||
unit: '',
|
||||
},
|
||||
{
|
||||
icon: 'clock',
|
||||
label: 'مدت عضویت',
|
||||
value: formatMembershipDuration(e.member_since?.days),
|
||||
unit: '',
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
const pdfContent = ref(null)
|
||||
const pdfLoading = ref(false)
|
||||
|
||||
const onSaveAsPdf = async () => {
|
||||
if (!pdfContent.value || isLoading.value || pdfLoading.value) return
|
||||
|
||||
pdfLoading.value = true
|
||||
try {
|
||||
await document.fonts?.ready
|
||||
|
||||
const pdfSource = pdfContent.value.cloneNode(true)
|
||||
pdfSource.classList.add('user-evaluation__content--pdf')
|
||||
pdfSource.querySelectorAll('[data-pdf-ignore]').forEach((element) => element.remove())
|
||||
|
||||
const html2pdfModule = await import('html2pdf.js')
|
||||
const html2pdf = html2pdfModule.default || html2pdfModule
|
||||
|
||||
await html2pdf()
|
||||
.set({
|
||||
margin: [8, 8, 8, 8],
|
||||
filename: `user-evaluation-${props.userId}.pdf`,
|
||||
image: { type: 'jpeg', quality: 0.98 },
|
||||
html2canvas: {
|
||||
scale: 2,
|
||||
useCORS: true,
|
||||
backgroundColor: '#ffffff',
|
||||
logging: false,
|
||||
},
|
||||
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
|
||||
pagebreak: {
|
||||
mode: ['css', 'legacy'],
|
||||
avoid: ['.user-evaluation__section', '.user-evaluation__stat-card'],
|
||||
},
|
||||
})
|
||||
.from(pdfSource)
|
||||
.save()
|
||||
} catch {
|
||||
toast.error('ساخت فایل PDF با خطا مواجه شد.')
|
||||
} finally {
|
||||
pdfLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.user-evaluation {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
text-align: start;
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
&__title {
|
||||
flex: 1;
|
||||
min-width: 12rem;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
&__pdf-btn {
|
||||
min-width: 9rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__pdf-header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&__section {
|
||||
margin-bottom: 1.25rem;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&__section-title {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 500;
|
||||
font-size: 0.8125rem;
|
||||
color: #8a8a8a;
|
||||
margin: 0 0 0.625rem;
|
||||
}
|
||||
|
||||
&__identity-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);
|
||||
}
|
||||
}
|
||||
|
||||
&__stats {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (min-width: 640px) {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
&__stat-card {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
padding: 0.875rem;
|
||||
background: rgba(255, 255, 255, 55%);
|
||||
box-shadow: 0 4px 10px -6px rgba(0, 0, 0, 8%);
|
||||
border-radius: 0.875rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__stat-icon {
|
||||
flex-shrink: 0;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: 0.625rem;
|
||||
background: rgba(243, 102, 117, 8%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
&__stat-text {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
&__stat-label {
|
||||
margin: 0 0 0.25rem;
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 400;
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.3;
|
||||
color: #9a9a9a;
|
||||
}
|
||||
|
||||
&__stat-value {
|
||||
margin: 0;
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 700;
|
||||
font-size: 1.0625rem;
|
||||
line-height: 1.4;
|
||||
color: #4b4b4b;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
&__stat-unit {
|
||||
font-family: var(--font-family-fa);
|
||||
font-weight: 400;
|
||||
font-size: 0.75rem;
|
||||
color: #8a8a8a;
|
||||
}
|
||||
|
||||
&__stat-subtitle {
|
||||
margin: 0.25rem 0 0;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.6875rem;
|
||||
color: #9a9a9a;
|
||||
}
|
||||
|
||||
&__content--pdf {
|
||||
width: 100%;
|
||||
padding: 0.25rem;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
direction: rtl;
|
||||
}
|
||||
|
||||
&__content--pdf &__pdf-header {
|
||||
display: block;
|
||||
margin-bottom: 1.5rem;
|
||||
padding-bottom: 0.75rem;
|
||||
border-bottom: 1px solid #eee;
|
||||
text-align: right;
|
||||
break-after: avoid;
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 1.25rem;
|
||||
font-weight: 500;
|
||||
color: #4b4b4b;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0.25rem 0 0;
|
||||
font-family: var(--font-family-fa);
|
||||
font-size: 0.875rem;
|
||||
color: #808080;
|
||||
}
|
||||
}
|
||||
|
||||
&__content--pdf &__section {
|
||||
margin-bottom: 1rem;
|
||||
break-inside: avoid;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
&__content--pdf &__identity-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
&__content--pdf &__stats {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
&__content--pdf &__stat-card {
|
||||
break-inside: avoid;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -76,6 +76,10 @@
|
||||
</div>
|
||||
<LineInfoBlock title="گرایش/رشته تحصیلی" :desc="user.fieldOfStudy || '—'" />
|
||||
</div>
|
||||
|
||||
<div class="user-details__section">
|
||||
<UserEvaluationPanel :user-id="userId" :user="user" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<NoItems v-else title="یافت نشد" desc="اطلاعات این کاربر در دسترس نیست." />
|
||||
@@ -106,6 +110,7 @@ import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||
import { useAdminUserQuery } from '@/services/query/admin-users'
|
||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||
import SkeletonLoaderBlock from '@/components/blocks/SkeletonLoaderBlock.vue'
|
||||
import UserEvaluationPanel from '@/features/admin/users/components/UserEvaluationPanel.vue'
|
||||
import {
|
||||
EDUCATION_STATUS,
|
||||
GENDER,
|
||||
|
||||
@@ -67,8 +67,8 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import * as yup from 'yup'
|
||||
import { computed, ref } from 'vue'
|
||||
import { toast } from 'vue3-toastify'
|
||||
import useYup from '@/composables/useYup'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
@@ -79,6 +79,7 @@ import FileUploader from '@/components/form/FileUploader.vue'
|
||||
import { objectToFormData } from '@/utils/object-to-formdata'
|
||||
import { useUploadMediaMutation } from '@/services/query/auth'
|
||||
import TextareaField from '@/components/form/TextareaField.vue'
|
||||
import { useServiceTypesListQuery } from '@/services/query/service-types'
|
||||
|
||||
defineProps({
|
||||
submitting: { type: Boolean, default: false },
|
||||
@@ -86,10 +87,10 @@ defineProps({
|
||||
|
||||
const emit = defineEmits(['submit', 'file-error'])
|
||||
|
||||
const serviceTypeOptions = [
|
||||
{ value: 'خدمات رفاهی', label: 'خدمات رفاهی' },
|
||||
{ value: 'خدمات آموزشی', label: 'خدمات آموزشی' },
|
||||
]
|
||||
const { data: serviceTypes } = useServiceTypesListQuery()
|
||||
const serviceTypeOptions = computed(() =>
|
||||
(serviceTypes.value ?? []).map((st) => ({ value: st.title, label: st.title }))
|
||||
)
|
||||
|
||||
const form = ref({
|
||||
category: '',
|
||||
|
||||
@@ -147,9 +147,20 @@ const menuItems = computed(() => [
|
||||
{
|
||||
title: 'مدیریت خدمات',
|
||||
icon: 'users-three',
|
||||
active: ['admin-services', 'admin-service-types'].includes(route.name),
|
||||
children: [
|
||||
{
|
||||
title: 'درخواستهای خدمت',
|
||||
to: { name: 'admin-services' },
|
||||
active: route.name === 'admin-services',
|
||||
},
|
||||
{
|
||||
title: 'انواع خدمات',
|
||||
to: { name: 'admin-service-types' },
|
||||
active: route.name === 'admin-service-types',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'مدیریت مشاوره',
|
||||
icon: 'chat',
|
||||
|
||||
@@ -8,6 +8,9 @@ export const apiShowAdminUser = (id) => http.get(buildUrl(endpoints.showUserDeta
|
||||
export const apiGetAdminUserRegisterData = (id) =>
|
||||
http.get(buildUrl(endpoints.getUserRegisterData, { id }))
|
||||
|
||||
export const apiGetAdminUserEvaluation = (id) =>
|
||||
http.get(buildUrl(endpoints.getUserEvaluation, { id }))
|
||||
|
||||
export const apiAddAdminUser = (payload) => http.post(endpoints.addNewUser, payload)
|
||||
|
||||
export const apiUpdateAdminUser = (id, payload) =>
|
||||
|
||||
@@ -46,5 +46,10 @@ export const apiGetRegistrationQuestionVideo = () =>
|
||||
// Media uploads (especially course videos) can legitimately take several
|
||||
// minutes on slower connections. Keep the normal API timeout short, but give
|
||||
// this endpoint enough time to complete the backend's 300 MB upload contract.
|
||||
export const apiUploadMedia = (formData) =>
|
||||
http.post(endpoints.uploadMedia, formData, { timeout: 10 * 60 * 1000 })
|
||||
// `onUploadProgress` is optional and forwarded straight to axios so callers
|
||||
// can render an upload progress bar (e.g. XHR progress events).
|
||||
export const apiUploadMedia = (formData, onUploadProgress) =>
|
||||
http.post(endpoints.uploadMedia, formData, {
|
||||
timeout: 10 * 60 * 1000,
|
||||
...(onUploadProgress ? { onUploadProgress } : {}),
|
||||
})
|
||||
|
||||
@@ -55,6 +55,14 @@ export const endpoints = {
|
||||
getStudentCertificates: '/student/certificates',
|
||||
downloadStudentCertificate: '/student/certificates/:id/download',
|
||||
|
||||
// ─── Backend-aligned: Service types (settings) ────────────────────────────
|
||||
// Read is open to any authenticated role (populates the student "request
|
||||
// service" category select); create/update/delete are admin-only.
|
||||
getServiceTypesList: '/service-types',
|
||||
addServiceType: '/service-types',
|
||||
updateServiceType: '/service-types/:id',
|
||||
deleteServiceType: '/service-types/:id',
|
||||
|
||||
// ─── Per-role aggregated dashboards ────────────────────────────────────────
|
||||
// Each requires the matching role's token; backend scopes the payload.
|
||||
getAdminDashboard: '/admin/dashboard',
|
||||
@@ -74,6 +82,7 @@ export const endpoints = {
|
||||
changeUserStatus: '/admin/users/:id/status',
|
||||
deleteUser: '/admin/users/:id',
|
||||
getUserRegisterData: '/admin/users/:id/register-data',
|
||||
getUserEvaluation: '/admin/users/:id/evaluation',
|
||||
|
||||
// ─── Backend-aligned: Terms ────────────────────────────────────────────────
|
||||
getTermsList: '/terms',
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { http } from '@/services/api/http'
|
||||
import { buildUrl, endpoints } from '@/services/api/endpoints'
|
||||
|
||||
export const apiGetServiceTypes = () => http.get(endpoints.getServiceTypesList)
|
||||
|
||||
export const apiAddServiceType = (payload) => http.post(endpoints.addServiceType, payload)
|
||||
|
||||
export const apiUpdateServiceType = (id, payload) =>
|
||||
http.patch(buildUrl(endpoints.updateServiceType, { id }), payload)
|
||||
|
||||
export const apiDeleteServiceType = (id) =>
|
||||
http.delete(buildUrl(endpoints.deleteServiceType, { id }))
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
apiAddAdminUser,
|
||||
apiChangeAdminUserStatus,
|
||||
apiDeleteAdminUser,
|
||||
apiGetAdminUserEvaluation,
|
||||
apiGetAdminUserRegisterData,
|
||||
apiGetAdminUsers,
|
||||
apiShowAdminUser,
|
||||
@@ -16,6 +17,7 @@ export const adminUsersKeys = {
|
||||
list: (filters, pagination) => ['admin', 'users', 'list', filters, pagination],
|
||||
detail: (id) => ['admin', 'users', 'detail', id],
|
||||
registerData: (id) => ['admin', 'users', 'register-data', id],
|
||||
evaluation: (id) => ['admin', 'users', 'evaluation', id],
|
||||
}
|
||||
|
||||
export const useAdminUsersListQuery = (filtersRef, paginationRef, options = {}) =>
|
||||
@@ -59,6 +61,14 @@ export const useAdminUserRegisterDataQuery = (idRef, options = {}) =>
|
||||
...options,
|
||||
})
|
||||
|
||||
export const useAdminUserEvaluationQuery = (idRef, options = {}) =>
|
||||
useQuery({
|
||||
queryKey: ['admin', 'users', 'evaluation', idRef],
|
||||
queryFn: () => apiGetAdminUserEvaluation(idRef.value),
|
||||
select: (response) => response?.data ?? response,
|
||||
...options,
|
||||
})
|
||||
|
||||
export const useAddAdminUserMutation = () =>
|
||||
useMutation({ mutationFn: (payload) => apiAddAdminUser(payload) })
|
||||
|
||||
|
||||
@@ -79,7 +79,16 @@ export const useGetRegistrationVideoQuery = (options = {}) =>
|
||||
...options,
|
||||
})
|
||||
|
||||
export const useUploadMediaMutation = () => useMutation({ mutationFn: apiUploadMedia })
|
||||
// `mutateAsync` accepts either a raw FormData (existing call sites, no
|
||||
// progress tracking) or `{ formData, onUploadProgress }` for callers that
|
||||
// want to render upload progress (e.g. a video upload progress bar).
|
||||
const uploadMediaMutationFn = (variables) => {
|
||||
if (variables instanceof FormData) return apiUploadMedia(variables)
|
||||
const { formData, onUploadProgress } = variables
|
||||
return apiUploadMedia(formData, onUploadProgress)
|
||||
}
|
||||
|
||||
export const useUploadMediaMutation = () => useMutation({ mutationFn: uploadMediaMutationFn })
|
||||
|
||||
// Register-data is a flat `{ field: value }` object; legacy responses were a
|
||||
// `[{ key, value }]` list. Normalize both into the object shape.
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { useMutation, useQuery } from '@tanstack/vue-query'
|
||||
import {
|
||||
apiAddServiceType,
|
||||
apiDeleteServiceType,
|
||||
apiGetServiceTypes,
|
||||
apiUpdateServiceType,
|
||||
} from '@/services/api/service-types'
|
||||
|
||||
export const serviceTypesKeys = {
|
||||
all: ['service-types'],
|
||||
list: () => ['service-types', 'list'],
|
||||
}
|
||||
|
||||
export const useServiceTypesListQuery = (options = {}) =>
|
||||
useQuery({
|
||||
queryKey: serviceTypesKeys.list(),
|
||||
queryFn: () => apiGetServiceTypes(),
|
||||
select: (response) => response?.data ?? response ?? [],
|
||||
...options,
|
||||
})
|
||||
|
||||
export const useAddServiceTypeMutation = () =>
|
||||
useMutation({ mutationFn: (payload) => apiAddServiceType(payload) })
|
||||
|
||||
export const useUpdateServiceTypeMutation = () =>
|
||||
useMutation({ mutationFn: ({ id, payload }) => apiUpdateServiceType(id, payload) })
|
||||
|
||||
export const useDeleteServiceTypeMutation = () =>
|
||||
useMutation({ mutationFn: (id) => apiDeleteServiceType(id) })
|
||||
@@ -8,15 +8,22 @@ export const studentCoursesKeys = {
|
||||
detail: (id) => ['student', 'courses', 'detail', id],
|
||||
}
|
||||
|
||||
const withCoverImage = (course) => ({
|
||||
...course,
|
||||
image: course.image ?? course.coverUrl ?? null,
|
||||
})
|
||||
|
||||
const adaptCourseResponse = (response) => {
|
||||
const course = response?.data ?? response
|
||||
if (!course) return course
|
||||
return {
|
||||
...course,
|
||||
image: course.image ?? course.coverUrl ?? null,
|
||||
}
|
||||
return withCoverImage(course)
|
||||
}
|
||||
|
||||
const adaptCourseListResponse = (response) => ({
|
||||
data: (response?.data?.items ?? response?.data ?? []).map((course) => withCoverImage(course)),
|
||||
meta: response?.data?.meta ?? response?.meta,
|
||||
})
|
||||
|
||||
export const useStudentCoursesListQuery = (filtersRef, paginationRef, options = {}) =>
|
||||
useQuery({
|
||||
queryKey: ['student', 'courses', 'list', filtersRef, paginationRef],
|
||||
@@ -25,6 +32,7 @@ export const useStudentCoursesListQuery = (filtersRef, paginationRef, options =
|
||||
...cleanFilters(filtersRef.value),
|
||||
...paginationRef.value,
|
||||
}),
|
||||
select: adaptCourseListResponse,
|
||||
...options,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user