552 lines
13 KiB
TypeScript
552 lines
13 KiB
TypeScript
/**
|
|
* Generated by orval v7.21.0 🍺
|
|
* Do not edit manually.
|
|
* Negodata Api Server
|
|
* OpenAPI spec version: 0.1.0
|
|
*/
|
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
import type {
|
|
DataTag,
|
|
DefinedInitialDataOptions,
|
|
DefinedUseQueryResult,
|
|
MutationFunction,
|
|
QueryClient,
|
|
QueryFunction,
|
|
QueryKey,
|
|
UndefinedInitialDataOptions,
|
|
UseMutationOptions,
|
|
UseMutationResult,
|
|
UseQueryOptions,
|
|
UseQueryResult,
|
|
} from "@tanstack/react-query";
|
|
|
|
import type {
|
|
HTTPValidationError,
|
|
ListCardsParams,
|
|
ReqCreateCard,
|
|
ReqUpdateCard,
|
|
ResCard,
|
|
ResCardList,
|
|
ResDeleteCard,
|
|
} from ".././model";
|
|
|
|
import { customFetch } from "../../mutator/custom-fetch";
|
|
|
|
/**
|
|
* @summary 협상카드 목록
|
|
*/
|
|
export const listCards = (params?: ListCardsParams, signal?: AbortSignal) => {
|
|
return customFetch<ResCardList>({
|
|
url: `/v1/card/list`,
|
|
method: "GET",
|
|
params,
|
|
signal,
|
|
});
|
|
};
|
|
|
|
export const getListCardsQueryKey = (params?: ListCardsParams) => {
|
|
return [`/v1/card/list`, ...(params ? [params] : [])] as const;
|
|
};
|
|
|
|
export const getListCardsQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof listCards>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
params?: ListCardsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listCards>>, TError, TData>
|
|
>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getListCardsQueryKey(params);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof listCards>>> = ({
|
|
signal,
|
|
}) => listCards(params, signal);
|
|
|
|
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
|
Awaited<ReturnType<typeof listCards>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type ListCardsQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof listCards>>
|
|
>;
|
|
export type ListCardsQueryError = void | HTTPValidationError;
|
|
|
|
export function useListCards<
|
|
TData = Awaited<ReturnType<typeof listCards>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
params: undefined | ListCardsParams,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listCards>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listCards>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listCards>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListCards<
|
|
TData = Awaited<ReturnType<typeof listCards>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
params?: ListCardsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listCards>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listCards>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listCards>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListCards<
|
|
TData = Awaited<ReturnType<typeof listCards>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
params?: ListCardsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listCards>>, TError, TData>
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 협상카드 목록
|
|
*/
|
|
|
|
export function useListCards<
|
|
TData = Awaited<ReturnType<typeof listCards>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
params?: ListCardsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listCards>>, TError, TData>
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getListCardsQueryOptions(params, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* @summary 협상카드 등록
|
|
*/
|
|
export const createCard = (
|
|
reqCreateCard: ReqCreateCard,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResCard>({
|
|
url: `/v1/card/create`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqCreateCard,
|
|
signal,
|
|
});
|
|
};
|
|
|
|
export const getCreateCardMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof createCard>>,
|
|
TError,
|
|
{ data: ReqCreateCard },
|
|
TContext
|
|
>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof createCard>>,
|
|
TError,
|
|
{ data: ReqCreateCard },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["createCard"];
|
|
const { mutation: mutationOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey } };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof createCard>>,
|
|
{ data: ReqCreateCard }
|
|
> = (props) => {
|
|
const { data } = props ?? {};
|
|
|
|
return createCard(data);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type CreateCardMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof createCard>>
|
|
>;
|
|
export type CreateCardMutationBody = ReqCreateCard;
|
|
export type CreateCardMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 협상카드 등록
|
|
*/
|
|
export const useCreateCard = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof createCard>>,
|
|
TError,
|
|
{ data: ReqCreateCard },
|
|
TContext
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof createCard>>,
|
|
TError,
|
|
{ data: ReqCreateCard },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getCreateCardMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary 협상카드 조회
|
|
*/
|
|
export const getCard = (cardId: string, signal?: AbortSignal) => {
|
|
return customFetch<ResCard>({
|
|
url: `/v1/card/${cardId}`,
|
|
method: "GET",
|
|
signal,
|
|
});
|
|
};
|
|
|
|
export const getGetCardQueryKey = (cardId?: string) => {
|
|
return [`/v1/card/${cardId}`] as const;
|
|
};
|
|
|
|
export const getGetCardQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof getCard>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
cardId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getCard>>, TError, TData>
|
|
>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetCardQueryKey(cardId);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getCard>>> = ({
|
|
signal,
|
|
}) => getCard(cardId, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!cardId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<Awaited<ReturnType<typeof getCard>>, TError, TData> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
};
|
|
|
|
export type GetCardQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof getCard>>
|
|
>;
|
|
export type GetCardQueryError = void | HTTPValidationError;
|
|
|
|
export function useGetCard<
|
|
TData = Awaited<ReturnType<typeof getCard>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
cardId: string,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getCard>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getCard>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getCard>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetCard<
|
|
TData = Awaited<ReturnType<typeof getCard>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
cardId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getCard>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getCard>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getCard>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetCard<
|
|
TData = Awaited<ReturnType<typeof getCard>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
cardId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getCard>>, TError, TData>
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 협상카드 조회
|
|
*/
|
|
|
|
export function useGetCard<
|
|
TData = Awaited<ReturnType<typeof getCard>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
cardId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getCard>>, TError, TData>
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getGetCardQueryOptions(cardId, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* @summary 협상카드 수정
|
|
*/
|
|
export const updateCard = (cardId: string, reqUpdateCard: ReqUpdateCard) => {
|
|
return customFetch<ResCard>({
|
|
url: `/v1/card/update/${cardId}`,
|
|
method: "PATCH",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqUpdateCard,
|
|
});
|
|
};
|
|
|
|
export const getUpdateCardMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof updateCard>>,
|
|
TError,
|
|
{ cardId: string; data: ReqUpdateCard },
|
|
TContext
|
|
>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof updateCard>>,
|
|
TError,
|
|
{ cardId: string; data: ReqUpdateCard },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["updateCard"];
|
|
const { mutation: mutationOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey } };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof updateCard>>,
|
|
{ cardId: string; data: ReqUpdateCard }
|
|
> = (props) => {
|
|
const { cardId, data } = props ?? {};
|
|
|
|
return updateCard(cardId, data);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type UpdateCardMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof updateCard>>
|
|
>;
|
|
export type UpdateCardMutationBody = ReqUpdateCard;
|
|
export type UpdateCardMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 협상카드 수정
|
|
*/
|
|
export const useUpdateCard = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof updateCard>>,
|
|
TError,
|
|
{ cardId: string; data: ReqUpdateCard },
|
|
TContext
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof updateCard>>,
|
|
TError,
|
|
{ cardId: string; data: ReqUpdateCard },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getUpdateCardMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary 협상카드 삭제
|
|
*/
|
|
export const deleteCard = (cardId: string) => {
|
|
return customFetch<ResDeleteCard>({
|
|
url: `/v1/card/delete/${cardId}`,
|
|
method: "DELETE",
|
|
});
|
|
};
|
|
|
|
export const getDeleteCardMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof deleteCard>>,
|
|
TError,
|
|
{ cardId: string },
|
|
TContext
|
|
>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof deleteCard>>,
|
|
TError,
|
|
{ cardId: string },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["deleteCard"];
|
|
const { mutation: mutationOptions } = options
|
|
? options.mutation &&
|
|
"mutationKey" in options.mutation &&
|
|
options.mutation.mutationKey
|
|
? options
|
|
: { ...options, mutation: { ...options.mutation, mutationKey } }
|
|
: { mutation: { mutationKey } };
|
|
|
|
const mutationFn: MutationFunction<
|
|
Awaited<ReturnType<typeof deleteCard>>,
|
|
{ cardId: string }
|
|
> = (props) => {
|
|
const { cardId } = props ?? {};
|
|
|
|
return deleteCard(cardId);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type DeleteCardMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof deleteCard>>
|
|
>;
|
|
|
|
export type DeleteCardMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 협상카드 삭제
|
|
*/
|
|
export const useDeleteCard = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof deleteCard>>,
|
|
TError,
|
|
{ cardId: string },
|
|
TContext
|
|
>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof deleteCard>>,
|
|
TError,
|
|
{ cardId: string },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getDeleteCardMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|