import axios from 'axios';
import { API_URL_SUPPORT } from '@/shared/api/api-url-support';
import { resultify } from '@/shared/lib/resultify';
import { CBDCAxiosError } from '@/shared/@types/error';
import { 
  FaqListParams,
  FaqListResponse
} from '../model/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const faqList = (params: FaqListParams) => {
  return resultify(
    axios.post<FaqListResponse>(API_URL_SUPPORT.faqList(), params),
  );
};

export const useFaqListMutation = (options?: UseMutationOptions<FaqListResponse, CBDCAxiosError, FaqListParams>) => {
  const mutation = useMutation<FaqListResponse, CBDCAxiosError, FaqListParams>({
    ...options,
    mutationFn: (params: FaqListParams) => faqList(params),
  });

  return {
    ...mutation,
  };
};
