/**
 * Generated by orval v7.21.0 🍺
 * Do not edit manually.
 * MBHS
 * Multidimensional Behavioral Health Screen
 * 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 {
  AdminProfileResponseModel,
  ChangePasswordDto,
  Message,
  ProfileControllerUploadProfilePhotoV1Body,
  UpdateAdminProfileDto,
} from "../generated.schemas";

import { customInstance } from "../../../config/axios";

type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];

export const profileControllerGetProfileV1 = (
  options?: SecondParameter<typeof customInstance>,
  signal?: AbortSignal,
) => {
  return customInstance<AdminProfileResponseModel>(
    { url: `/v1/admin-profile`, method: "GET", signal },
    options,
  );
};

export const getProfileControllerGetProfileV1QueryKey = () => {
  return [`/v1/admin-profile`] as const;
};

export const getProfileControllerGetProfileV1QueryOptions = <
  TData = Awaited<ReturnType<typeof profileControllerGetProfileV1>>,
  TError = Message,
>(options?: {
  query?: Partial<
    UseQueryOptions<
      Awaited<ReturnType<typeof profileControllerGetProfileV1>>,
      TError,
      TData
    >
  >;
  request?: SecondParameter<typeof customInstance>;
}) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ?? getProfileControllerGetProfileV1QueryKey();

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

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

export type ProfileControllerGetProfileV1QueryResult = NonNullable<
  Awaited<ReturnType<typeof profileControllerGetProfileV1>>
>;
export type ProfileControllerGetProfileV1QueryError = Message;

export function useProfileControllerGetProfileV1<
  TData = Awaited<ReturnType<typeof profileControllerGetProfileV1>>,
  TError = Message,
>(
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof profileControllerGetProfileV1>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof profileControllerGetProfileV1>>,
          TError,
          Awaited<ReturnType<typeof profileControllerGetProfileV1>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useProfileControllerGetProfileV1<
  TData = Awaited<ReturnType<typeof profileControllerGetProfileV1>>,
  TError = Message,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof profileControllerGetProfileV1>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof profileControllerGetProfileV1>>,
          TError,
          Awaited<ReturnType<typeof profileControllerGetProfileV1>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useProfileControllerGetProfileV1<
  TData = Awaited<ReturnType<typeof profileControllerGetProfileV1>>,
  TError = Message,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof profileControllerGetProfileV1>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};

export function useProfileControllerGetProfileV1<
  TData = Awaited<ReturnType<typeof profileControllerGetProfileV1>>,
  TError = Message,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof profileControllerGetProfileV1>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getProfileControllerGetProfileV1QueryOptions(options);

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

export const profileControllerUpdateProfileV1 = (
  updateAdminProfileDto: UpdateAdminProfileDto,
  options?: SecondParameter<typeof customInstance>,
) => {
  return customInstance<AdminProfileResponseModel>(
    {
      url: `/v1/admin-profile`,
      method: "PATCH",
      headers: { "Content-Type": "application/json" },
      data: updateAdminProfileDto,
    },
    options,
  );
};

export const getProfileControllerUpdateProfileV1MutationOptions = <
  TError = Message,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof profileControllerUpdateProfileV1>>,
    TError,
    { data: UpdateAdminProfileDto },
    TContext
  >;
  request?: SecondParameter<typeof customInstance>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof profileControllerUpdateProfileV1>>,
  TError,
  { data: UpdateAdminProfileDto },
  TContext
> => {
  const mutationKey = ["profileControllerUpdateProfileV1"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof profileControllerUpdateProfileV1>>,
    { data: UpdateAdminProfileDto }
  > = (props) => {
    const { data } = props ?? {};

    return profileControllerUpdateProfileV1(data, requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type ProfileControllerUpdateProfileV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof profileControllerUpdateProfileV1>>
>;
export type ProfileControllerUpdateProfileV1MutationBody =
  UpdateAdminProfileDto;
export type ProfileControllerUpdateProfileV1MutationError = Message;

export const useProfileControllerUpdateProfileV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof profileControllerUpdateProfileV1>>,
      TError,
      { data: UpdateAdminProfileDto },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof profileControllerUpdateProfileV1>>,
  TError,
  { data: UpdateAdminProfileDto },
  TContext
> => {
  const mutationOptions =
    getProfileControllerUpdateProfileV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
export const profileControllerChangePasswordV1 = (
  changePasswordDto: ChangePasswordDto,
  options?: SecondParameter<typeof customInstance>,
  signal?: AbortSignal,
) => {
  return customInstance<Message>(
    {
      url: `/v1/admin-change-password`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: changePasswordDto,
      signal,
    },
    options,
  );
};

export const getProfileControllerChangePasswordV1MutationOptions = <
  TError = Message,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof profileControllerChangePasswordV1>>,
    TError,
    { data: ChangePasswordDto },
    TContext
  >;
  request?: SecondParameter<typeof customInstance>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof profileControllerChangePasswordV1>>,
  TError,
  { data: ChangePasswordDto },
  TContext
> => {
  const mutationKey = ["profileControllerChangePasswordV1"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof profileControllerChangePasswordV1>>,
    { data: ChangePasswordDto }
  > = (props) => {
    const { data } = props ?? {};

    return profileControllerChangePasswordV1(data, requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type ProfileControllerChangePasswordV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof profileControllerChangePasswordV1>>
>;
export type ProfileControllerChangePasswordV1MutationBody = ChangePasswordDto;
export type ProfileControllerChangePasswordV1MutationError = Message;

export const useProfileControllerChangePasswordV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof profileControllerChangePasswordV1>>,
      TError,
      { data: ChangePasswordDto },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof profileControllerChangePasswordV1>>,
  TError,
  { data: ChangePasswordDto },
  TContext
> => {
  const mutationOptions =
    getProfileControllerChangePasswordV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
export const profileControllerUploadProfilePhotoV1 = (
  profileControllerUploadProfilePhotoV1Body: ProfileControllerUploadProfilePhotoV1Body,
  options?: SecondParameter<typeof customInstance>,
  signal?: AbortSignal,
) => {
  const formData = new FormData();
  if (profileControllerUploadProfilePhotoV1Body.file !== undefined) {
    formData.append(`file`, profileControllerUploadProfilePhotoV1Body.file);
  }

  return customInstance<AdminProfileResponseModel>(
    {
      url: `/v1/admin-profile-photo`,
      method: "POST",
      headers: { "Content-Type": "multipart/form-data" },
      data: formData,
      signal,
    },
    options,
  );
};

export const getProfileControllerUploadProfilePhotoV1MutationOptions = <
  TError = Message,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof profileControllerUploadProfilePhotoV1>>,
    TError,
    { data: ProfileControllerUploadProfilePhotoV1Body },
    TContext
  >;
  request?: SecondParameter<typeof customInstance>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof profileControllerUploadProfilePhotoV1>>,
  TError,
  { data: ProfileControllerUploadProfilePhotoV1Body },
  TContext
> => {
  const mutationKey = ["profileControllerUploadProfilePhotoV1"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof profileControllerUploadProfilePhotoV1>>,
    { data: ProfileControllerUploadProfilePhotoV1Body }
  > = (props) => {
    const { data } = props ?? {};

    return profileControllerUploadProfilePhotoV1(data, requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type ProfileControllerUploadProfilePhotoV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof profileControllerUploadProfilePhotoV1>>
>;
export type ProfileControllerUploadProfilePhotoV1MutationBody =
  ProfileControllerUploadProfilePhotoV1Body;
export type ProfileControllerUploadProfilePhotoV1MutationError = Message;

export const useProfileControllerUploadProfilePhotoV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof profileControllerUploadProfilePhotoV1>>,
      TError,
      { data: ProfileControllerUploadProfilePhotoV1Body },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof profileControllerUploadProfilePhotoV1>>,
  TError,
  { data: ProfileControllerUploadProfilePhotoV1Body },
  TContext
> => {
  const mutationOptions =
    getProfileControllerUploadProfilePhotoV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
