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

export const provinceJahadGetSingleRancherService = createAsyncThunk(
  "PROVINCE_JAHAD_GET_SINGLE_RANCHER",
  async (d, { dispatch }) => {
    dispatch(LOADING_START());
    const { data, status } = await axios.get(
      `LiveStock/rancher/rancher-view/`,
      {
        params: {
          value: d.value,
          search: "filter",
          role: getRoleFromUrl(),
        },
      }
    );
    dispatch(LOADING_END());
    return { data, status };
  }
);
