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 { 
  AppAlarmMarkParams,
  AppAlarmMarkResponse
} from '../model/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const appAlarmMark = (params: AppAlarmMarkParams) => {
  return resultify(
    axios.post<AppAlarmMarkResponse>(API_URL_ALARM.appAlarmMark(), params),
  );
};

export const useAppAlarmMarkMutation = (options?: UseMutationOptions<AppAlarmMarkResponse, NiceAxiosError, AppAlarmMarkParams>) => {
  const mutation = useMutation<AppAlarmMarkResponse, NiceAxiosError, AppAlarmMarkParams>({
    ...options,
    mutationFn: (params: AppAlarmMarkParams) => appAlarmMark(params),
  });

  return {
    ...mutation,
  };
};
