feat: displaying and sorting groups of deals
This commit is contained in:
@ -9,12 +9,14 @@ import {
|
||||
import type { AxiosError } from "axios";
|
||||
import { client as _heyApiClient } from "../client.gen";
|
||||
import {
|
||||
addDeal,
|
||||
addKitToDeal,
|
||||
addKitToDealProduct,
|
||||
createBarcodeTemplate,
|
||||
createBoard,
|
||||
createClient,
|
||||
createDeal,
|
||||
createDealGroup,
|
||||
createDealProduct,
|
||||
createDealProductService,
|
||||
createDealService,
|
||||
@ -59,10 +61,12 @@ import {
|
||||
getServicesKits,
|
||||
getStatuses,
|
||||
getStatusHistory,
|
||||
removeDeal,
|
||||
updateBarcodeTemplate,
|
||||
updateBoard,
|
||||
updateClient,
|
||||
updateDeal,
|
||||
updateDealGroup,
|
||||
updateDealProduct,
|
||||
updateDealProductService,
|
||||
updateDealService,
|
||||
@ -76,6 +80,9 @@ import {
|
||||
type Options,
|
||||
} from "../sdk.gen";
|
||||
import type {
|
||||
AddDealData,
|
||||
AddDealError,
|
||||
AddDealResponse,
|
||||
AddKitToDealData,
|
||||
AddKitToDealError,
|
||||
AddKitToDealProductData,
|
||||
@ -93,6 +100,9 @@ import type {
|
||||
CreateClientResponse2,
|
||||
CreateDealData,
|
||||
CreateDealError,
|
||||
CreateDealGroupData,
|
||||
CreateDealGroupError,
|
||||
CreateDealGroupResponse2,
|
||||
CreateDealProductData,
|
||||
CreateDealProductError,
|
||||
CreateDealProductResponse2,
|
||||
@ -194,6 +204,9 @@ import type {
|
||||
GetServicesKitsData,
|
||||
GetStatusesData,
|
||||
GetStatusHistoryData,
|
||||
RemoveDealData,
|
||||
RemoveDealError,
|
||||
RemoveDealResponse,
|
||||
UpdateBarcodeTemplateData,
|
||||
UpdateBarcodeTemplateError,
|
||||
UpdateBarcodeTemplateResponse2,
|
||||
@ -205,6 +218,9 @@ import type {
|
||||
UpdateClientResponse2,
|
||||
UpdateDealData,
|
||||
UpdateDealError,
|
||||
UpdateDealGroupData,
|
||||
UpdateDealGroupError,
|
||||
UpdateDealGroupResponse2,
|
||||
UpdateDealProductData,
|
||||
UpdateDealProductError,
|
||||
UpdateDealProductResponse2,
|
||||
@ -605,6 +621,159 @@ export const updateDealMutation = (
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Group
|
||||
*/
|
||||
export const updateDealGroupMutation = (
|
||||
options?: Partial<Options<UpdateDealGroupData>>
|
||||
): UseMutationOptions<
|
||||
UpdateDealGroupResponse2,
|
||||
AxiosError<UpdateDealGroupError>,
|
||||
Options<UpdateDealGroupData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateDealGroupResponse2,
|
||||
AxiosError<UpdateDealGroupError>,
|
||||
Options<UpdateDealGroupData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await updateDealGroup({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const createDealGroupQueryKey = (
|
||||
options: Options<CreateDealGroupData>
|
||||
) => createQueryKey("createDealGroup", options);
|
||||
|
||||
/**
|
||||
* Create Group
|
||||
*/
|
||||
export const createDealGroupOptions = (
|
||||
options: Options<CreateDealGroupData>
|
||||
) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await createDealGroup({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: createDealGroupQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Group
|
||||
*/
|
||||
export const createDealGroupMutation = (
|
||||
options?: Partial<Options<CreateDealGroupData>>
|
||||
): UseMutationOptions<
|
||||
CreateDealGroupResponse2,
|
||||
AxiosError<CreateDealGroupError>,
|
||||
Options<CreateDealGroupData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateDealGroupResponse2,
|
||||
AxiosError<CreateDealGroupError>,
|
||||
Options<CreateDealGroupData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await createDealGroup({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove Deal
|
||||
*/
|
||||
export const removeDealMutation = (
|
||||
options?: Partial<Options<RemoveDealData>>
|
||||
): UseMutationOptions<
|
||||
RemoveDealResponse,
|
||||
AxiosError<RemoveDealError>,
|
||||
Options<RemoveDealData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
RemoveDealResponse,
|
||||
AxiosError<RemoveDealError>,
|
||||
Options<RemoveDealData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await removeDeal({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const addDealQueryKey = (options: Options<AddDealData>) =>
|
||||
createQueryKey("addDeal", options);
|
||||
|
||||
/**
|
||||
* Add Deal
|
||||
*/
|
||||
export const addDealOptions = (options: Options<AddDealData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await addDeal({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: addDealQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Add Deal
|
||||
*/
|
||||
export const addDealMutation = (
|
||||
options?: Partial<Options<AddDealData>>
|
||||
): UseMutationOptions<
|
||||
AddDealResponse,
|
||||
AxiosError<AddDealError>,
|
||||
Options<AddDealData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
AddDealResponse,
|
||||
AxiosError<AddDealError>,
|
||||
Options<AddDealData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await addDeal({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getBuiltInModulesQueryKey = (
|
||||
options?: Options<GetBuiltInModulesData>
|
||||
) => createQueryKey("getBuiltInModules", options);
|
||||
|
||||
Reference in New Issue
Block a user