feat(services): add Service Types management UI
Admin CRUD page for service types, plus wiring the student "request service" form's category select to the real list instead of a hardcoded pair of options.
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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 }))
|
||||
@@ -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) })
|
||||
Reference in New Issue
Block a user