/**
 * Generated by orval v7.10.0 🍺
 * Do not edit manually.
 * Monitoring | v1
 * OpenAPI spec version: 1.0.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 {
  AreaModel,
  CreateAreaRequest,
  GetAreaListParams,
  ProblemDetails,
  TableDataResponseModelOfAreaModel,
  UpdateAreaRequest
} from './client.schemas';

import { customClient } from '../services/http.service';





export const getAreaList = (
    params?: GetAreaListParams,
 signal?: AbortSignal
) => {
      
      
      return customClient<TableDataResponseModelOfAreaModel>(
      {url: `/api/areas`, method: 'GET',
        params, signal
    },
      );
    }
  

export const getGetAreaListQueryKey = (params?: GetAreaListParams,) => {
    return [`/api/areas`, ...(params ? [params]: [])] as const;
    }

    
export const getGetAreaListQueryOptions = <TData = Awaited<ReturnType<typeof getAreaList>>, TError = unknown>(params?: GetAreaListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAreaList>>, TError, TData>>, }
) => {

const {query: queryOptions} = options ?? {};

  const queryKey =  queryOptions?.queryKey ?? getGetAreaListQueryKey(params);

  

    const queryFn: QueryFunction<Awaited<ReturnType<typeof getAreaList>>> = ({ signal }) => getAreaList(params, signal);

      

      

   return  { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getAreaList>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}

export type GetAreaListQueryResult = NonNullable<Awaited<ReturnType<typeof getAreaList>>>
export type GetAreaListQueryError = unknown


export function useGetAreaList<TData = Awaited<ReturnType<typeof getAreaList>>, TError = unknown>(
 params: undefined |  GetAreaListParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAreaList>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getAreaList>>,
          TError,
          Awaited<ReturnType<typeof getAreaList>>
        > , 'initialData'
      >, }
 , queryClient?: QueryClient
  ):  DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetAreaList<TData = Awaited<ReturnType<typeof getAreaList>>, TError = unknown>(
 params?: GetAreaListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAreaList>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getAreaList>>,
          TError,
          Awaited<ReturnType<typeof getAreaList>>
        > , 'initialData'
      >, }
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetAreaList<TData = Awaited<ReturnType<typeof getAreaList>>, TError = unknown>(
 params?: GetAreaListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAreaList>>, TError, TData>>, }
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }

export function useGetAreaList<TData = Awaited<ReturnType<typeof getAreaList>>, TError = unknown>(
 params?: GetAreaListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAreaList>>, TError, TData>>, }
 , queryClient?: QueryClient 
 ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {

  const queryOptions = getGetAreaListQueryOptions(params,options)

  const query = useQuery(queryOptions , queryClient) as  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const createArea = (
    createAreaRequest: CreateAreaRequest,
 signal?: AbortSignal
) => {
      
      
      return customClient<AreaModel>(
      {url: `/api/areas`, method: 'POST',
      headers: {'Content-Type': 'application/json', },
      data: createAreaRequest, signal
    },
      );
    }
  


export const getCreateAreaMutationOptions = <TError = string | ProblemDetails,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createArea>>, TError,{data: CreateAreaRequest}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof createArea>>, TError,{data: CreateAreaRequest}, TContext> => {

const mutationKey = ['createArea'];
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 createArea>>, {data: CreateAreaRequest}> = (props) => {
          const {data} = props ?? {};

          return  createArea(data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type CreateAreaMutationResult = NonNullable<Awaited<ReturnType<typeof createArea>>>
    export type CreateAreaMutationBody = CreateAreaRequest
    export type CreateAreaMutationError = string | ProblemDetails

    export const useCreateArea = <TError = string | ProblemDetails,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createArea>>, TError,{data: CreateAreaRequest}, TContext>, }
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof createArea>>,
        TError,
        {data: CreateAreaRequest},
        TContext
      > => {

      const mutationOptions = getCreateAreaMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    export const getArea = (
    id: string,
 signal?: AbortSignal
) => {
      
      
      return customClient<AreaModel>(
      {url: `/api/areas/${id}`, method: 'GET', signal
    },
      );
    }
  

export const getGetAreaQueryKey = (id: string,) => {
    return [`/api/areas/${id}`] as const;
    }

    
export const getGetAreaQueryOptions = <TData = Awaited<ReturnType<typeof getArea>>, TError = string>(id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getArea>>, TError, TData>>, }
) => {

const {query: queryOptions} = options ?? {};

  const queryKey =  queryOptions?.queryKey ?? getGetAreaQueryKey(id);

  

    const queryFn: QueryFunction<Awaited<ReturnType<typeof getArea>>> = ({ signal }) => getArea(id, signal);

      

      

   return  { queryKey, queryFn, enabled: !!(id), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getArea>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}

export type GetAreaQueryResult = NonNullable<Awaited<ReturnType<typeof getArea>>>
export type GetAreaQueryError = string


export function useGetArea<TData = Awaited<ReturnType<typeof getArea>>, TError = string>(
 id: string, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getArea>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getArea>>,
          TError,
          Awaited<ReturnType<typeof getArea>>
        > , 'initialData'
      >, }
 , queryClient?: QueryClient
  ):  DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetArea<TData = Awaited<ReturnType<typeof getArea>>, TError = string>(
 id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getArea>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getArea>>,
          TError,
          Awaited<ReturnType<typeof getArea>>
        > , 'initialData'
      >, }
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetArea<TData = Awaited<ReturnType<typeof getArea>>, TError = string>(
 id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getArea>>, TError, TData>>, }
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }

export function useGetArea<TData = Awaited<ReturnType<typeof getArea>>, TError = string>(
 id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getArea>>, TError, TData>>, }
 , queryClient?: QueryClient 
 ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {

  const queryOptions = getGetAreaQueryOptions(id,options)

  const query = useQuery(queryOptions , queryClient) as  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const updateArea = (
    id: string,
    updateAreaRequest: UpdateAreaRequest,
 ) => {
      
      
      return customClient<void>(
      {url: `/api/areas/${id}`, method: 'PUT',
      headers: {'Content-Type': 'application/json', },
      data: updateAreaRequest
    },
      );
    }
  


export const getUpdateAreaMutationOptions = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateArea>>, TError,{id: string;data: UpdateAreaRequest}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof updateArea>>, TError,{id: string;data: UpdateAreaRequest}, TContext> => {

const mutationKey = ['updateArea'];
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 updateArea>>, {id: string;data: UpdateAreaRequest}> = (props) => {
          const {id,data} = props ?? {};

          return  updateArea(id,data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type UpdateAreaMutationResult = NonNullable<Awaited<ReturnType<typeof updateArea>>>
    export type UpdateAreaMutationBody = UpdateAreaRequest
    export type UpdateAreaMutationError = string

    export const useUpdateArea = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateArea>>, TError,{id: string;data: UpdateAreaRequest}, TContext>, }
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof updateArea>>,
        TError,
        {id: string;data: UpdateAreaRequest},
        TContext
      > => {

      const mutationOptions = getUpdateAreaMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    export const deleteArea = (
    id: string,
 ) => {
      
      
      return customClient<void>(
      {url: `/api/areas/${id}`, method: 'DELETE'
    },
      );
    }
  


export const getDeleteAreaMutationOptions = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteArea>>, TError,{id: string}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof deleteArea>>, TError,{id: string}, TContext> => {

const mutationKey = ['deleteArea'];
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 deleteArea>>, {id: string}> = (props) => {
          const {id} = props ?? {};

          return  deleteArea(id,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeleteAreaMutationResult = NonNullable<Awaited<ReturnType<typeof deleteArea>>>
    
    export type DeleteAreaMutationError = string

    export const useDeleteArea = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteArea>>, TError,{id: string}, TContext>, }
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof deleteArea>>,
        TError,
        {id: string},
        TContext
      > => {

      const mutationOptions = getDeleteAreaMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    