import { createAsyncThunk } from "@reduxjs/toolkit";
import axios from "axios";

export const getStewards = createAsyncThunk(
  "MAIN_GET_STEWARDS",
  async (province) => {
    const axiosInstance = axios.create();
    axiosInstance.defaults.headers.common = {};

    const apiUrl = `https://amait.mrkiani.ir/api/report/pos/${
      province === "markazi" ? "markazi" : "hamadan"
    }`;

    try {
      const response = await axiosInstance.get(apiUrl);
      const { data, status } = response;
      return { data, status };
    } catch (error) {
      console.error("Error fetching data:", error);
      throw error;
    }
  }
);
