/** * Generated by orval v6.31.0 🍺 * Do not edit manually. * pkh-api * pkh api * OpenAPI spec version: 0.0.1 */ import { useMutation, useQuery } from '@tanstack/react-query'; import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult, } from '@tanstack/react-query'; import { drcInstance } from '../../../configs/mutator/drc-instance'; import type { ErrorType } from '../../../configs/mutator/drc-instance'; import type { KhovtMasterKho, KhovtMasterKhoControllerCountParams, KhovtMasterKhoControllerFindByIdParams, KhovtMasterKhoControllerFindParams, KhovtMasterKhoPartial, KhovtMasterKhoWithRelations, LoopbackCount, NewKhovtMasterKho, } from '../../models'; export const khovtMasterKhoControllerCount = (params?: KhovtMasterKhoControllerCountParams, signal?: AbortSignal) => { return drcInstance({ url: `/khovt-master-khos/count`, method: 'GET', params, signal }); }; export const getKhovtMasterKhoControllerCountQueryKey = (params?: KhovtMasterKhoControllerCountParams) => { return [`/khovt-master-khos/count`, ...(params ? [params] : [])] as const; }; export const getKhovtMasterKhoControllerCountQueryOptions = < TData = Awaited>, TError = ErrorType, >( params?: KhovtMasterKhoControllerCountParams, options?: { query?: Partial>, TError, TData>>; }, ) => { const { query: queryOptions } = options ?? {}; const queryKey = queryOptions?.queryKey ?? getKhovtMasterKhoControllerCountQueryKey(params); const queryFn: QueryFunction>> = ({ signal }) => khovtMasterKhoControllerCount(params, signal); return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< Awaited>, TError, TData > & { queryKey: QueryKey }; }; export type KhovtMasterKhoControllerCountQueryResult = NonNullable< Awaited> >; export type KhovtMasterKhoControllerCountQueryError = ErrorType; export const useKhovtMasterKhoControllerCount = < TData = Awaited>, TError = ErrorType, >( params?: KhovtMasterKhoControllerCountParams, options?: { query?: Partial>, TError, TData>>; }, ): UseQueryResult & { queryKey: QueryKey } => { const queryOptions = getKhovtMasterKhoControllerCountQueryOptions(params, options); const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; query.queryKey = queryOptions.queryKey; return query; }; export const khovtMasterKhoControllerUpdateById = (id: number, khovtMasterKhoPartial: KhovtMasterKhoPartial) => { return drcInstance({ url: `/khovt-master-khos/${id}`, method: 'PATCH', headers: { 'Content-Type': 'application/json' }, data: khovtMasterKhoPartial, }); }; export const getKhovtMasterKhoControllerUpdateByIdMutationOptions = < TError = ErrorType, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { id: number; data: KhovtMasterKhoPartial }, TContext >; }): UseMutationOptions< Awaited>, TError, { id: number; data: KhovtMasterKhoPartial }, TContext > => { const { mutation: mutationOptions } = options ?? {}; const mutationFn: MutationFunction< Awaited>, { id: number; data: KhovtMasterKhoPartial } > = (props) => { const { id, data } = props ?? {}; return khovtMasterKhoControllerUpdateById(id, data); }; return { mutationFn, ...mutationOptions }; }; export type KhovtMasterKhoControllerUpdateByIdMutationResult = NonNullable< Awaited> >; export type KhovtMasterKhoControllerUpdateByIdMutationBody = KhovtMasterKhoPartial; export type KhovtMasterKhoControllerUpdateByIdMutationError = ErrorType; export const useKhovtMasterKhoControllerUpdateById = , TContext = unknown>(options?: { mutation?: UseMutationOptions< Awaited>, TError, { id: number; data: KhovtMasterKhoPartial }, TContext >; }): UseMutationResult< Awaited>, TError, { id: number; data: KhovtMasterKhoPartial }, TContext > => { const mutationOptions = getKhovtMasterKhoControllerUpdateByIdMutationOptions(options); return useMutation(mutationOptions); }; export const khovtMasterKhoControllerFindById = ( id: number, params?: KhovtMasterKhoControllerFindByIdParams, signal?: AbortSignal, ) => { return drcInstance({ url: `/khovt-master-khos/${id}`, method: 'GET', params, signal }); }; export const getKhovtMasterKhoControllerFindByIdQueryKey = ( id: number, params?: KhovtMasterKhoControllerFindByIdParams, ) => { return [`/khovt-master-khos/${id}`, ...(params ? [params] : [])] as const; }; export const getKhovtMasterKhoControllerFindByIdQueryOptions = < TData = Awaited>, TError = ErrorType, >( id: number, params?: KhovtMasterKhoControllerFindByIdParams, options?: { query?: Partial>, TError, TData>>; }, ) => { const { query: queryOptions } = options ?? {}; const queryKey = queryOptions?.queryKey ?? getKhovtMasterKhoControllerFindByIdQueryKey(id, params); const queryFn: QueryFunction>> = ({ signal }) => khovtMasterKhoControllerFindById(id, params, signal); return { queryKey, queryFn, enabled: !!id, ...queryOptions } as UseQueryOptions< Awaited>, TError, TData > & { queryKey: QueryKey }; }; export type KhovtMasterKhoControllerFindByIdQueryResult = NonNullable< Awaited> >; export type KhovtMasterKhoControllerFindByIdQueryError = ErrorType; export const useKhovtMasterKhoControllerFindById = < TData = Awaited>, TError = ErrorType, >( id: number, params?: KhovtMasterKhoControllerFindByIdParams, options?: { query?: Partial>, TError, TData>>; }, ): UseQueryResult & { queryKey: QueryKey } => { const queryOptions = getKhovtMasterKhoControllerFindByIdQueryOptions(id, params, options); const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; query.queryKey = queryOptions.queryKey; return query; }; export const khovtMasterKhoControllerDeleteById = (id: number) => { return drcInstance({ url: `/khovt-master-khos/${id}`, method: 'DELETE' }); }; export const getKhovtMasterKhoControllerDeleteByIdMutationOptions = < TError = ErrorType, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { id: number }, TContext >; }): UseMutationOptions< Awaited>, TError, { id: number }, TContext > => { const { mutation: mutationOptions } = options ?? {}; const mutationFn: MutationFunction>, { id: number }> = ( props, ) => { const { id } = props ?? {}; return khovtMasterKhoControllerDeleteById(id); }; return { mutationFn, ...mutationOptions }; }; export type KhovtMasterKhoControllerDeleteByIdMutationResult = NonNullable< Awaited> >; export type KhovtMasterKhoControllerDeleteByIdMutationError = ErrorType; export const useKhovtMasterKhoControllerDeleteById = , TContext = unknown>(options?: { mutation?: UseMutationOptions< Awaited>, TError, { id: number }, TContext >; }): UseMutationResult< Awaited>, TError, { id: number }, TContext > => { const mutationOptions = getKhovtMasterKhoControllerDeleteByIdMutationOptions(options); return useMutation(mutationOptions); }; export const khovtMasterKhoControllerCreate = (newKhovtMasterKho: NewKhovtMasterKho) => { return drcInstance({ url: `/khovt-master-khos`, method: 'POST', headers: { 'Content-Type': 'application/json' }, data: newKhovtMasterKho, }); }; export const getKhovtMasterKhoControllerCreateMutationOptions = < TError = ErrorType, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { data: NewKhovtMasterKho }, TContext >; }): UseMutationOptions< Awaited>, TError, { data: NewKhovtMasterKho }, TContext > => { const { mutation: mutationOptions } = options ?? {}; const mutationFn: MutationFunction< Awaited>, { data: NewKhovtMasterKho } > = (props) => { const { data } = props ?? {}; return khovtMasterKhoControllerCreate(data); }; return { mutationFn, ...mutationOptions }; }; export type KhovtMasterKhoControllerCreateMutationResult = NonNullable< Awaited> >; export type KhovtMasterKhoControllerCreateMutationBody = NewKhovtMasterKho; export type KhovtMasterKhoControllerCreateMutationError = ErrorType; export const useKhovtMasterKhoControllerCreate = , TContext = unknown>(options?: { mutation?: UseMutationOptions< Awaited>, TError, { data: NewKhovtMasterKho }, TContext >; }): UseMutationResult< Awaited>, TError, { data: NewKhovtMasterKho }, TContext > => { const mutationOptions = getKhovtMasterKhoControllerCreateMutationOptions(options); return useMutation(mutationOptions); }; export const khovtMasterKhoControllerFind = (params?: KhovtMasterKhoControllerFindParams, signal?: AbortSignal) => { return drcInstance({ url: `/khovt-master-khos`, method: 'GET', params, signal }); }; export const getKhovtMasterKhoControllerFindQueryKey = (params?: KhovtMasterKhoControllerFindParams) => { return [`/khovt-master-khos`, ...(params ? [params] : [])] as const; }; export const getKhovtMasterKhoControllerFindQueryOptions = < TData = Awaited>, TError = ErrorType, >( params?: KhovtMasterKhoControllerFindParams, options?: { query?: Partial>, TError, TData>>; }, ) => { const { query: queryOptions } = options ?? {}; const queryKey = queryOptions?.queryKey ?? getKhovtMasterKhoControllerFindQueryKey(params); const queryFn: QueryFunction>> = ({ signal }) => khovtMasterKhoControllerFind(params, signal); return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< Awaited>, TError, TData > & { queryKey: QueryKey }; }; export type KhovtMasterKhoControllerFindQueryResult = NonNullable< Awaited> >; export type KhovtMasterKhoControllerFindQueryError = ErrorType; export const useKhovtMasterKhoControllerFind = < TData = Awaited>, TError = ErrorType, >( params?: KhovtMasterKhoControllerFindParams, options?: { query?: Partial>, TError, TData>>; }, ): UseQueryResult & { queryKey: QueryKey } => { const queryOptions = getKhovtMasterKhoControllerFindQueryOptions(params, options); const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; query.queryKey = queryOptions.queryKey; return query; };