import axios from 'axios';
import { API_URL_ALARM } from '@/shared/api/api-url-alarm';
import { resultify } from '@/shared/lib/resultify';
import { NiceAxiosError } from '@/shared/@types/error';
import { 
  AppAlarmUnreadCountParams,
  AppAlarmUnreadCountResponse
} from '../model/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const appAlarmUnreadCount = (params: AppAlarmUnreadCountParams) => {
  return resultify(
    axios.post<AppAlarmUnreadCountResponse>(API_URL_ALARM.appAlarmUnreadCount(), params),
  );
};

export const useAppAlarmUnreadCountMutation = (options?: UseMutationOptions<AppAlarmUnreadCountResponse, NiceAxiosError, AppAlarmUnreadCountParams>) => {
  const mutation = useMutation<AppAlarmUnreadCountResponse, NiceAxiosError, AppAlarmUnreadCountParams>({
    ...options,
    mutationFn: (params: AppAlarmUnreadCountParams) => appAlarmUnreadCount(params),
  });

  return {
    ...mutation,
  };
};
