feat: projects create, update, delete
This commit is contained in:
@ -1,22 +1,80 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import { type Options, getBoards, createBoard, deleteBoard, updateBoard, getDeals, updateDeal, getProjects, getStatuses, createStatus, deleteStatus, updateStatus } from '../sdk.gen';
|
||||
import { queryOptions, type UseMutationOptions } from '@tanstack/react-query';
|
||||
import type { GetBoardsData, CreateBoardData, CreateBoardError, CreateBoardResponse2, DeleteBoardData, DeleteBoardError, DeleteBoardResponse2, UpdateBoardData, UpdateBoardError, UpdateBoardResponse2, GetDealsData, UpdateDealData, UpdateDealError, UpdateDealResponse2, GetProjectsData, GetStatusesData, CreateStatusData, CreateStatusError, CreateStatusResponse2, DeleteStatusData, DeleteStatusError, DeleteStatusResponse2, UpdateStatusData, UpdateStatusError, UpdateStatusResponse2 } from '../types.gen';
|
||||
import type { AxiosError } from 'axios';
|
||||
import { client as _heyApiClient } from '../client.gen';
|
||||
import { queryOptions, type UseMutationOptions } from "@tanstack/react-query";
|
||||
import type { AxiosError } from "axios";
|
||||
import { client as _heyApiClient } from "../client.gen";
|
||||
import {
|
||||
createBoard,
|
||||
createProject,
|
||||
createStatus,
|
||||
deleteBoard,
|
||||
deleteProject,
|
||||
deleteStatus,
|
||||
getBoards,
|
||||
getDeals,
|
||||
getProjects,
|
||||
getStatuses,
|
||||
updateBoard,
|
||||
updateDeal,
|
||||
updateProject,
|
||||
updateStatus,
|
||||
type Options,
|
||||
} from "../sdk.gen";
|
||||
import type {
|
||||
CreateBoardData,
|
||||
CreateBoardError,
|
||||
CreateBoardResponse2,
|
||||
CreateProjectData,
|
||||
CreateProjectError,
|
||||
CreateProjectResponse2,
|
||||
CreateStatusData,
|
||||
CreateStatusError,
|
||||
CreateStatusResponse2,
|
||||
DeleteBoardData,
|
||||
DeleteBoardError,
|
||||
DeleteBoardResponse2,
|
||||
DeleteProjectData,
|
||||
DeleteProjectError,
|
||||
DeleteProjectResponse2,
|
||||
DeleteStatusData,
|
||||
DeleteStatusError,
|
||||
DeleteStatusResponse2,
|
||||
GetBoardsData,
|
||||
GetDealsData,
|
||||
GetProjectsData,
|
||||
GetStatusesData,
|
||||
UpdateBoardData,
|
||||
UpdateBoardError,
|
||||
UpdateBoardResponse2,
|
||||
UpdateDealData,
|
||||
UpdateDealError,
|
||||
UpdateDealResponse2,
|
||||
UpdateProjectData,
|
||||
UpdateProjectError,
|
||||
UpdateProjectResponse2,
|
||||
UpdateStatusData,
|
||||
UpdateStatusError,
|
||||
UpdateStatusResponse2,
|
||||
} from "../types.gen";
|
||||
|
||||
export type QueryKey<TOptions extends Options> = [
|
||||
Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & {
|
||||
Pick<TOptions, "baseURL" | "body" | "headers" | "path" | "query"> & {
|
||||
_id: string;
|
||||
_infinite?: boolean;
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): [
|
||||
QueryKey<TOptions>[0]
|
||||
] => {
|
||||
const params: QueryKey<TOptions>[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey<TOptions>[0];
|
||||
const createQueryKey = <TOptions extends Options>(
|
||||
id: string,
|
||||
options?: TOptions,
|
||||
infinite?: boolean
|
||||
): [QueryKey<TOptions>[0]] => {
|
||||
const params: QueryKey<TOptions>[0] = {
|
||||
_id: id,
|
||||
baseURL:
|
||||
options?.baseURL ||
|
||||
(options?.client ?? _heyApiClient).getConfig().baseURL,
|
||||
} as QueryKey<TOptions>[0];
|
||||
if (infinite) {
|
||||
params._infinite = infinite;
|
||||
}
|
||||
@ -32,12 +90,11 @@ const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions
|
||||
if (options?.query) {
|
||||
params.query = options.query;
|
||||
}
|
||||
return [
|
||||
params
|
||||
];
|
||||
return [params];
|
||||
};
|
||||
|
||||
export const getBoardsQueryKey = (options: Options<GetBoardsData>) => createQueryKey('getBoards', options);
|
||||
export const getBoardsQueryKey = (options: Options<GetBoardsData>) =>
|
||||
createQueryKey("getBoards", options);
|
||||
|
||||
/**
|
||||
* Get Boards
|
||||
@ -49,15 +106,16 @@ export const getBoardsOptions = (options: Options<GetBoardsData>) => {
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getBoardsQueryKey(options)
|
||||
queryKey: getBoardsQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const createBoardQueryKey = (options: Options<CreateBoardData>) => createQueryKey('createBoard', options);
|
||||
export const createBoardQueryKey = (options: Options<CreateBoardData>) =>
|
||||
createQueryKey("createBoard", options);
|
||||
|
||||
/**
|
||||
* Create Board
|
||||
@ -69,27 +127,37 @@ export const createBoardOptions = (options: Options<CreateBoardData>) => {
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: createBoardQueryKey(options)
|
||||
queryKey: createBoardQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Board
|
||||
*/
|
||||
export const createBoardMutation = (options?: Partial<Options<CreateBoardData>>): UseMutationOptions<CreateBoardResponse2, AxiosError<CreateBoardError>, Options<CreateBoardData>> => {
|
||||
const mutationOptions: UseMutationOptions<CreateBoardResponse2, AxiosError<CreateBoardError>, Options<CreateBoardData>> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
export const createBoardMutation = (
|
||||
options?: Partial<Options<CreateBoardData>>
|
||||
): UseMutationOptions<
|
||||
CreateBoardResponse2,
|
||||
AxiosError<CreateBoardError>,
|
||||
Options<CreateBoardData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateBoardResponse2,
|
||||
AxiosError<CreateBoardError>,
|
||||
Options<CreateBoardData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await createBoard({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
@ -97,16 +165,26 @@ export const createBoardMutation = (options?: Partial<Options<CreateBoardData>>)
|
||||
/**
|
||||
* Delete Board
|
||||
*/
|
||||
export const deleteBoardMutation = (options?: Partial<Options<DeleteBoardData>>): UseMutationOptions<DeleteBoardResponse2, AxiosError<DeleteBoardError>, Options<DeleteBoardData>> => {
|
||||
const mutationOptions: UseMutationOptions<DeleteBoardResponse2, AxiosError<DeleteBoardError>, Options<DeleteBoardData>> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
export const deleteBoardMutation = (
|
||||
options?: Partial<Options<DeleteBoardData>>
|
||||
): UseMutationOptions<
|
||||
DeleteBoardResponse2,
|
||||
AxiosError<DeleteBoardError>,
|
||||
Options<DeleteBoardData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteBoardResponse2,
|
||||
AxiosError<DeleteBoardError>,
|
||||
Options<DeleteBoardData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await deleteBoard({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
@ -114,21 +192,32 @@ export const deleteBoardMutation = (options?: Partial<Options<DeleteBoardData>>)
|
||||
/**
|
||||
* Update Board
|
||||
*/
|
||||
export const updateBoardMutation = (options?: Partial<Options<UpdateBoardData>>): UseMutationOptions<UpdateBoardResponse2, AxiosError<UpdateBoardError>, Options<UpdateBoardData>> => {
|
||||
const mutationOptions: UseMutationOptions<UpdateBoardResponse2, AxiosError<UpdateBoardError>, Options<UpdateBoardData>> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
export const updateBoardMutation = (
|
||||
options?: Partial<Options<UpdateBoardData>>
|
||||
): UseMutationOptions<
|
||||
UpdateBoardResponse2,
|
||||
AxiosError<UpdateBoardError>,
|
||||
Options<UpdateBoardData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateBoardResponse2,
|
||||
AxiosError<UpdateBoardError>,
|
||||
Options<UpdateBoardData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await updateBoard({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getDealsQueryKey = (options: Options<GetDealsData>) => createQueryKey('getDeals', options);
|
||||
export const getDealsQueryKey = (options: Options<GetDealsData>) =>
|
||||
createQueryKey("getDeals", options);
|
||||
|
||||
/**
|
||||
* Get Deals
|
||||
@ -140,32 +229,43 @@ export const getDealsOptions = (options: Options<GetDealsData>) => {
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getDealsQueryKey(options)
|
||||
queryKey: getDealsQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Deal
|
||||
*/
|
||||
export const updateDealMutation = (options?: Partial<Options<UpdateDealData>>): UseMutationOptions<UpdateDealResponse2, AxiosError<UpdateDealError>, Options<UpdateDealData>> => {
|
||||
const mutationOptions: UseMutationOptions<UpdateDealResponse2, AxiosError<UpdateDealError>, Options<UpdateDealData>> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
export const updateDealMutation = (
|
||||
options?: Partial<Options<UpdateDealData>>
|
||||
): UseMutationOptions<
|
||||
UpdateDealResponse2,
|
||||
AxiosError<UpdateDealError>,
|
||||
Options<UpdateDealData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateDealResponse2,
|
||||
AxiosError<UpdateDealError>,
|
||||
Options<UpdateDealData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await updateDeal({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getProjectsQueryKey = (options?: Options<GetProjectsData>) => createQueryKey('getProjects', options);
|
||||
export const getProjectsQueryKey = (options?: Options<GetProjectsData>) =>
|
||||
createQueryKey("getProjects", options);
|
||||
|
||||
/**
|
||||
* Get Projects
|
||||
@ -177,15 +277,118 @@ export const getProjectsOptions = (options?: Options<GetProjectsData>) => {
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getProjectsQueryKey(options)
|
||||
queryKey: getProjectsQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const getStatusesQueryKey = (options: Options<GetStatusesData>) => createQueryKey('getStatuses', options);
|
||||
export const createProjectQueryKey = (options: Options<CreateProjectData>) =>
|
||||
createQueryKey("createProject", options);
|
||||
|
||||
/**
|
||||
* Create Project
|
||||
*/
|
||||
export const createProjectOptions = (options: Options<CreateProjectData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await createProject({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: createProjectQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Project
|
||||
*/
|
||||
export const createProjectMutation = (
|
||||
options?: Partial<Options<CreateProjectData>>
|
||||
): UseMutationOptions<
|
||||
CreateProjectResponse2,
|
||||
AxiosError<CreateProjectError>,
|
||||
Options<CreateProjectData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateProjectResponse2,
|
||||
AxiosError<CreateProjectError>,
|
||||
Options<CreateProjectData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await createProject({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete Project
|
||||
*/
|
||||
export const deleteProjectMutation = (
|
||||
options?: Partial<Options<DeleteProjectData>>
|
||||
): UseMutationOptions<
|
||||
DeleteProjectResponse2,
|
||||
AxiosError<DeleteProjectError>,
|
||||
Options<DeleteProjectData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteProjectResponse2,
|
||||
AxiosError<DeleteProjectError>,
|
||||
Options<DeleteProjectData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await deleteProject({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update Project
|
||||
*/
|
||||
export const updateProjectMutation = (
|
||||
options?: Partial<Options<UpdateProjectData>>
|
||||
): UseMutationOptions<
|
||||
UpdateProjectResponse2,
|
||||
AxiosError<UpdateProjectError>,
|
||||
Options<UpdateProjectData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateProjectResponse2,
|
||||
AxiosError<UpdateProjectError>,
|
||||
Options<UpdateProjectData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await updateProject({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getStatusesQueryKey = (options: Options<GetStatusesData>) =>
|
||||
createQueryKey("getStatuses", options);
|
||||
|
||||
/**
|
||||
* Get Statuses
|
||||
@ -197,15 +400,16 @@ export const getStatusesOptions = (options: Options<GetStatusesData>) => {
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getStatusesQueryKey(options)
|
||||
queryKey: getStatusesQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const createStatusQueryKey = (options: Options<CreateStatusData>) => createQueryKey('createStatus', options);
|
||||
export const createStatusQueryKey = (options: Options<CreateStatusData>) =>
|
||||
createQueryKey("createStatus", options);
|
||||
|
||||
/**
|
||||
* Create Status
|
||||
@ -217,27 +421,37 @@ export const createStatusOptions = (options: Options<CreateStatusData>) => {
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: createStatusQueryKey(options)
|
||||
queryKey: createStatusQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Status
|
||||
*/
|
||||
export const createStatusMutation = (options?: Partial<Options<CreateStatusData>>): UseMutationOptions<CreateStatusResponse2, AxiosError<CreateStatusError>, Options<CreateStatusData>> => {
|
||||
const mutationOptions: UseMutationOptions<CreateStatusResponse2, AxiosError<CreateStatusError>, Options<CreateStatusData>> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
export const createStatusMutation = (
|
||||
options?: Partial<Options<CreateStatusData>>
|
||||
): UseMutationOptions<
|
||||
CreateStatusResponse2,
|
||||
AxiosError<CreateStatusError>,
|
||||
Options<CreateStatusData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateStatusResponse2,
|
||||
AxiosError<CreateStatusError>,
|
||||
Options<CreateStatusData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await createStatus({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
@ -245,16 +459,26 @@ export const createStatusMutation = (options?: Partial<Options<CreateStatusData>
|
||||
/**
|
||||
* Delete Status
|
||||
*/
|
||||
export const deleteStatusMutation = (options?: Partial<Options<DeleteStatusData>>): UseMutationOptions<DeleteStatusResponse2, AxiosError<DeleteStatusError>, Options<DeleteStatusData>> => {
|
||||
const mutationOptions: UseMutationOptions<DeleteStatusResponse2, AxiosError<DeleteStatusError>, Options<DeleteStatusData>> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
export const deleteStatusMutation = (
|
||||
options?: Partial<Options<DeleteStatusData>>
|
||||
): UseMutationOptions<
|
||||
DeleteStatusResponse2,
|
||||
AxiosError<DeleteStatusError>,
|
||||
Options<DeleteStatusData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DeleteStatusResponse2,
|
||||
AxiosError<DeleteStatusError>,
|
||||
Options<DeleteStatusData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await deleteStatus({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
@ -262,16 +486,26 @@ export const deleteStatusMutation = (options?: Partial<Options<DeleteStatusData>
|
||||
/**
|
||||
* Update Status
|
||||
*/
|
||||
export const updateStatusMutation = (options?: Partial<Options<UpdateStatusData>>): UseMutationOptions<UpdateStatusResponse2, AxiosError<UpdateStatusError>, Options<UpdateStatusData>> => {
|
||||
const mutationOptions: UseMutationOptions<UpdateStatusResponse2, AxiosError<UpdateStatusError>, Options<UpdateStatusData>> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
export const updateStatusMutation = (
|
||||
options?: Partial<Options<UpdateStatusData>>
|
||||
): UseMutationOptions<
|
||||
UpdateStatusResponse2,
|
||||
AxiosError<UpdateStatusError>,
|
||||
Options<UpdateStatusData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
UpdateStatusResponse2,
|
||||
AxiosError<UpdateStatusError>,
|
||||
Options<UpdateStatusData>
|
||||
> = {
|
||||
mutationFn: async localOptions => {
|
||||
const { data } = await updateStatus({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user