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

import { userQueryKeys } from '../user-query-keys';
import { type PostSetProfileDataReturn, type PostSetProfileData, userApi } from '../user-api';

import type { BaseAxiosError } from '../../../../types';

export const usePostSetProfileMutation = () => {
  return useMutation<
    PostSetProfileDataReturn,
    BaseAxiosError,
    PostSetProfileData,
    PostSetProfileDataReturn
  >({
    mutationKey: userQueryKeys.setProfileData(),
    mutationFn: async (data) => {
      const response = await userApi.setProfileData(data);
      return response.data;
    }
  });
};
