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

export const tradePanelChart = createAsyncThunk(
  "TRADE_PANEL_CHART",
  async (d) => {
    try {
      const { data, status } = await axios.get(
        `/direct-buying-poultry-requests-chart`,
        {
          params: {
            role: getRoleFromUrl(),
            role_key: d?.role_key || "",
          },
        }
      );
      return { data, status };
    } catch (e) {
      return { error: e.response.data };
    }
  }
);
