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);

View File

@ -30,6 +30,9 @@ import type {
CreateProjectData,
CreateProjectErrors,
CreateProjectResponses,
CreateServiceCategoryData,
CreateServiceCategoryErrors,
CreateServiceCategoryResponses,
CreateServiceData,
CreateServiceErrors,
CreateServiceResponses,
@ -60,6 +63,9 @@ import type {
DeleteProjectData,
DeleteProjectErrors,
DeleteProjectResponses,
DeleteServiceCategoryData,
DeleteServiceCategoryErrors,
DeleteServiceCategoryResponses,
DeleteServiceData,
DeleteServiceErrors,
DeleteServiceResponses,
@ -91,6 +97,8 @@ import type {
GetProductsResponses,
GetProjectsData,
GetProjectsResponses,
GetServiceCategoriesData,
GetServiceCategoriesResponses,
GetServicesData,
GetServicesKitsData,
GetServicesKitsResponses,
@ -122,6 +130,9 @@ import type {
UpdateProjectData,
UpdateProjectErrors,
UpdateProjectResponses,
UpdateServiceCategoryData,
UpdateServiceCategoryErrors,
UpdateServiceCategoryResponses,
UpdateServiceData,
UpdateServiceErrors,
UpdateServiceResponses,
@ -151,6 +162,8 @@ import {
zCreateProductResponse2,
zCreateProjectData,
zCreateProjectResponse2,
zCreateServiceCategoryData,
zCreateServiceCategoryResponse2,
zCreateServiceData,
zCreateServiceResponse2,
zCreateServicesKitData,
@ -171,6 +184,8 @@ import {
zDeleteProductResponse2,
zDeleteProjectData,
zDeleteProjectResponse2,
zDeleteServiceCategoryData,
zDeleteServiceCategoryResponse2,
zDeleteServiceData,
zDeleteServiceResponse2,
zDeleteServicesKitData,
@ -193,6 +208,8 @@ import {
zGetProductsResponse2,
zGetProjectsData,
zGetProjectsResponse2,
zGetServiceCategoriesData,
zGetServiceCategoriesResponse2,
zGetServicesData,
zGetServicesKitsData,
zGetServicesKitsResponse,
@ -215,6 +232,8 @@ import {
zUpdateProductResponse2,
zUpdateProjectData,
zUpdateProjectResponse2,
zUpdateServiceCategoryData,
zUpdateServiceCategoryResponse2,
zUpdateServiceData,
zUpdateServiceResponse2,
zUpdateServicesKitData,
@ -1244,6 +1263,106 @@ export const updateService = <ThrowOnError extends boolean = false>(
});
};
/**
* Get Services Categories
*/
export const getServiceCategories = <ThrowOnError extends boolean = false>(
options?: Options<GetServiceCategoriesData, ThrowOnError>
) => {
return (options?.client ?? _heyApiClient).get<
GetServiceCategoriesResponses,
unknown,
ThrowOnError
>({
requestValidator: async data => {
return await zGetServiceCategoriesData.parseAsync(data);
},
responseType: "json",
responseValidator: async data => {
return await zGetServiceCategoriesResponse2.parseAsync(data);
},
url: "/modules/fulfillment-base/service-category/",
...options,
});
};
/**
* Create Service Category
*/
export const createServiceCategory = <ThrowOnError extends boolean = false>(
options: Options<CreateServiceCategoryData, ThrowOnError>
) => {
return (options.client ?? _heyApiClient).post<
CreateServiceCategoryResponses,
CreateServiceCategoryErrors,
ThrowOnError
>({
requestValidator: async data => {
return await zCreateServiceCategoryData.parseAsync(data);
},
responseType: "json",
responseValidator: async data => {
return await zCreateServiceCategoryResponse2.parseAsync(data);
},
url: "/modules/fulfillment-base/service-category/",
...options,
headers: {
"Content-Type": "application/json",
...options.headers,
},
});
};
/**
* Delete Service Category
*/
export const deleteServiceCategory = <ThrowOnError extends boolean = false>(
options: Options<DeleteServiceCategoryData, ThrowOnError>
) => {
return (options.client ?? _heyApiClient).delete<
DeleteServiceCategoryResponses,
DeleteServiceCategoryErrors,
ThrowOnError
>({
requestValidator: async data => {
return await zDeleteServiceCategoryData.parseAsync(data);
},
responseType: "json",
responseValidator: async data => {
return await zDeleteServiceCategoryResponse2.parseAsync(data);
},
url: "/modules/fulfillment-base/service-category/{pk}",
...options,
});
};
/**
* Update Service Category
*/
export const updateServiceCategory = <ThrowOnError extends boolean = false>(
options: Options<UpdateServiceCategoryData, ThrowOnError>
) => {
return (options.client ?? _heyApiClient).patch<
UpdateServiceCategoryResponses,
UpdateServiceCategoryErrors,
ThrowOnError
>({
requestValidator: async data => {
return await zUpdateServiceCategoryData.parseAsync(data);
},
responseType: "json",
responseValidator: async data => {
return await zUpdateServiceCategoryResponse2.parseAsync(data);
},
url: "/modules/fulfillment-base/service-category/{pk}",
...options,
headers: {
"Content-Type": "application/json",
...options.headers,
},
});
};
/**
* Get Services Kits
*/

View File

@ -388,6 +388,42 @@ export type CreateProjectSchema = {
name: string;
};
/**
* CreateServiceCategoryRequest
*/
export type CreateServiceCategoryRequest = {
entity: CreateServiceCategorySchema;
};
/**
* CreateServiceCategoryResponse
*/
export type CreateServiceCategoryResponse = {
/**
* Message
*/
message: string;
entity: ServiceCategorySchema;
};
/**
* CreateServiceCategorySchema
*/
export type CreateServiceCategorySchema = {
/**
* Name
*/
name: string;
/**
* Dealservicerank
*/
dealServiceRank: string;
/**
* Productservicerank
*/
productServiceRank: string;
};
/**
* CreateServiceRequest
*/
@ -410,10 +446,6 @@ export type CreateServiceResponse = {
* CreateServiceSchema
*/
export type CreateServiceSchema = {
/**
* Id
*/
id: number;
/**
* Name
*/
@ -713,6 +745,16 @@ export type DeleteProjectResponse = {
message: string;
};
/**
* DeleteServiceCategoryResponse
*/
export type DeleteServiceCategoryResponse = {
/**
* Message
*/
message: string;
};
/**
* DeleteServiceResponse
*/
@ -814,6 +856,16 @@ export type GetProjectsResponse = {
items: Array<ProjectSchema>;
};
/**
* GetServiceCategoriesResponse
*/
export type GetServiceCategoriesResponse = {
/**
* Items
*/
items: Array<ServiceCategorySchema>;
};
/**
* GetServicesKitResponse
*/
@ -1015,10 +1067,6 @@ export type ProjectSchema = {
* ServiceCategorySchema
*/
export type ServiceCategorySchema = {
/**
* Id
*/
id: number;
/**
* Name
*/
@ -1031,6 +1079,10 @@ export type ServiceCategorySchema = {
* Productservicerank
*/
productServiceRank: string;
/**
* Id
*/
id: number;
};
/**
@ -1059,10 +1111,6 @@ export type ServicePriceRangeSchema = {
* ServiceSchema
*/
export type ServiceSchema = {
/**
* Id
*/
id: number;
/**
* Name
*/
@ -1088,6 +1136,10 @@ export type ServiceSchema = {
* Lexorank
*/
lexorank: string;
/**
* Id
*/
id: number;
};
/**
@ -1409,6 +1461,45 @@ export type UpdateProjectSchema = {
builtInModules?: Array<BuiltInModuleSchemaInput>;
};
/**
* UpdateServiceCategoryRequest
*/
export type UpdateServiceCategoryRequest = {
entity: UpdateServiceCategorySchema;
};
/**
* UpdateServiceCategoryResponse
*/
export type UpdateServiceCategoryResponse = {
/**
* Message
*/
message: string;
};
/**
* UpdateServiceCategorySchema
*/
export type UpdateServiceCategorySchema = {
/**
* Name
*/
name: string;
/**
* Dealservicerank
*/
dealServiceRank: string;
/**
* Productservicerank
*/
productServiceRank: string;
/**
* Id
*/
id: number;
};
/**
* UpdateServiceRequest
*/
@ -1430,10 +1521,6 @@ export type UpdateServiceResponse = {
* UpdateServiceSchema
*/
export type UpdateServiceSchema = {
/**
* Id
*/
id: number;
/**
* Name
*/
@ -1459,6 +1546,10 @@ export type UpdateServiceSchema = {
* Lexorank
*/
lexorank: string;
/**
* Id
*/
id: number;
};
/**
@ -2767,6 +2858,114 @@ export type UpdateServiceResponses = {
export type UpdateServiceResponse2 =
UpdateServiceResponses[keyof UpdateServiceResponses];
export type GetServiceCategoriesData = {
body?: never;
path?: never;
query?: never;
url: "/modules/fulfillment-base/service-category/";
};
export type GetServiceCategoriesResponses = {
/**
* Successful Response
*/
200: GetServiceCategoriesResponse;
};
export type GetServiceCategoriesResponse2 =
GetServiceCategoriesResponses[keyof GetServiceCategoriesResponses];
export type CreateServiceCategoryData = {
body: CreateServiceCategoryRequest;
path?: never;
query?: never;
url: "/modules/fulfillment-base/service-category/";
};
export type CreateServiceCategoryErrors = {
/**
* Validation Error
*/
422: HttpValidationError;
};
export type CreateServiceCategoryError =
CreateServiceCategoryErrors[keyof CreateServiceCategoryErrors];
export type CreateServiceCategoryResponses = {
/**
* Successful Response
*/
200: CreateServiceCategoryResponse;
};
export type CreateServiceCategoryResponse2 =
CreateServiceCategoryResponses[keyof CreateServiceCategoryResponses];
export type DeleteServiceCategoryData = {
body?: never;
path: {
/**
* Pk
*/
pk: number;
};
query?: never;
url: "/modules/fulfillment-base/service-category/{pk}";
};
export type DeleteServiceCategoryErrors = {
/**
* Validation Error
*/
422: HttpValidationError;
};
export type DeleteServiceCategoryError =
DeleteServiceCategoryErrors[keyof DeleteServiceCategoryErrors];
export type DeleteServiceCategoryResponses = {
/**
* Successful Response
*/
200: DeleteServiceCategoryResponse;
};
export type DeleteServiceCategoryResponse2 =
DeleteServiceCategoryResponses[keyof DeleteServiceCategoryResponses];
export type UpdateServiceCategoryData = {
body: UpdateServiceCategoryRequest;
path: {
/**
* Pk
*/
pk: number;
};
query?: never;
url: "/modules/fulfillment-base/service-category/{pk}";
};
export type UpdateServiceCategoryErrors = {
/**
* Validation Error
*/
422: HttpValidationError;
};
export type UpdateServiceCategoryError =
UpdateServiceCategoryErrors[keyof UpdateServiceCategoryErrors];
export type UpdateServiceCategoryResponses = {
/**
* Successful Response
*/
200: UpdateServiceCategoryResponse;
};
export type UpdateServiceCategoryResponse2 =
UpdateServiceCategoryResponses[keyof UpdateServiceCategoryResponses];
export type GetServicesKitsData = {
body?: never;
path?: never;

View File

@ -119,10 +119,10 @@ export const zProductSchema = z.object({
* ServiceCategorySchema
*/
export const zServiceCategorySchema = z.object({
id: z.int(),
name: z.string(),
dealServiceRank: z.string(),
productServiceRank: z.string(),
id: z.int(),
});
/**
@ -139,7 +139,6 @@ export const zServicePriceRangeSchema = z.object({
* ServiceSchema
*/
export const zServiceSchema = z.object({
id: z.int(),
name: z.string(),
category: zServiceCategorySchema,
price: z.number(),
@ -147,6 +146,7 @@ export const zServiceSchema = z.object({
priceRanges: z.array(zServicePriceRangeSchema),
cost: z.union([z.number(), z.null()]),
lexorank: z.string(),
id: z.int(),
});
/**
@ -351,11 +351,34 @@ export const zCreateProjectResponse = z.object({
entity: zProjectSchema,
});
/**
* CreateServiceCategorySchema
*/
export const zCreateServiceCategorySchema = z.object({
name: z.string(),
dealServiceRank: z.string(),
productServiceRank: z.string(),
});
/**
* CreateServiceCategoryRequest
*/
export const zCreateServiceCategoryRequest = z.object({
entity: zCreateServiceCategorySchema,
});
/**
* CreateServiceCategoryResponse
*/
export const zCreateServiceCategoryResponse = z.object({
message: z.string(),
entity: zServiceCategorySchema,
});
/**
* CreateServiceSchema
*/
export const zCreateServiceSchema = z.object({
id: z.int(),
name: z.string(),
category: zServiceCategorySchema,
price: z.number(),
@ -518,6 +541,13 @@ export const zDeleteProjectResponse = z.object({
message: z.string(),
});
/**
* DeleteServiceCategoryResponse
*/
export const zDeleteServiceCategoryResponse = z.object({
message: z.string(),
});
/**
* DeleteServiceResponse
*/
@ -597,6 +627,13 @@ export const zGetProjectsResponse = z.object({
items: z.array(zProjectSchema),
});
/**
* GetServiceCategoriesResponse
*/
export const zGetServiceCategoriesResponse = z.object({
items: z.array(zServiceCategorySchema),
});
/**
* GetServicesKitResponse
*/
@ -845,11 +882,34 @@ export const zUpdateProjectResponse = z.object({
message: z.string(),
});
/**
* UpdateServiceCategorySchema
*/
export const zUpdateServiceCategorySchema = z.object({
name: z.string(),
dealServiceRank: z.string(),
productServiceRank: z.string(),
id: z.int(),
});
/**
* UpdateServiceCategoryRequest
*/
export const zUpdateServiceCategoryRequest = z.object({
entity: zUpdateServiceCategorySchema,
});
/**
* UpdateServiceCategoryResponse
*/
export const zUpdateServiceCategoryResponse = z.object({
message: z.string(),
});
/**
* UpdateServiceSchema
*/
export const zUpdateServiceSchema = z.object({
id: z.int(),
name: z.string(),
category: zServiceCategorySchema,
price: z.number(),
@ -857,6 +917,7 @@ export const zUpdateServiceSchema = z.object({
priceRanges: z.array(zServicePriceRangeSchema),
cost: z.union([z.number(), z.null()]),
lexorank: z.string(),
id: z.int(),
});
/**
@ -1431,6 +1492,54 @@ export const zUpdateServiceData = z.object({
*/
export const zUpdateServiceResponse2 = zUpdateServiceResponse;
export const zGetServiceCategoriesData = z.object({
body: z.optional(z.never()),
path: z.optional(z.never()),
query: z.optional(z.never()),
});
/**
* Successful Response
*/
export const zGetServiceCategoriesResponse2 = zGetServiceCategoriesResponse;
export const zCreateServiceCategoryData = z.object({
body: zCreateServiceCategoryRequest,
path: z.optional(z.never()),
query: z.optional(z.never()),
});
/**
* Successful Response
*/
export const zCreateServiceCategoryResponse2 = zCreateServiceCategoryResponse;
export const zDeleteServiceCategoryData = z.object({
body: z.optional(z.never()),
path: z.object({
pk: z.int(),
}),
query: z.optional(z.never()),
});
/**
* Successful Response
*/
export const zDeleteServiceCategoryResponse2 = zDeleteServiceCategoryResponse;
export const zUpdateServiceCategoryData = z.object({
body: zUpdateServiceCategoryRequest,
path: z.object({
pk: z.int(),
}),
query: z.optional(z.never()),
});
/**
* Successful Response
*/
export const zUpdateServiceCategoryResponse2 = zUpdateServiceCategoryResponse;
export const zGetServicesKitsData = z.object({
body: z.optional(z.never()),
path: z.optional(z.never()),