fix: data
Deploy banu-front / deploy (push) Failing after 6s

This commit is contained in:
sajjadtalkhabi
2026-06-11 19:22:35 +03:30
parent a007db0d50
commit 020a47f735
5 changed files with 80 additions and 3 deletions
+3
View File
@@ -5,6 +5,9 @@ export const apiGetAdminUsers = (params) => http.get(endpoints.getApprovedUsers,
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 apiUpdateAdminUser = (id, payload) =>
+1
View File
@@ -59,6 +59,7 @@ export const endpoints = {
updateUserRole: '/admin/users/:id/role',
changeUserStatus: '/admin/users/:id/status',
deleteUser: '/admin/users/:id',
getUserRegisterData: '/admin/users/:id/register-data',
// ─── Backend-aligned: Terms ────────────────────────────────────────────────
getTermsList: '/terms',
+39
View File
@@ -38,6 +38,45 @@ register('GET', endpoints.showUserDetails, ({ params }) => ({
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 }) => {
const id = makeId()
const roleByName = (n) => roles.find((r) => r.name === n)
+24
View File
@@ -4,6 +4,7 @@ import {
apiAddAdminUser,
apiChangeAdminUserStatus,
apiDeleteAdminUser,
apiGetAdminUserRegisterData,
apiGetAdminUsers,
apiShowAdminUser,
apiUpdateAdminUser,
@@ -14,6 +15,7 @@ export const adminUsersKeys = {
all: ['admin', 'users'],
list: (filters, pagination) => ['admin', 'users', 'list', filters, pagination],
detail: (id) => ['admin', 'users', 'detail', id],
registerData: (id) => ['admin', 'users', 'register-data', id],
}
export const useAdminUsersListQuery = (filtersRef, paginationRef, options = {}) =>
@@ -35,6 +37,28 @@ export const useAdminUserQuery = (idRef, 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 = () =>
useMutation({ mutationFn: (payload) => apiAddAdminUser(payload) })