import { createAsyncThunk } from "@reduxjs/toolkit";
import axios from "axios";
import { LOADING_END, LOADING_START } from "../../../lib/redux/slices/appSlice";

export const visorsGetNationalInfoService = createAsyncThunk(
  "VISORS_GET_NATIONAL_iNFO",
  async (d, { dispatch }) => {
    dispatch(LOADING_START());
    const { data, status } = await axios.get(
      `https://rsibackend.rasadyar.com/app/hatching-analysis-` + d.type,
      {
        params: {
          date1: d.withDate ? d.selectedDate1 : null,
          date2: d.withDate ? d.selectedDate2 : null,
          province: d.selectedProvince ? d.selectedProvince : null,
        },
      }
    );
    dispatch(LOADING_END());
    return { data, status };
  }
);
