feat: deal attributes editing
This commit is contained in:
@ -59,6 +59,7 @@ import {
|
||||
getBaseMarketplaces,
|
||||
getBoards,
|
||||
getClients,
|
||||
getDealModuleAttributes,
|
||||
getDealProducts,
|
||||
getDeals,
|
||||
getDealServices,
|
||||
@ -85,6 +86,7 @@ import {
|
||||
updateClient,
|
||||
updateDeal,
|
||||
updateDealGroup,
|
||||
updateDealModuleAttributes,
|
||||
updateDealProduct,
|
||||
updateDealProductService,
|
||||
updateDealService,
|
||||
@ -234,6 +236,7 @@ import type {
|
||||
GetBaseMarketplacesData,
|
||||
GetBoardsData,
|
||||
GetClientsData,
|
||||
GetDealModuleAttributesData,
|
||||
GetDealProductsData,
|
||||
GetDealsData,
|
||||
GetDealsError,
|
||||
@ -284,6 +287,9 @@ import type {
|
||||
UpdateDealGroupData,
|
||||
UpdateDealGroupError,
|
||||
UpdateDealGroupResponse2,
|
||||
UpdateDealModuleAttributesData,
|
||||
UpdateDealModuleAttributesError,
|
||||
UpdateDealModuleAttributesResponse2,
|
||||
UpdateDealProductData,
|
||||
UpdateDealProductError,
|
||||
UpdateDealProductResponse2,
|
||||
@ -569,6 +575,81 @@ export const getAttributeTypesOptions = (
|
||||
});
|
||||
};
|
||||
|
||||
export const getDealModuleAttributesQueryKey = (
|
||||
options: Options<GetDealModuleAttributesData>
|
||||
) => createQueryKey("getDealModuleAttributes", options);
|
||||
|
||||
/**
|
||||
* Get Deal Module Attributes
|
||||
*/
|
||||
export const getDealModuleAttributesOptions = (
|
||||
options: Options<GetDealModuleAttributesData>
|
||||
) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getDealModuleAttributes({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getDealModuleAttributesQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const updateDealModuleAttributesQueryKey = (
|
||||
options: Options<UpdateDealModuleAttributesData>
|
||||
) => createQueryKey("updateDealModuleAttributes", options);
|
||||
|
||||
/**
|
||||
* Update Deal Module Attributes
|
||||
*/
|
||||
export const updateDealModuleAttributesOptions = (
|
||||
options: Options<UpdateDealModuleAttributesData>
|
||||
) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await updateDealModuleAttributes({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: updateDealModuleAttributesQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Deal Module Attributes
|
||||
*/
|
||||
export const updateDealModuleAttributesMutation = (
|
||||
options?: Partial<Options<UpdateDealModuleAttributesData>>
|
||||
): UseMutationOptions<
|
||||
UpdateDealModuleAttributesResponse2,
|
||||
AxiosError<UpdateDealModuleAttributesError>,
|
||||
Options<UpdateDealModuleAttributesData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateDealModuleAttributesResponse2,
|
||||
AxiosError<UpdateDealModuleAttributesError>,
|
||||
Options<UpdateDealModuleAttributesData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await updateDealModuleAttributes({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getBoardsQueryKey = (options: Options<GetBoardsData>) =>
|
||||
createQueryKey("getBoards", options);
|
||||
|
||||
|
||||
@ -149,6 +149,9 @@ import type {
|
||||
GetClientsData,
|
||||
GetClientsErrors,
|
||||
GetClientsResponses,
|
||||
GetDealModuleAttributesData,
|
||||
GetDealModuleAttributesErrors,
|
||||
GetDealModuleAttributesResponses,
|
||||
GetDealProductsData,
|
||||
GetDealProductsErrors,
|
||||
GetDealProductsResponses,
|
||||
@ -219,6 +222,9 @@ import type {
|
||||
UpdateDealGroupData,
|
||||
UpdateDealGroupErrors,
|
||||
UpdateDealGroupResponses,
|
||||
UpdateDealModuleAttributesData,
|
||||
UpdateDealModuleAttributesErrors,
|
||||
UpdateDealModuleAttributesResponses,
|
||||
UpdateDealProductData,
|
||||
UpdateDealProductErrors,
|
||||
UpdateDealProductResponses,
|
||||
@ -365,6 +371,8 @@ import {
|
||||
zGetBoardsResponse2,
|
||||
zGetClientsData,
|
||||
zGetClientsResponse2,
|
||||
zGetDealModuleAttributesData,
|
||||
zGetDealModuleAttributesResponse2,
|
||||
zGetDealProductsData,
|
||||
zGetDealProductsResponse2,
|
||||
zGetDealsData,
|
||||
@ -416,6 +424,8 @@ import {
|
||||
zUpdateDealData,
|
||||
zUpdateDealGroupData,
|
||||
zUpdateDealGroupResponse2,
|
||||
zUpdateDealModuleAttributesData,
|
||||
zUpdateDealModuleAttributesResponse2,
|
||||
zUpdateDealProductData,
|
||||
zUpdateDealProductResponse2,
|
||||
zUpdateDealProductServiceData,
|
||||
@ -616,6 +626,58 @@ export const getAttributeTypes = <ThrowOnError extends boolean = false>(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Deal Module Attributes
|
||||
*/
|
||||
export const getDealModuleAttributes = <ThrowOnError extends boolean = false>(
|
||||
options: Options<GetDealModuleAttributesData, ThrowOnError>
|
||||
) => {
|
||||
return (options.client ?? _heyApiClient).get<
|
||||
GetDealModuleAttributesResponses,
|
||||
GetDealModuleAttributesErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
requestValidator: async data => {
|
||||
return await zGetDealModuleAttributesData.parseAsync(data);
|
||||
},
|
||||
responseType: "json",
|
||||
responseValidator: async data => {
|
||||
return await zGetDealModuleAttributesResponse2.parseAsync(data);
|
||||
},
|
||||
url: "/crm/v1/attribute/deal/{dealId}/module/{moduleId}",
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Deal Module Attributes
|
||||
*/
|
||||
export const updateDealModuleAttributes = <
|
||||
ThrowOnError extends boolean = false,
|
||||
>(
|
||||
options: Options<UpdateDealModuleAttributesData, ThrowOnError>
|
||||
) => {
|
||||
return (options.client ?? _heyApiClient).post<
|
||||
UpdateDealModuleAttributesResponses,
|
||||
UpdateDealModuleAttributesErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
requestValidator: async data => {
|
||||
return await zUpdateDealModuleAttributesData.parseAsync(data);
|
||||
},
|
||||
responseType: "json",
|
||||
responseValidator: async data => {
|
||||
return await zUpdateDealModuleAttributesResponse2.parseAsync(data);
|
||||
},
|
||||
url: "/crm/v1/attribute/deal/{dealId}/module/{moduleId}",
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options.headers,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Boards
|
||||
*/
|
||||
|
||||
@ -1034,6 +1034,57 @@ export type DealGroupSchema = {
|
||||
lexorank: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* DealModuleAttributeSchema
|
||||
*/
|
||||
export type DealModuleAttributeSchema = {
|
||||
/**
|
||||
* Attributeid
|
||||
*/
|
||||
attributeId: number;
|
||||
/**
|
||||
* Label
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
* Originallabel
|
||||
*/
|
||||
originalLabel: string;
|
||||
/**
|
||||
* Value
|
||||
*/
|
||||
value: {
|
||||
[key: string]: unknown;
|
||||
} | null;
|
||||
type: AttributeTypeSchema;
|
||||
/**
|
||||
* Defaultvalue
|
||||
*/
|
||||
defaultValue: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
/**
|
||||
* Description
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* Isapplicabletogroup
|
||||
*/
|
||||
isApplicableToGroup: boolean;
|
||||
/**
|
||||
* Isshownondashboard
|
||||
*/
|
||||
isShownOnDashboard: boolean;
|
||||
/**
|
||||
* Ishighlightifexpired
|
||||
*/
|
||||
isHighlightIfExpired: boolean;
|
||||
/**
|
||||
* Isnullable
|
||||
*/
|
||||
isNullable: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* DealProductAddKitRequest
|
||||
*/
|
||||
@ -1510,6 +1561,16 @@ export type GetClientsResponse = {
|
||||
items: Array<ClientSchema>;
|
||||
};
|
||||
|
||||
/**
|
||||
* GetDealModuleAttributesResponse
|
||||
*/
|
||||
export type GetDealModuleAttributesResponse = {
|
||||
/**
|
||||
* Attributes
|
||||
*/
|
||||
attributes: Array<DealModuleAttributeSchema>;
|
||||
};
|
||||
|
||||
/**
|
||||
* GetDealProductsResponse
|
||||
*/
|
||||
@ -2501,6 +2562,42 @@ export type UpdateDealGroupSchema = {
|
||||
statusId?: number | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* UpdateDealModuleAttributeSchema
|
||||
*/
|
||||
export type UpdateDealModuleAttributeSchema = {
|
||||
/**
|
||||
* Attributeid
|
||||
*/
|
||||
attributeId: number;
|
||||
/**
|
||||
* Value
|
||||
*/
|
||||
value: {
|
||||
[key: string]: unknown;
|
||||
} | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* UpdateDealModuleAttributesRequest
|
||||
*/
|
||||
export type UpdateDealModuleAttributesRequest = {
|
||||
/**
|
||||
* Attributes
|
||||
*/
|
||||
attributes: Array<UpdateDealModuleAttributeSchema>;
|
||||
};
|
||||
|
||||
/**
|
||||
* UpdateDealModuleAttributesResponse
|
||||
*/
|
||||
export type UpdateDealModuleAttributesResponse = {
|
||||
/**
|
||||
* Message
|
||||
*/
|
||||
message: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* UpdateDealProductRequest
|
||||
*/
|
||||
@ -3177,6 +3274,78 @@ export type GetAttributeTypesResponses = {
|
||||
export type GetAttributeTypesResponse =
|
||||
GetAttributeTypesResponses[keyof GetAttributeTypesResponses];
|
||||
|
||||
export type GetDealModuleAttributesData = {
|
||||
body?: never;
|
||||
path: {
|
||||
/**
|
||||
* Dealid
|
||||
*/
|
||||
dealId: number;
|
||||
/**
|
||||
* Moduleid
|
||||
*/
|
||||
moduleId: number;
|
||||
};
|
||||
query?: never;
|
||||
url: "/crm/v1/attribute/deal/{dealId}/module/{moduleId}";
|
||||
};
|
||||
|
||||
export type GetDealModuleAttributesErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type GetDealModuleAttributesError =
|
||||
GetDealModuleAttributesErrors[keyof GetDealModuleAttributesErrors];
|
||||
|
||||
export type GetDealModuleAttributesResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: GetDealModuleAttributesResponse;
|
||||
};
|
||||
|
||||
export type GetDealModuleAttributesResponse2 =
|
||||
GetDealModuleAttributesResponses[keyof GetDealModuleAttributesResponses];
|
||||
|
||||
export type UpdateDealModuleAttributesData = {
|
||||
body: UpdateDealModuleAttributesRequest;
|
||||
path: {
|
||||
/**
|
||||
* Dealid
|
||||
*/
|
||||
dealId: number;
|
||||
/**
|
||||
* Moduleid
|
||||
*/
|
||||
moduleId: number;
|
||||
};
|
||||
query?: never;
|
||||
url: "/crm/v1/attribute/deal/{dealId}/module/{moduleId}";
|
||||
};
|
||||
|
||||
export type UpdateDealModuleAttributesErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type UpdateDealModuleAttributesError =
|
||||
UpdateDealModuleAttributesErrors[keyof UpdateDealModuleAttributesErrors];
|
||||
|
||||
export type UpdateDealModuleAttributesResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: UpdateDealModuleAttributesResponse;
|
||||
};
|
||||
|
||||
export type UpdateDealModuleAttributesResponse2 =
|
||||
UpdateDealModuleAttributesResponses[keyof UpdateDealModuleAttributesResponses];
|
||||
|
||||
export type GetBoardsData = {
|
||||
body?: never;
|
||||
path: {
|
||||
|
||||
@ -827,6 +827,23 @@ export const zDealAddKitResponse = z.object({
|
||||
message: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* DealModuleAttributeSchema
|
||||
*/
|
||||
export const zDealModuleAttributeSchema = z.object({
|
||||
attributeId: z.int(),
|
||||
label: z.string(),
|
||||
originalLabel: z.string(),
|
||||
value: z.union([z.object({}), z.null()]),
|
||||
type: zAttributeTypeSchema,
|
||||
defaultValue: z.object({}),
|
||||
description: z.string(),
|
||||
isApplicableToGroup: z.boolean(),
|
||||
isShownOnDashboard: z.boolean(),
|
||||
isHighlightIfExpired: z.boolean(),
|
||||
isNullable: z.boolean(),
|
||||
});
|
||||
|
||||
/**
|
||||
* DealProductAddKitRequest
|
||||
*/
|
||||
@ -1093,6 +1110,13 @@ export const zGetClientsResponse = z.object({
|
||||
items: z.array(zClientSchema),
|
||||
});
|
||||
|
||||
/**
|
||||
* GetDealModuleAttributesResponse
|
||||
*/
|
||||
export const zGetDealModuleAttributesResponse = z.object({
|
||||
attributes: z.array(zDealModuleAttributeSchema),
|
||||
});
|
||||
|
||||
/**
|
||||
* GetDealProductsResponse
|
||||
*/
|
||||
@ -1441,6 +1465,28 @@ export const zUpdateDealGroupResponse = z.object({
|
||||
message: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* UpdateDealModuleAttributeSchema
|
||||
*/
|
||||
export const zUpdateDealModuleAttributeSchema = z.object({
|
||||
attributeId: z.int(),
|
||||
value: z.union([z.object({}), z.null()]),
|
||||
});
|
||||
|
||||
/**
|
||||
* UpdateDealModuleAttributesRequest
|
||||
*/
|
||||
export const zUpdateDealModuleAttributesRequest = z.object({
|
||||
attributes: z.array(zUpdateDealModuleAttributeSchema),
|
||||
});
|
||||
|
||||
/**
|
||||
* UpdateDealModuleAttributesResponse
|
||||
*/
|
||||
export const zUpdateDealModuleAttributesResponse = z.object({
|
||||
message: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* UpdateDealProductSchema
|
||||
*/
|
||||
@ -1837,6 +1883,36 @@ export const zGetAttributeTypesData = z.object({
|
||||
*/
|
||||
export const zGetAttributeTypesResponse = zGetAllAttributeTypesResponse;
|
||||
|
||||
export const zGetDealModuleAttributesData = z.object({
|
||||
body: z.optional(z.never()),
|
||||
path: z.object({
|
||||
dealId: z.int(),
|
||||
moduleId: z.int(),
|
||||
}),
|
||||
query: z.optional(z.never()),
|
||||
});
|
||||
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
export const zGetDealModuleAttributesResponse2 =
|
||||
zGetDealModuleAttributesResponse;
|
||||
|
||||
export const zUpdateDealModuleAttributesData = z.object({
|
||||
body: zUpdateDealModuleAttributesRequest,
|
||||
path: z.object({
|
||||
dealId: z.int(),
|
||||
moduleId: z.int(),
|
||||
}),
|
||||
query: z.optional(z.never()),
|
||||
});
|
||||
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
export const zUpdateDealModuleAttributesResponse2 =
|
||||
zUpdateDealModuleAttributesResponse;
|
||||
|
||||
export const zGetBoardsData = z.object({
|
||||
body: z.optional(z.never()),
|
||||
path: z.object({
|
||||
|
||||
Reference in New Issue
Block a user