feat: services table, base segmented control

This commit is contained in:
2025-09-27 18:24:22 +04:00
parent 14140826a7
commit 47533ad7f5
29 changed files with 1489 additions and 44 deletions

View File

@ -19,6 +19,7 @@ import {
createProduct,
createProject,
createService,
createServiceCategory,
createServicesKit,
createStatus,
deleteBoard,
@ -29,6 +30,7 @@ import {
deleteProduct,
deleteProject,
deleteService,
deleteServiceCategory,
deleteServicesKit,
deleteStatus,
duplicateProductServices,
@ -39,6 +41,7 @@ import {
getDealServices,
getProducts,
getProjects,
getServiceCategories,
getServices,
getServicesKits,
getStatuses,
@ -51,6 +54,7 @@ import {
updateProduct,
updateProject,
updateService,
updateServiceCategory,
updateServicesKit,
updateStatus,
type Options,
@ -83,6 +87,9 @@ import type {
CreateProjectData,
CreateProjectError,
CreateProjectResponse2,
CreateServiceCategoryData,
CreateServiceCategoryError,
CreateServiceCategoryResponse2,
CreateServiceData,
CreateServiceError,
CreateServiceResponse2,
@ -113,6 +120,9 @@ import type {
DeleteProjectData,
DeleteProjectError,
DeleteProjectResponse2,
DeleteServiceCategoryData,
DeleteServiceCategoryError,
DeleteServiceCategoryResponse2,
DeleteServiceData,
DeleteServiceError,
DeleteServiceResponse2,
@ -136,6 +146,7 @@ import type {
GetProductsError,
GetProductsResponse2,
GetProjectsData,
GetServiceCategoriesData,
GetServicesData,
GetServicesKitsData,
GetStatusesData,
@ -161,6 +172,9 @@ import type {
UpdateProjectData,
UpdateProjectError,
UpdateProjectResponse2,
UpdateServiceCategoryData,
UpdateServiceCategoryError,
UpdateServiceCategoryResponse2,
UpdateServiceData,
UpdateServiceError,
UpdateServiceResponse2,
@ -1644,6 +1658,135 @@ export const updateServiceMutation = (
return mutationOptions;
};
export const getServiceCategoriesQueryKey = (
options?: Options<GetServiceCategoriesData>
) => createQueryKey("getServiceCategories", options);
/**
* Get Services Categories
*/
export const getServiceCategoriesOptions = (
options?: Options<GetServiceCategoriesData>
) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getServiceCategories({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: getServiceCategoriesQueryKey(options),
});
};
export const createServiceCategoryQueryKey = (
options: Options<CreateServiceCategoryData>
) => createQueryKey("createServiceCategory", options);
/**
* Create Service Category
*/
export const createServiceCategoryOptions = (
options: Options<CreateServiceCategoryData>
) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await createServiceCategory({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: createServiceCategoryQueryKey(options),
});
};
/**
* Create Service Category
*/
export const createServiceCategoryMutation = (
options?: Partial<Options<CreateServiceCategoryData>>
): UseMutationOptions<
CreateServiceCategoryResponse2,
AxiosError<CreateServiceCategoryError>,
Options<CreateServiceCategoryData>
> => {
const mutationOptions: UseMutationOptions<
CreateServiceCategoryResponse2,
AxiosError<CreateServiceCategoryError>,
Options<CreateServiceCategoryData>
> = {
mutationFn: async localOptions => {
const { data } = await createServiceCategory({
...options,
...localOptions,
throwOnError: true,
});
return data;
},
};
return mutationOptions;
};
/**
* Delete Service Category
*/
export const deleteServiceCategoryMutation = (
options?: Partial<Options<DeleteServiceCategoryData>>
): UseMutationOptions<
DeleteServiceCategoryResponse2,
AxiosError<DeleteServiceCategoryError>,
Options<DeleteServiceCategoryData>
> => {
const mutationOptions: UseMutationOptions<
DeleteServiceCategoryResponse2,
AxiosError<DeleteServiceCategoryError>,
Options<DeleteServiceCategoryData>
> = {
mutationFn: async localOptions => {
const { data } = await deleteServiceCategory({
...options,
...localOptions,
throwOnError: true,
});
return data;
},
};
return mutationOptions;
};
/**
* Update Service Category
*/
export const updateServiceCategoryMutation = (
options?: Partial<Options<UpdateServiceCategoryData>>
): UseMutationOptions<
UpdateServiceCategoryResponse2,
AxiosError<UpdateServiceCategoryError>,
Options<UpdateServiceCategoryData>
> => {
const mutationOptions: UseMutationOptions<
UpdateServiceCategoryResponse2,
AxiosError<UpdateServiceCategoryError>,
Options<UpdateServiceCategoryData>
> = {
mutationFn: async localOptions => {
const { data } = await updateServiceCategory({
...options,
...localOptions,
throwOnError: true,
});
return data;
},
};
return mutationOptions;
};
export const getServicesKitsQueryKey = (
options?: Options<GetServicesKitsData>
) => createQueryKey("getServicesKits", options);