import { useMutation } from '@tanstack/react-query';

import { locationQueryKeys } from '../location-query-keys';
import { locationApi } from '../location-api';

import type { BaseAxiosError } from '../../../../types';
import { ResponseType } from '@api/response-type';

export const usePostSetSettingsRegionsMutation = () => {
  return useMutation<ResponseType, BaseAxiosError, { token: string; sharing: 0 | 1 }, ResponseType>(
    {
      mutationKey: locationQueryKeys.setSettingsRegions(),
      mutationFn: async (variables) => {
        const response = await locationApi.setSettingsRegions(variables.token, variables.sharing);
        return response.data;
      }
    }
  );
};
