feat: modules and module-editor pages

This commit is contained in:
2025-10-25 12:11:14 +04:00
parent 57a7ab0871
commit 2bdbebc453
40 changed files with 3485 additions and 38 deletions

View File

@ -10,8 +10,10 @@ import {
import type { AxiosError } from "axios";
import { client as _heyApiClient } from "../client.gen";
import {
addAttributeToModule,
addKitToDeal,
addKitToDealProduct,
createAttribute,
createBarcodeTemplate,
createBoard,
createClient,
@ -28,6 +30,7 @@ import {
createServiceCategory,
createServicesKit,
createStatus,
deleteAttribute,
deleteBarcodeTemplate,
deleteBoard,
deleteClient,
@ -38,6 +41,7 @@ import {
deleteDealService,
deleteDealTag,
deleteMarketplace,
deleteModule,
deleteProduct,
deleteProductBarcodeImage,
deleteProject,
@ -46,6 +50,8 @@ import {
deleteServicesKit,
deleteStatus,
duplicateProductServices,
getAttributes,
getAttributeTypes,
getBarcodeTemplateAttributes,
getBarcodeTemplates,
getBarcodeTemplateSizes,
@ -59,6 +65,8 @@ import {
getDealTags,
getMarketplaces,
getModules,
getModulesWithAttributes,
getModuleWithAttributes,
getProductBarcodePdf,
getProducts,
getProjects,
@ -67,7 +75,10 @@ import {
getServicesKits,
getStatuses,
getStatusHistory,
removeAttributeFromModule,
switchDealTag,
updateAttribute,
updateAttributeLabel,
updateBarcodeTemplate,
updateBoard,
updateClient,
@ -79,6 +90,7 @@ import {
updateDealsInGroup,
updateDealTag,
updateMarketplace,
updateModule,
updateProduct,
updateProject,
updateService,
@ -90,12 +102,18 @@ import {
type Options,
} from "../sdk.gen";
import type {
AddAttributeToModuleData,
AddAttributeToModuleError,
AddAttributeToModuleResponse,
AddKitToDealData,
AddKitToDealError,
AddKitToDealProductData,
AddKitToDealProductError,
AddKitToDealProductResponse,
AddKitToDealResponse,
CreateAttributeData,
CreateAttributeError,
CreateAttributeResponse2,
CreateBarcodeTemplateData,
CreateBarcodeTemplateError,
CreateBarcodeTemplateResponse2,
@ -144,6 +162,9 @@ import type {
CreateStatusData,
CreateStatusError,
CreateStatusResponse2,
DeleteAttributeData,
DeleteAttributeError,
DeleteAttributeResponse2,
DeleteBarcodeTemplateData,
DeleteBarcodeTemplateError,
DeleteBarcodeTemplateResponse2,
@ -174,6 +195,9 @@ import type {
DeleteMarketplaceData,
DeleteMarketplaceError,
DeleteMarketplaceResponse2,
DeleteModuleData,
DeleteModuleError,
DeleteModuleResponse2,
DeleteProductBarcodeImageData,
DeleteProductBarcodeImageError,
DeleteProductBarcodeImageResponse,
@ -198,6 +222,8 @@ import type {
DuplicateProductServicesData,
DuplicateProductServicesError,
DuplicateProductServicesResponse,
GetAttributesData,
GetAttributeTypesData,
GetBarcodeTemplateAttributesData,
GetBarcodeTemplatesData,
GetBarcodeTemplateSizesData,
@ -214,6 +240,8 @@ import type {
GetDealTagsData,
GetMarketplacesData,
GetModulesData,
GetModulesWithAttributesData,
GetModuleWithAttributesData,
GetProductBarcodePdfData,
GetProductBarcodePdfError,
GetProductBarcodePdfResponse2,
@ -226,9 +254,18 @@ import type {
GetServicesKitsData,
GetStatusesData,
GetStatusHistoryData,
RemoveAttributeFromModuleData,
RemoveAttributeFromModuleError,
RemoveAttributeFromModuleResponse,
SwitchDealTagData,
SwitchDealTagError,
SwitchDealTagResponse2,
UpdateAttributeData,
UpdateAttributeError,
UpdateAttributeLabelData,
UpdateAttributeLabelError,
UpdateAttributeLabelResponse2,
UpdateAttributeResponse2,
UpdateBarcodeTemplateData,
UpdateBarcodeTemplateError,
UpdateBarcodeTemplateResponse2,
@ -262,6 +299,9 @@ import type {
UpdateMarketplaceData,
UpdateMarketplaceError,
UpdateMarketplaceResponse2,
UpdateModuleData,
UpdateModuleError,
UpdateModuleResponse,
UpdateProductData,
UpdateProductError,
UpdateProductResponse2,
@ -324,6 +364,207 @@ const createQueryKey = <TOptions extends Options>(
return [params];
};
export const getAttributesQueryKey = (options?: Options<GetAttributesData>) =>
createQueryKey("getAttributes", options);
/**
* Get Attributes
*/
export const getAttributesOptions = (options?: Options<GetAttributesData>) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getAttributes({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: getAttributesQueryKey(options),
});
};
export const createAttributeQueryKey = (
options: Options<CreateAttributeData>
) => createQueryKey("createAttribute", options);
/**
* Create Attribute
*/
export const createAttributeOptions = (
options: Options<CreateAttributeData>
) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await createAttribute({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: createAttributeQueryKey(options),
});
};
/**
* Create Attribute
*/
export const createAttributeMutation = (
options?: Partial<Options<CreateAttributeData>>
): UseMutationOptions<
CreateAttributeResponse2,
AxiosError<CreateAttributeError>,
Options<CreateAttributeData>
> => {
const mutationOptions: UseMutationOptions<
CreateAttributeResponse2,
AxiosError<CreateAttributeError>,
Options<CreateAttributeData>
> = {
mutationFn: async localOptions => {
const { data } = await createAttribute({
...options,
...localOptions,
throwOnError: true,
});
return data;
},
};
return mutationOptions;
};
/**
* Delete Attribute
*/
export const deleteAttributeMutation = (
options?: Partial<Options<DeleteAttributeData>>
): UseMutationOptions<
DeleteAttributeResponse2,
AxiosError<DeleteAttributeError>,
Options<DeleteAttributeData>
> => {
const mutationOptions: UseMutationOptions<
DeleteAttributeResponse2,
AxiosError<DeleteAttributeError>,
Options<DeleteAttributeData>
> = {
mutationFn: async localOptions => {
const { data } = await deleteAttribute({
...options,
...localOptions,
throwOnError: true,
});
return data;
},
};
return mutationOptions;
};
/**
* Update Attribute
*/
export const updateAttributeMutation = (
options?: Partial<Options<UpdateAttributeData>>
): UseMutationOptions<
UpdateAttributeResponse2,
AxiosError<UpdateAttributeError>,
Options<UpdateAttributeData>
> => {
const mutationOptions: UseMutationOptions<
UpdateAttributeResponse2,
AxiosError<UpdateAttributeError>,
Options<UpdateAttributeData>
> = {
mutationFn: async localOptions => {
const { data } = await updateAttribute({
...options,
...localOptions,
throwOnError: true,
});
return data;
},
};
return mutationOptions;
};
export const updateAttributeLabelQueryKey = (
options: Options<UpdateAttributeLabelData>
) => createQueryKey("updateAttributeLabel", options);
/**
* Update Attribute Label
*/
export const updateAttributeLabelOptions = (
options: Options<UpdateAttributeLabelData>
) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await updateAttributeLabel({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: updateAttributeLabelQueryKey(options),
});
};
/**
* Update Attribute Label
*/
export const updateAttributeLabelMutation = (
options?: Partial<Options<UpdateAttributeLabelData>>
): UseMutationOptions<
UpdateAttributeLabelResponse2,
AxiosError<UpdateAttributeLabelError>,
Options<UpdateAttributeLabelData>
> => {
const mutationOptions: UseMutationOptions<
UpdateAttributeLabelResponse2,
AxiosError<UpdateAttributeLabelError>,
Options<UpdateAttributeLabelData>
> = {
mutationFn: async localOptions => {
const { data } = await updateAttributeLabel({
...options,
...localOptions,
throwOnError: true,
});
return data;
},
};
return mutationOptions;
};
export const getAttributeTypesQueryKey = (
options?: Options<GetAttributeTypesData>
) => createQueryKey("getAttributeTypes", options);
/**
* Get Attribute Types
*/
export const getAttributeTypesOptions = (
options?: Options<GetAttributeTypesData>
) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getAttributeTypes({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: getAttributeTypesQueryKey(options),
});
};
export const getBoardsQueryKey = (options: Options<GetBoardsData>) =>
createQueryKey("getBoards", options);
@ -1054,6 +1295,186 @@ export const getModulesOptions = (options?: Options<GetModulesData>) => {
});
};
export const getModulesWithAttributesQueryKey = (
options?: Options<GetModulesWithAttributesData>
) => createQueryKey("getModulesWithAttributes", options);
/**
* Get Modules With Attributes
*/
export const getModulesWithAttributesOptions = (
options?: Options<GetModulesWithAttributesData>
) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getModulesWithAttributes({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: getModulesWithAttributesQueryKey(options),
});
};
export const getModuleWithAttributesQueryKey = (
options: Options<GetModuleWithAttributesData>
) => createQueryKey("getModuleWithAttributes", options);
/**
* Get Module With Attributes
*/
export const getModuleWithAttributesOptions = (
options: Options<GetModuleWithAttributesData>
) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getModuleWithAttributes({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: getModuleWithAttributesQueryKey(options),
});
};
/**
* Update Module Common Info
*/
export const updateModuleMutation = (
options?: Partial<Options<UpdateModuleData>>
): UseMutationOptions<
UpdateModuleResponse,
AxiosError<UpdateModuleError>,
Options<UpdateModuleData>
> => {
const mutationOptions: UseMutationOptions<
UpdateModuleResponse,
AxiosError<UpdateModuleError>,
Options<UpdateModuleData>
> = {
mutationFn: async localOptions => {
const { data } = await updateModule({
...options,
...localOptions,
throwOnError: true,
});
return data;
},
};
return mutationOptions;
};
/**
* Delete Module
*/
export const deleteModuleMutation = (
options?: Partial<Options<DeleteModuleData>>
): UseMutationOptions<
DeleteModuleResponse2,
AxiosError<DeleteModuleError>,
Options<DeleteModuleData>
> => {
const mutationOptions: UseMutationOptions<
DeleteModuleResponse2,
AxiosError<DeleteModuleError>,
Options<DeleteModuleData>
> = {
mutationFn: async localOptions => {
const { data } = await deleteModule({
...options,
...localOptions,
throwOnError: true,
});
return data;
},
};
return mutationOptions;
};
/**
* Remove Attribute From Module
*/
export const removeAttributeFromModuleMutation = (
options?: Partial<Options<RemoveAttributeFromModuleData>>
): UseMutationOptions<
RemoveAttributeFromModuleResponse,
AxiosError<RemoveAttributeFromModuleError>,
Options<RemoveAttributeFromModuleData>
> => {
const mutationOptions: UseMutationOptions<
RemoveAttributeFromModuleResponse,
AxiosError<RemoveAttributeFromModuleError>,
Options<RemoveAttributeFromModuleData>
> = {
mutationFn: async localOptions => {
const { data } = await removeAttributeFromModule({
...options,
...localOptions,
throwOnError: true,
});
return data;
},
};
return mutationOptions;
};
export const addAttributeToModuleQueryKey = (
options: Options<AddAttributeToModuleData>
) => createQueryKey("addAttributeToModule", options);
/**
* Add Attribute To Module
*/
export const addAttributeToModuleOptions = (
options: Options<AddAttributeToModuleData>
) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await addAttributeToModule({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: addAttributeToModuleQueryKey(options),
});
};
/**
* Add Attribute To Module
*/
export const addAttributeToModuleMutation = (
options?: Partial<Options<AddAttributeToModuleData>>
): UseMutationOptions<
AddAttributeToModuleResponse,
AxiosError<AddAttributeToModuleError>,
Options<AddAttributeToModuleData>
> => {
const mutationOptions: UseMutationOptions<
AddAttributeToModuleResponse,
AxiosError<AddAttributeToModuleError>,
Options<AddAttributeToModuleData>
> = {
mutationFn: async localOptions => {
const { data } = await addAttributeToModule({
...options,
...localOptions,
throwOnError: true,
});
return data;
},
};
return mutationOptions;
};
export const getClientsQueryKey = (options?: Options<GetClientsData>) =>
createQueryKey("getClients", options);