/**
 * Generated by orval v8.8.0 🍺
 * Do not edit manually.
 * OpenAPI spec version: 0.0.0
 */
import { useQuery } from "@tanstack/react-query";
import type {
  DataTag,
  DefinedInitialDataOptions,
  DefinedUseQueryResult,
  QueryClient,
  QueryFunction,
  QueryKey,
  UndefinedInitialDataOptions,
  UseQueryOptions,
  UseQueryResult,
} from "@tanstack/react-query";

import type { ApiChoicesRetrieve200, ApiChoicesRetrieveParams } from "./models";

import { publicMutator } from "../../publicClient";

/**
 * Vrátí všechny možné hodnoty pro ChoiceField s podporou vícejazyčných labelů. Umožňuje načíst více modelů a polí najednou.
 */
export const apiChoicesRetrieve = (
  params: ApiChoicesRetrieveParams,
  signal?: AbortSignal,
) => {
  return publicMutator<ApiChoicesRetrieve200>({
    url: `/api/choices/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiChoicesRetrieveQueryKey = (
  params?: ApiChoicesRetrieveParams,
) => {
  return [`/api/choices/`, ...(params ? [params] : [])] as const;
};

export const getApiChoicesRetrieveQueryOptions = <
  TData = Awaited<ReturnType<typeof apiChoicesRetrieve>>,
  TError = unknown,
>(
  params: ApiChoicesRetrieveParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiChoicesRetrieve>>,
        TError,
        TData
      >
    >;
  },
) => {
  const { query: queryOptions } = options ?? {};

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

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

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

export type ApiChoicesRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiChoicesRetrieve>>
>;
export type ApiChoicesRetrieveQueryError = unknown;

export function useApiChoicesRetrieve<
  TData = Awaited<ReturnType<typeof apiChoicesRetrieve>>,
  TError = unknown,
>(
  params: ApiChoicesRetrieveParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiChoicesRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiChoicesRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiChoicesRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiChoicesRetrieve<
  TData = Awaited<ReturnType<typeof apiChoicesRetrieve>>,
  TError = unknown,
>(
  params: ApiChoicesRetrieveParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiChoicesRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiChoicesRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiChoicesRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiChoicesRetrieve<
  TData = Awaited<ReturnType<typeof apiChoicesRetrieve>>,
  TError = unknown,
>(
  params: ApiChoicesRetrieveParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiChoicesRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};

export function useApiChoicesRetrieve<
  TData = Awaited<ReturnType<typeof apiChoicesRetrieve>>,
  TError = unknown,
>(
  params: ApiChoicesRetrieveParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiChoicesRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getApiChoicesRetrieveQueryOptions(params, options);

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

  return { ...query, queryKey: queryOptions.queryKey };
}
