feat: deal tags
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
import {
|
||||
infiniteQueryOptions,
|
||||
queryOptions,
|
||||
type DefaultError,
|
||||
type InfiniteData,
|
||||
type UseMutationOptions,
|
||||
} from "@tanstack/react-query";
|
||||
@ -19,6 +20,7 @@ import {
|
||||
createDealProduct,
|
||||
createDealProductService,
|
||||
createDealService,
|
||||
createDealTag,
|
||||
createMarketplace,
|
||||
createProduct,
|
||||
createProject,
|
||||
@ -26,7 +28,6 @@ import {
|
||||
createServiceCategory,
|
||||
createServicesKit,
|
||||
createStatus,
|
||||
createTag,
|
||||
deleteBarcodeTemplate,
|
||||
deleteBoard,
|
||||
deleteClient,
|
||||
@ -35,6 +36,7 @@ import {
|
||||
deleteDealProduct,
|
||||
deleteDealProductService,
|
||||
deleteDealService,
|
||||
deleteDealTag,
|
||||
deleteMarketplace,
|
||||
deleteProduct,
|
||||
deleteProject,
|
||||
@ -42,7 +44,6 @@ import {
|
||||
deleteServiceCategory,
|
||||
deleteServicesKit,
|
||||
deleteStatus,
|
||||
deleteTag,
|
||||
duplicateProductServices,
|
||||
getBarcodeTemplateAttributes,
|
||||
getBarcodeTemplates,
|
||||
@ -55,6 +56,7 @@ import {
|
||||
getDeals,
|
||||
getDealServices,
|
||||
getDealTagColors,
|
||||
getDealTags,
|
||||
getMarketplaces,
|
||||
getProductBarcodePdf,
|
||||
getProducts,
|
||||
@ -74,6 +76,7 @@ import {
|
||||
updateDealProductService,
|
||||
updateDealService,
|
||||
updateDealsInGroup,
|
||||
updateDealTag,
|
||||
updateMarketplace,
|
||||
updateProduct,
|
||||
updateProject,
|
||||
@ -81,7 +84,6 @@ import {
|
||||
updateServiceCategory,
|
||||
updateServicesKit,
|
||||
updateStatus,
|
||||
updateTag,
|
||||
type Options,
|
||||
} from "../sdk.gen";
|
||||
import type {
|
||||
@ -115,6 +117,9 @@ import type {
|
||||
CreateDealServiceData,
|
||||
CreateDealServiceError,
|
||||
CreateDealServiceResponse2,
|
||||
CreateDealTagData,
|
||||
CreateDealTagError,
|
||||
CreateDealTagResponse2,
|
||||
CreateMarketplaceData,
|
||||
CreateMarketplaceError,
|
||||
CreateMarketplaceResponse2,
|
||||
@ -136,9 +141,6 @@ import type {
|
||||
CreateStatusData,
|
||||
CreateStatusError,
|
||||
CreateStatusResponse2,
|
||||
CreateTagData,
|
||||
CreateTagError,
|
||||
CreateTagResponse,
|
||||
DeleteBarcodeTemplateData,
|
||||
DeleteBarcodeTemplateError,
|
||||
DeleteBarcodeTemplateResponse2,
|
||||
@ -163,6 +165,9 @@ import type {
|
||||
DeleteDealServiceData,
|
||||
DeleteDealServiceError,
|
||||
DeleteDealServiceResponse2,
|
||||
DeleteDealTagData,
|
||||
DeleteDealTagError,
|
||||
DeleteDealTagResponse2,
|
||||
DeleteMarketplaceData,
|
||||
DeleteMarketplaceError,
|
||||
DeleteMarketplaceResponse2,
|
||||
@ -184,9 +189,6 @@ import type {
|
||||
DeleteStatusData,
|
||||
DeleteStatusError,
|
||||
DeleteStatusResponse2,
|
||||
DeleteTagData,
|
||||
DeleteTagError,
|
||||
DeleteTagResponse,
|
||||
DuplicateProductServicesData,
|
||||
DuplicateProductServicesError,
|
||||
DuplicateProductServicesResponse,
|
||||
@ -203,6 +205,8 @@ import type {
|
||||
GetDealServicesData,
|
||||
GetDealsResponse2,
|
||||
GetDealTagColorsData,
|
||||
GetDealTagColorsResponse,
|
||||
GetDealTagsData,
|
||||
GetMarketplacesData,
|
||||
GetProductBarcodePdfData,
|
||||
GetProductBarcodePdfError,
|
||||
@ -246,6 +250,9 @@ import type {
|
||||
UpdateDealsInGroupData,
|
||||
UpdateDealsInGroupError,
|
||||
UpdateDealsInGroupResponse2,
|
||||
UpdateDealTagData,
|
||||
UpdateDealTagError,
|
||||
UpdateDealTagResponse2,
|
||||
UpdateMarketplaceData,
|
||||
UpdateMarketplaceError,
|
||||
UpdateMarketplaceResponse2,
|
||||
@ -267,9 +274,6 @@ import type {
|
||||
UpdateStatusData,
|
||||
UpdateStatusError,
|
||||
UpdateStatusResponse2,
|
||||
UpdateTagData,
|
||||
UpdateTagError,
|
||||
UpdateTagResponse,
|
||||
} from "../types.gen";
|
||||
|
||||
export type QueryKey<TOptions extends Options> = [
|
||||
@ -795,43 +799,16 @@ export const updateDealsInGroupMutation = (
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Tag
|
||||
*/
|
||||
export const updateTagMutation = (
|
||||
options?: Partial<Options<UpdateTagData>>
|
||||
): UseMutationOptions<
|
||||
UpdateTagResponse,
|
||||
AxiosError<UpdateTagError>,
|
||||
Options<UpdateTagData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateTagResponse,
|
||||
AxiosError<UpdateTagError>,
|
||||
Options<UpdateTagData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await updateTag({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const createTagQueryKey = (options: Options<CreateTagData>) =>
|
||||
createQueryKey("createTag", options);
|
||||
export const getDealTagsQueryKey = (options: Options<GetDealTagsData>) =>
|
||||
createQueryKey("getDealTags", options);
|
||||
|
||||
/**
|
||||
* Create Tag
|
||||
* Get Deal Tags
|
||||
*/
|
||||
export const createTagOptions = (options: Options<CreateTagData>) => {
|
||||
export const getDealTagsOptions = (options: Options<GetDealTagsData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await createTag({
|
||||
const { data } = await getDealTags({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
@ -839,27 +816,48 @@ export const createTagOptions = (options: Options<CreateTagData>) => {
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: createTagQueryKey(options),
|
||||
queryKey: getDealTagsQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const createDealTagQueryKey = (options: Options<CreateDealTagData>) =>
|
||||
createQueryKey("createDealTag", options);
|
||||
|
||||
/**
|
||||
* Create Deal Tag
|
||||
*/
|
||||
export const createDealTagOptions = (options: Options<CreateDealTagData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await createDealTag({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: createDealTagQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Tag
|
||||
* Create Deal Tag
|
||||
*/
|
||||
export const createTagMutation = (
|
||||
options?: Partial<Options<CreateTagData>>
|
||||
export const createDealTagMutation = (
|
||||
options?: Partial<Options<CreateDealTagData>>
|
||||
): UseMutationOptions<
|
||||
CreateTagResponse,
|
||||
AxiosError<CreateTagError>,
|
||||
Options<CreateTagData>
|
||||
CreateDealTagResponse2,
|
||||
AxiosError<CreateDealTagError>,
|
||||
Options<CreateDealTagData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateTagResponse,
|
||||
AxiosError<CreateTagError>,
|
||||
Options<CreateTagData>
|
||||
CreateDealTagResponse2,
|
||||
AxiosError<CreateDealTagError>,
|
||||
Options<CreateDealTagData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await createTag({
|
||||
const { data } = await createDealTag({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
@ -871,22 +869,49 @@ export const createTagMutation = (
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete Tag
|
||||
* Delete Deal Tag
|
||||
*/
|
||||
export const deleteTagMutation = (
|
||||
options?: Partial<Options<DeleteTagData>>
|
||||
export const deleteDealTagMutation = (
|
||||
options?: Partial<Options<DeleteDealTagData>>
|
||||
): UseMutationOptions<
|
||||
DeleteTagResponse,
|
||||
AxiosError<DeleteTagError>,
|
||||
Options<DeleteTagData>
|
||||
DeleteDealTagResponse2,
|
||||
AxiosError<DeleteDealTagError>,
|
||||
Options<DeleteDealTagData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteTagResponse,
|
||||
AxiosError<DeleteTagError>,
|
||||
Options<DeleteTagData>
|
||||
DeleteDealTagResponse2,
|
||||
AxiosError<DeleteDealTagError>,
|
||||
Options<DeleteDealTagData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await deleteTag({
|
||||
const { data } = await deleteDealTag({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Deal Tag
|
||||
*/
|
||||
export const updateDealTagMutation = (
|
||||
options?: Partial<Options<UpdateDealTagData>>
|
||||
): UseMutationOptions<
|
||||
UpdateDealTagResponse2,
|
||||
AxiosError<UpdateDealTagError>,
|
||||
Options<UpdateDealTagData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateDealTagResponse2,
|
||||
AxiosError<UpdateDealTagError>,
|
||||
Options<UpdateDealTagData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await updateDealTag({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
@ -969,6 +994,33 @@ export const getDealTagColorsOptions = (
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Deal Tag Colors
|
||||
*/
|
||||
export const getDealTagColorsMutation = (
|
||||
options?: Partial<Options<GetDealTagColorsData>>
|
||||
): UseMutationOptions<
|
||||
GetDealTagColorsResponse,
|
||||
AxiosError<DefaultError>,
|
||||
Options<GetDealTagColorsData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
GetDealTagColorsResponse,
|
||||
AxiosError<DefaultError>,
|
||||
Options<GetDealTagColorsData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await getDealTagColors({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getBuiltInModulesQueryKey = (
|
||||
options?: Options<GetBuiltInModulesData>
|
||||
) => createQueryKey("getBuiltInModules", options);
|
||||
|
||||
Reference in New Issue
Block a user