@@ -164,6 +164,10 @@ export const endpoints = {
|
||||
showCounselorTicket: '/counselor/tickets/:id',
|
||||
sendCounselorTicketMessage: '/counselor/tickets/:id/messages',
|
||||
changeCounselorTicketStatus: '/counselor/tickets/:id/status',
|
||||
|
||||
listMissionaryRequests: '/missionary/requests',
|
||||
showMissionaryRequest: '/missionary/requests/:id',
|
||||
changeMissionaryRequestStatus: '/missionary/requests/:id/status',
|
||||
}
|
||||
|
||||
export const buildUrl = (template, params = {}) =>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { http } from '@/services/api/http'
|
||||
import { buildUrl, endpoints } from '@/services/api/endpoints'
|
||||
|
||||
export const apiListMissionaryRequests = (params) =>
|
||||
http.get(endpoints.listMissionaryRequests, { params })
|
||||
|
||||
export const apiShowMissionaryRequest = (id) =>
|
||||
http.get(buildUrl(endpoints.showMissionaryRequest, { id }))
|
||||
|
||||
export const apiChangeMissionaryRequestStatus = (id, payload) =>
|
||||
http.patch(buildUrl(endpoints.changeMissionaryRequestStatus, { id }), payload)
|
||||
@@ -0,0 +1,62 @@
|
||||
export const missionaryRequests = [
|
||||
{
|
||||
id: 1,
|
||||
missionaryId: 8,
|
||||
externalSource: 'wordpress',
|
||||
externalReferenceId: 'wp-ticket-12341',
|
||||
requesterName: 'احمد رضایی',
|
||||
requesterPhone: '09123456789',
|
||||
requesterEmail: 'ahmad@example.com',
|
||||
title: 'درخواست جلسه هفتگی روضه خانگی',
|
||||
description: 'به دنبال برگزاری یک جلسه ثابت هفتگی در منزل هستیم.',
|
||||
location: 'تهران، ایران',
|
||||
requestedDate: '2026-05-20',
|
||||
status: 'pending',
|
||||
createdAt: '2026-05-09T10:00:00+00:00',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
missionaryId: 8,
|
||||
externalSource: 'wordpress',
|
||||
externalReferenceId: 'wp-ticket-12342',
|
||||
requesterName: 'مریم اکبری',
|
||||
requesterPhone: '09121112233',
|
||||
requesterEmail: 'maryam@example.com',
|
||||
title: 'مراسم مناسبتی دهه محرم',
|
||||
description: 'برای دهه اول محرم نیاز به مبلغ برای جلسات خانگی داریم.',
|
||||
location: 'قم، ایران',
|
||||
requestedDate: '2026-06-25',
|
||||
status: 'seen',
|
||||
createdAt: '2026-05-11T08:30:00+00:00',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
missionaryId: 8,
|
||||
externalSource: 'wordpress',
|
||||
externalReferenceId: 'wp-ticket-12343',
|
||||
requesterName: 'فاطمه حسینی',
|
||||
requesterPhone: '09354445566',
|
||||
requesterEmail: 'fatemeh@example.com',
|
||||
title: 'جلسه پرسش و پاسخ اعتقادی دانشگاه',
|
||||
description: 'برگزاری نشست پرسش و پاسخ برای دانشجویان خوابگاه.',
|
||||
location: 'اصفهان، ایران',
|
||||
requestedDate: '2026-06-02',
|
||||
status: 'accepted',
|
||||
createdAt: '2026-05-12T14:15:00+00:00',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
missionaryId: 8,
|
||||
externalSource: 'wordpress',
|
||||
externalReferenceId: 'wp-ticket-12344',
|
||||
requesterName: 'حسین مولایی',
|
||||
requesterPhone: '09107778899',
|
||||
requesterEmail: 'hossein@example.com',
|
||||
title: 'کلاس آموزش احکام مدرسه',
|
||||
description: 'برگزاری کلاس هفتگی احکام برای دانشآموزان دوره اول.',
|
||||
location: 'مشهد، ایران',
|
||||
requestedDate: '2026-05-30',
|
||||
status: 'rejected',
|
||||
createdAt: '2026-05-13T09:45:00+00:00',
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,22 @@
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import { findOrThrow, updateById } from '@/services/mock/helpers'
|
||||
import { missionaryRequests } from '@/services/mock/fixtures/missionary-requests'
|
||||
|
||||
register('GET', endpoints.listMissionaryRequests, () => ({
|
||||
success: true,
|
||||
message: 'OK',
|
||||
data: missionaryRequests,
|
||||
}))
|
||||
|
||||
register('GET', endpoints.showMissionaryRequest, ({ params }) => ({
|
||||
success: true,
|
||||
message: 'OK',
|
||||
data: findOrThrow(missionaryRequests, params.id),
|
||||
}))
|
||||
|
||||
register('PATCH', endpoints.changeMissionaryRequestStatus, ({ params, data }) => ({
|
||||
success: true,
|
||||
message: 'Status updated.',
|
||||
data: updateById(missionaryRequests, params.id, { status: data.status }),
|
||||
}))
|
||||
@@ -70,16 +70,25 @@ export const useGetRegistrationVideoQuery = (options = {}) =>
|
||||
|
||||
export const useUploadMediaMutation = () => useMutation({ mutationFn: apiUploadMedia })
|
||||
|
||||
// Register-data is a flat `{ field: value }` object; legacy responses were a
|
||||
// `[{ key, value }]` list. Normalize both into the object shape.
|
||||
const toRegisterDataObject = (response) => {
|
||||
const body = response?.data ?? response
|
||||
const raw = Array.isArray(body) ? body : body?.data ?? body
|
||||
if (Array.isArray(raw)) {
|
||||
return raw.reduce((acc, item) => {
|
||||
if (item && typeof item === 'object' && 'key' in item) acc[item.key] = item.value
|
||||
return acc
|
||||
}, {})
|
||||
}
|
||||
return raw && typeof raw === 'object' ? raw : {}
|
||||
}
|
||||
|
||||
export const useGetRegisterDataQuery = (options = {}) =>
|
||||
useQuery({
|
||||
queryKey: authKeys.registerData(),
|
||||
queryFn: () => apiGetRegisterData(),
|
||||
select: (response) => {
|
||||
const data = response?.data ?? response
|
||||
if (Array.isArray(data)) return data
|
||||
if (Array.isArray(data?.data)) return data.data
|
||||
return []
|
||||
},
|
||||
select: toRegisterDataObject,
|
||||
...options,
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { useMutation, useQuery } from '@tanstack/vue-query'
|
||||
import {
|
||||
apiChangeMissionaryRequestStatus,
|
||||
apiListMissionaryRequests,
|
||||
apiShowMissionaryRequest,
|
||||
} from '@/services/api/missionary-requests'
|
||||
|
||||
export const missionaryRequestsKeys = {
|
||||
all: ['missionary', 'requests'],
|
||||
list: () => ['missionary', 'requests', 'list'],
|
||||
detail: (id) => ['missionary', 'requests', 'detail', id],
|
||||
}
|
||||
|
||||
export const useMissionaryRequestsListQuery = (options = {}) =>
|
||||
useQuery({
|
||||
queryKey: missionaryRequestsKeys.list(),
|
||||
queryFn: () => apiListMissionaryRequests(),
|
||||
select: (response) => response?.data ?? [],
|
||||
...options,
|
||||
})
|
||||
|
||||
export const useMissionaryRequestQuery = (idRef, options = {}) =>
|
||||
useQuery({
|
||||
queryKey: ['missionary', 'requests', 'detail', idRef],
|
||||
queryFn: () => apiShowMissionaryRequest(idRef.value),
|
||||
select: (response) => response?.data ?? response,
|
||||
...options,
|
||||
})
|
||||
|
||||
export const useChangeMissionaryRequestStatusMutation = () =>
|
||||
useMutation({
|
||||
mutationFn: ({ id, payload }) => apiChangeMissionaryRequestStatus(id, payload),
|
||||
})
|
||||
Reference in New Issue
Block a user