+13
-3
@@ -214,8 +214,8 @@ import useModal from '@/composables/useModal'
|
|||||||
import BasicModal from '@/components/BasicModal.vue'
|
import BasicModal from '@/components/BasicModal.vue'
|
||||||
import { formatJalaaliDate } from '@/utils/date-utils'
|
import { formatJalaaliDate } from '@/utils/date-utils'
|
||||||
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
import LineTitleBlock from '@/components/LineTitleBlock.vue'
|
||||||
import { useAdminUserQuery } from '@/services/query/admin-users'
|
|
||||||
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
import LineInfoBlock from '@/components/blocks/LineInfoBlock.vue'
|
||||||
|
import { useAdminUserQuery, useAdminUserRegisterDataQuery } from '@/services/query/admin-users'
|
||||||
import {
|
import {
|
||||||
AUDIENCE_CONFLICT_RESPONSE,
|
AUDIENCE_CONFLICT_RESPONSE,
|
||||||
COMPETING_PROPAGATOR_RESPONSE,
|
COMPETING_PROPAGATOR_RESPONSE,
|
||||||
@@ -242,10 +242,20 @@ const { data: fetched } = useAdminUserQuery(userIdRef, {
|
|||||||
enabled: () => !!userIdRef.value,
|
enabled: () => !!userIdRef.value,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { data: registerData } = useAdminUserRegisterDataQuery(userIdRef, {
|
||||||
|
enabled: () => !!userIdRef.value,
|
||||||
|
})
|
||||||
|
|
||||||
const user = computed(() => modalData.value.user || fetched.value || null)
|
const user = computed(() => modalData.value.user || fetched.value || null)
|
||||||
const profile = computed(() => user.value?.profile || {})
|
|
||||||
|
// The register-data endpoint returns the answers the user gave during the
|
||||||
|
// registration steps — the same fields the sections below render. Merge it over
|
||||||
|
// the user's stored profile so reviewing admins see what was actually submitted.
|
||||||
|
const profile = computed(() => ({ ...user.value?.profile, ...registerData.value }))
|
||||||
|
|
||||||
const fullName = computed(
|
const fullName = computed(
|
||||||
() => `${user.value?.firstName || ''} ${user.value?.lastName || ''}`.trim() || '—'
|
() =>
|
||||||
|
user.value?.name || `${user.value?.firstName || ''} ${user.value?.lastName || ''}`.trim() || '—'
|
||||||
)
|
)
|
||||||
|
|
||||||
const platforms = computed(() =>
|
const platforms = computed(() =>
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ export const apiGetAdminUsers = (params) => http.get(endpoints.getApprovedUsers,
|
|||||||
|
|
||||||
export const apiShowAdminUser = (id) => http.get(buildUrl(endpoints.showUserDetails, { id }))
|
export const apiShowAdminUser = (id) => http.get(buildUrl(endpoints.showUserDetails, { id }))
|
||||||
|
|
||||||
|
export const apiGetAdminUserRegisterData = (id) =>
|
||||||
|
http.get(buildUrl(endpoints.getUserRegisterData, { id }))
|
||||||
|
|
||||||
export const apiAddAdminUser = (payload) => http.post(endpoints.addNewUser, payload)
|
export const apiAddAdminUser = (payload) => http.post(endpoints.addNewUser, payload)
|
||||||
|
|
||||||
export const apiUpdateAdminUser = (id, payload) =>
|
export const apiUpdateAdminUser = (id, payload) =>
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ export const endpoints = {
|
|||||||
updateUserRole: '/admin/users/:id/role',
|
updateUserRole: '/admin/users/:id/role',
|
||||||
changeUserStatus: '/admin/users/:id/status',
|
changeUserStatus: '/admin/users/:id/status',
|
||||||
deleteUser: '/admin/users/:id',
|
deleteUser: '/admin/users/:id',
|
||||||
|
getUserRegisterData: '/admin/users/:id/register-data',
|
||||||
|
|
||||||
// ─── Backend-aligned: Terms ────────────────────────────────────────────────
|
// ─── Backend-aligned: Terms ────────────────────────────────────────────────
|
||||||
getTermsList: '/terms',
|
getTermsList: '/terms',
|
||||||
|
|||||||
@@ -38,6 +38,45 @@ register('GET', endpoints.showUserDetails, ({ params }) => ({
|
|||||||
data: findOrThrow(adminUsers, params.id),
|
data: findOrThrow(adminUsers, params.id),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
register('GET', endpoints.getUserRegisterData, ({ params }) => {
|
||||||
|
const user = findOrThrow(adminUsers, params.id)
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: 'OK',
|
||||||
|
data: [
|
||||||
|
{ key: 'educationStatus', value: 'seminary_student' },
|
||||||
|
{ key: 'seminaryLevel', value: 'level_3' },
|
||||||
|
{ key: 'universityLevel', value: 'not_applicable' },
|
||||||
|
{ key: 'universityName', value: 'حوزه علمیه قم' },
|
||||||
|
{ key: 'fieldOfStudy', value: 'فقه و اصول' },
|
||||||
|
{ key: 'workExperienceSummary', value: 'پنج سال تدریس در مدرسه دینی.' },
|
||||||
|
{ key: 'activitySummary', value: 'برگزاری جلسات قرآن و حدیث به صورت هفتگی.' },
|
||||||
|
{ key: 'specializedTopics', value: 'تربیت دینی نوجوانان' },
|
||||||
|
{ key: 'propagationExperienceYears', value: 6 },
|
||||||
|
{ key: 'propagationMethodDescription', value: 'محوریت بیان داستانهای قرآنی.' },
|
||||||
|
{
|
||||||
|
key: 'propagationPlatforms',
|
||||||
|
value: [
|
||||||
|
{ platform: 'home_gathering_regular', platform_details: null },
|
||||||
|
{ platform: 'online', platform_details: 'کانال اینستاگرام @example' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{ key: 'responseToLowSatisfaction', value: 'change_the_method' },
|
||||||
|
{ key: 'responseToSessionCancellation', value: 'teach_how_to_reduce_costs' },
|
||||||
|
{ key: 'responseToAudienceConflict', value: 'divide_the_crowd' },
|
||||||
|
{ key: 'responseToCompetingPropagator', value: 'strengthen_yourself' },
|
||||||
|
{ key: 'responseToCompetingPropagatorDescription', value: null },
|
||||||
|
{ key: 'relevantCertificates', value: 'سطح ۳ حوزوی، تدریس قرآن' },
|
||||||
|
{ key: 'hijabApproach', value: 'گفتگوی همدلانه و آموزشمحور.' },
|
||||||
|
{ key: 'provinceId', value: user.address?.province?.id ?? 1 },
|
||||||
|
{ key: 'cityId', value: user.address?.city?.id ?? 101 },
|
||||||
|
{ key: 'address', value: user.address?.address || 'تهران، خیابان نمونه' },
|
||||||
|
{ key: 'avatar', value: null },
|
||||||
|
{ key: 'avatarId', value: null },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
register('POST', endpoints.addNewUser, ({ data }) => {
|
register('POST', endpoints.addNewUser, ({ data }) => {
|
||||||
const id = makeId()
|
const id = makeId()
|
||||||
const roleByName = (n) => roles.find((r) => r.name === n)
|
const roleByName = (n) => roles.find((r) => r.name === n)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
apiAddAdminUser,
|
apiAddAdminUser,
|
||||||
apiChangeAdminUserStatus,
|
apiChangeAdminUserStatus,
|
||||||
apiDeleteAdminUser,
|
apiDeleteAdminUser,
|
||||||
|
apiGetAdminUserRegisterData,
|
||||||
apiGetAdminUsers,
|
apiGetAdminUsers,
|
||||||
apiShowAdminUser,
|
apiShowAdminUser,
|
||||||
apiUpdateAdminUser,
|
apiUpdateAdminUser,
|
||||||
@@ -14,6 +15,7 @@ export const adminUsersKeys = {
|
|||||||
all: ['admin', 'users'],
|
all: ['admin', 'users'],
|
||||||
list: (filters, pagination) => ['admin', 'users', 'list', filters, pagination],
|
list: (filters, pagination) => ['admin', 'users', 'list', filters, pagination],
|
||||||
detail: (id) => ['admin', 'users', 'detail', id],
|
detail: (id) => ['admin', 'users', 'detail', id],
|
||||||
|
registerData: (id) => ['admin', 'users', 'register-data', id],
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useAdminUsersListQuery = (filtersRef, paginationRef, options = {}) =>
|
export const useAdminUsersListQuery = (filtersRef, paginationRef, options = {}) =>
|
||||||
@@ -35,6 +37,28 @@ export const useAdminUserQuery = (idRef, options = {}) =>
|
|||||||
...options,
|
...options,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Register-data comes back as a `[{ key, value }]` array (values may be
|
||||||
|
// strings, numbers, null, or nested objects/arrays). Normalize it into a plain
|
||||||
|
// `{ key: value }` object for consumers; tolerate an already-object shape too.
|
||||||
|
const toRegisterDataObject = (response) => {
|
||||||
|
const raw = response?.data ?? response
|
||||||
|
if (Array.isArray(raw)) {
|
||||||
|
return raw.reduce((acc, item) => {
|
||||||
|
if (item && item.key != null) acc[item.key] = item.value
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
}
|
||||||
|
return raw || {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useAdminUserRegisterDataQuery = (idRef, options = {}) =>
|
||||||
|
useQuery({
|
||||||
|
queryKey: ['admin', 'users', 'register-data', idRef],
|
||||||
|
queryFn: () => apiGetAdminUserRegisterData(idRef.value),
|
||||||
|
select: toRegisterDataObject,
|
||||||
|
...options,
|
||||||
|
})
|
||||||
|
|
||||||
export const useAddAdminUserMutation = () =>
|
export const useAddAdminUserMutation = () =>
|
||||||
useMutation({ mutationFn: (payload) => apiAddAdminUser(payload) })
|
useMutation({ mutationFn: (payload) => apiAddAdminUser(payload) })
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user