feat: deal create, update, delete
This commit is contained in:
@ -5,9 +5,11 @@ import type { AxiosError } from "axios";
|
||||
import { client as _heyApiClient } from "../client.gen";
|
||||
import {
|
||||
createBoard,
|
||||
createDeal,
|
||||
createProject,
|
||||
createStatus,
|
||||
deleteBoard,
|
||||
deleteDeal,
|
||||
deleteProject,
|
||||
deleteStatus,
|
||||
getBoards,
|
||||
@ -24,6 +26,9 @@ import type {
|
||||
CreateBoardData,
|
||||
CreateBoardError,
|
||||
CreateBoardResponse2,
|
||||
CreateDealData,
|
||||
CreateDealError,
|
||||
CreateDealResponse2,
|
||||
CreateProjectData,
|
||||
CreateProjectError,
|
||||
CreateProjectResponse2,
|
||||
@ -33,6 +38,9 @@ import type {
|
||||
DeleteBoardData,
|
||||
DeleteBoardError,
|
||||
DeleteBoardResponse2,
|
||||
DeleteDealData,
|
||||
DeleteDealError,
|
||||
DeleteDealResponse2,
|
||||
DeleteProjectData,
|
||||
DeleteProjectError,
|
||||
DeleteProjectResponse2,
|
||||
@ -237,6 +245,81 @@ export const getDealsOptions = (options: Options<GetDealsData>) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const createDealQueryKey = (options: Options<CreateDealData>) =>
|
||||
createQueryKey("createDeal", options);
|
||||
|
||||
/**
|
||||
* Create Deal
|
||||
*/
|
||||
export const createDealOptions = (options: Options<CreateDealData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await createDeal({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: createDealQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Deal
|
||||
*/
|
||||
export const createDealMutation = (
|
||||
options?: Partial<Options<CreateDealData>>
|
||||
): UseMutationOptions<
|
||||
CreateDealResponse2,
|
||||
AxiosError<CreateDealError>,
|
||||
Options<CreateDealData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateDealResponse2,
|
||||
AxiosError<CreateDealError>,
|
||||
Options<CreateDealData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await createDeal({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete Deal
|
||||
*/
|
||||
export const deleteDealMutation = (
|
||||
options?: Partial<Options<DeleteDealData>>
|
||||
): UseMutationOptions<
|
||||
DeleteDealResponse2,
|
||||
AxiosError<DeleteDealError>,
|
||||
Options<DeleteDealData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteDealResponse2,
|
||||
AxiosError<DeleteDealError>,
|
||||
Options<DeleteDealData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await deleteDeal({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Deal
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user