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:
@@ -241,6 +241,17 @@ export default [
|
|||||||
subtitle: 'لیست خدمات را مشاهده و مدیریت نمایید.',
|
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',
|
path: '/consultations',
|
||||||
name: 'admin-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 SendMessageModal } from './components/modals/SendMessageModal.vue'
|
||||||
export { default as ServiceDetailsModal } from './components/modals/ServiceDetailsModal.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 ServiceItem } from './components/ServiceItem.vue'
|
||||||
|
export { default as ServiceTypeItem } from './components/ServiceTypeItem.vue'
|
||||||
export { default as ServicesFilters } from './components/ServicesFilters.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, 'توضیحات طولانی است'),
|
||||||
|
})
|
||||||
@@ -67,8 +67,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
|
||||||
import * as yup from 'yup'
|
import * as yup from 'yup'
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
import { toast } from 'vue3-toastify'
|
import { toast } from 'vue3-toastify'
|
||||||
import useYup from '@/composables/useYup'
|
import useYup from '@/composables/useYup'
|
||||||
import BaseButton from '@/components/BaseButton.vue'
|
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 { objectToFormData } from '@/utils/object-to-formdata'
|
||||||
import { useUploadMediaMutation } from '@/services/query/auth'
|
import { useUploadMediaMutation } from '@/services/query/auth'
|
||||||
import TextareaField from '@/components/form/TextareaField.vue'
|
import TextareaField from '@/components/form/TextareaField.vue'
|
||||||
|
import { useServiceTypesListQuery } from '@/services/query/service-types'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
submitting: { type: Boolean, default: false },
|
submitting: { type: Boolean, default: false },
|
||||||
@@ -86,10 +87,10 @@ defineProps({
|
|||||||
|
|
||||||
const emit = defineEmits(['submit', 'file-error'])
|
const emit = defineEmits(['submit', 'file-error'])
|
||||||
|
|
||||||
const serviceTypeOptions = [
|
const { data: serviceTypes } = useServiceTypesListQuery()
|
||||||
{ value: 'خدمات رفاهی', label: 'خدمات رفاهی' },
|
const serviceTypeOptions = computed(() =>
|
||||||
{ value: 'خدمات آموزشی', label: 'خدمات آموزشی' },
|
(serviceTypes.value ?? []).map((st) => ({ value: st.title, label: st.title }))
|
||||||
]
|
)
|
||||||
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
category: '',
|
category: '',
|
||||||
|
|||||||
@@ -147,9 +147,20 @@ const menuItems = computed(() => [
|
|||||||
{
|
{
|
||||||
title: 'مدیریت خدمات',
|
title: 'مدیریت خدمات',
|
||||||
icon: 'users-three',
|
icon: 'users-three',
|
||||||
|
active: ['admin-services', 'admin-service-types'].includes(route.name),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
title: 'درخواستهای خدمت',
|
||||||
to: { name: 'admin-services' },
|
to: { name: 'admin-services' },
|
||||||
active: route.name === 'admin-services',
|
active: route.name === 'admin-services',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'انواع خدمات',
|
||||||
|
to: { name: 'admin-service-types' },
|
||||||
|
active: route.name === 'admin-service-types',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'مدیریت مشاوره',
|
title: 'مدیریت مشاوره',
|
||||||
icon: 'chat',
|
icon: 'chat',
|
||||||
|
|||||||
@@ -55,6 +55,14 @@ export const endpoints = {
|
|||||||
getStudentCertificates: '/student/certificates',
|
getStudentCertificates: '/student/certificates',
|
||||||
downloadStudentCertificate: '/student/certificates/:id/download',
|
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 ────────────────────────────────────────
|
// ─── Per-role aggregated dashboards ────────────────────────────────────────
|
||||||
// Each requires the matching role's token; backend scopes the payload.
|
// Each requires the matching role's token; backend scopes the payload.
|
||||||
getAdminDashboard: '/admin/dashboard',
|
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