feat: modules creation
This commit is contained in:
@ -24,6 +24,7 @@ import {
|
||||
createDealService,
|
||||
createDealTag,
|
||||
createMarketplace,
|
||||
createModule,
|
||||
createProduct,
|
||||
createProject,
|
||||
createService,
|
||||
@ -144,6 +145,9 @@ import type {
|
||||
CreateMarketplaceData,
|
||||
CreateMarketplaceError,
|
||||
CreateMarketplaceResponse2,
|
||||
CreateModuleData,
|
||||
CreateModuleError,
|
||||
CreateModuleResponse2,
|
||||
CreateProductData,
|
||||
CreateProductError,
|
||||
CreateProductResponse2,
|
||||
@ -1295,6 +1299,54 @@ export const getModulesOptions = (options?: Options<GetModulesData>) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const createModuleQueryKey = (options: Options<CreateModuleData>) =>
|
||||
createQueryKey("createModule", options);
|
||||
|
||||
/**
|
||||
* Create Module
|
||||
*/
|
||||
export const createModuleOptions = (options: Options<CreateModuleData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await createModule({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: createModuleQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Module
|
||||
*/
|
||||
export const createModuleMutation = (
|
||||
options?: Partial<Options<CreateModuleData>>
|
||||
): UseMutationOptions<
|
||||
CreateModuleResponse2,
|
||||
AxiosError<CreateModuleError>,
|
||||
Options<CreateModuleData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateModuleResponse2,
|
||||
AxiosError<CreateModuleError>,
|
||||
Options<CreateModuleData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await createModule({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getModulesWithAttributesQueryKey = (
|
||||
options?: Options<GetModulesWithAttributesData>
|
||||
) => createQueryKey("getModulesWithAttributes", options);
|
||||
|
||||
Reference in New Issue
Block a user