feat: creating and updating groups
This commit is contained in:
@ -9,7 +9,6 @@ import {
|
||||
import type { AxiosError } from "axios";
|
||||
import { client as _heyApiClient } from "../client.gen";
|
||||
import {
|
||||
addDeal,
|
||||
addKitToDeal,
|
||||
addKitToDealProduct,
|
||||
createBarcodeTemplate,
|
||||
@ -31,6 +30,7 @@ import {
|
||||
deleteBoard,
|
||||
deleteClient,
|
||||
deleteDeal,
|
||||
deleteDealGroup,
|
||||
deleteDealProduct,
|
||||
deleteDealProductService,
|
||||
deleteDealService,
|
||||
@ -61,7 +61,6 @@ import {
|
||||
getServicesKits,
|
||||
getStatuses,
|
||||
getStatusHistory,
|
||||
removeDeal,
|
||||
updateBarcodeTemplate,
|
||||
updateBoard,
|
||||
updateClient,
|
||||
@ -70,6 +69,7 @@ import {
|
||||
updateDealProduct,
|
||||
updateDealProductService,
|
||||
updateDealService,
|
||||
updateDealsInGroup,
|
||||
updateMarketplace,
|
||||
updateProduct,
|
||||
updateProject,
|
||||
@ -80,9 +80,6 @@ import {
|
||||
type Options,
|
||||
} from "../sdk.gen";
|
||||
import type {
|
||||
AddDealData,
|
||||
AddDealError,
|
||||
AddDealResponse,
|
||||
AddKitToDealData,
|
||||
AddKitToDealError,
|
||||
AddKitToDealProductData,
|
||||
@ -145,6 +142,9 @@ import type {
|
||||
DeleteClientResponse2,
|
||||
DeleteDealData,
|
||||
DeleteDealError,
|
||||
DeleteDealGroupData,
|
||||
DeleteDealGroupError,
|
||||
DeleteDealGroupResponse2,
|
||||
DeleteDealProductData,
|
||||
DeleteDealProductError,
|
||||
DeleteDealProductResponse2,
|
||||
@ -204,9 +204,6 @@ import type {
|
||||
GetServicesKitsData,
|
||||
GetStatusesData,
|
||||
GetStatusHistoryData,
|
||||
RemoveDealData,
|
||||
RemoveDealError,
|
||||
RemoveDealResponse,
|
||||
UpdateBarcodeTemplateData,
|
||||
UpdateBarcodeTemplateError,
|
||||
UpdateBarcodeTemplateResponse2,
|
||||
@ -231,6 +228,9 @@ import type {
|
||||
UpdateDealServiceData,
|
||||
UpdateDealServiceError,
|
||||
UpdateDealServiceResponse2,
|
||||
UpdateDealsInGroupData,
|
||||
UpdateDealsInGroupError,
|
||||
UpdateDealsInGroupResponse2,
|
||||
UpdateMarketplaceData,
|
||||
UpdateMarketplaceError,
|
||||
UpdateMarketplaceResponse2,
|
||||
@ -621,6 +621,33 @@ export const updateDealMutation = (
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete Group
|
||||
*/
|
||||
export const deleteDealGroupMutation = (
|
||||
options?: Partial<Options<DeleteDealGroupData>>
|
||||
): UseMutationOptions<
|
||||
DeleteDealGroupResponse2,
|
||||
AxiosError<DeleteDealGroupError>,
|
||||
Options<DeleteDealGroupData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteDealGroupResponse2,
|
||||
AxiosError<DeleteDealGroupError>,
|
||||
Options<DeleteDealGroupData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await deleteDealGroup({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Group
|
||||
*/
|
||||
@ -699,43 +726,19 @@ export const createDealGroupMutation = (
|
||||
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);
|
||||
export const updateDealsInGroupQueryKey = (
|
||||
options: Options<UpdateDealsInGroupData>
|
||||
) => createQueryKey("updateDealsInGroup", options);
|
||||
|
||||
/**
|
||||
* Add Deal
|
||||
* Update Deals In Group
|
||||
*/
|
||||
export const addDealOptions = (options: Options<AddDealData>) => {
|
||||
export const updateDealsInGroupOptions = (
|
||||
options: Options<UpdateDealsInGroupData>
|
||||
) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await addDeal({
|
||||
const { data } = await updateDealsInGroup({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
@ -743,27 +746,27 @@ export const addDealOptions = (options: Options<AddDealData>) => {
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: addDealQueryKey(options),
|
||||
queryKey: updateDealsInGroupQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Add Deal
|
||||
* Update Deals In Group
|
||||
*/
|
||||
export const addDealMutation = (
|
||||
options?: Partial<Options<AddDealData>>
|
||||
export const updateDealsInGroupMutation = (
|
||||
options?: Partial<Options<UpdateDealsInGroupData>>
|
||||
): UseMutationOptions<
|
||||
AddDealResponse,
|
||||
AxiosError<AddDealError>,
|
||||
Options<AddDealData>
|
||||
UpdateDealsInGroupResponse2,
|
||||
AxiosError<UpdateDealsInGroupError>,
|
||||
Options<UpdateDealsInGroupData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
AddDealResponse,
|
||||
AxiosError<AddDealError>,
|
||||
Options<AddDealData>
|
||||
UpdateDealsInGroupResponse2,
|
||||
AxiosError<UpdateDealsInGroupError>,
|
||||
Options<UpdateDealsInGroupData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await addDeal({
|
||||
const { data } = await updateDealsInGroup({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
|
||||
Reference in New Issue
Block a user