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

import { userQueryKeys } from '../user-query-keys';
import { userApi } from '../user-api';
import { ResponseType } from '@api/response-type';

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

export const usePostSaveNotificationTokenMutation = () => {
  return useMutation<
    ResponseType,
    BaseAxiosError,
    {
      token: string;
      platform: string;
      n_token: string;
    },
    ResponseType
  >({
    mutationKey: userQueryKeys.setNotificationToken(),
    mutationFn: async (variables) => {
      const response = await userApi.setNotificationToken(
        variables.token,
        variables.platform,
        variables.n_token
      );
      return response.data;
    }
  });
};
