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

export const provinceTradePanelMarketRequestOverview = createAsyncThunk(
  "PROVINCE_GET_TRADE_PANEL_MARKET_REQUEST",
  async (d) => {
    try {
      const { data, status } = await axios.get(`kill-house-market-info`, {
        params: { ...d, role: getRoleFromUrl() || "" },
      });
      return { data, status };
    } catch (e) {
      return { error: e.response.data.result };
    }
  }
);

export const provinceTradePanelMarketRequestAdminOverview = createAsyncThunk(
  "PROVINCE_GET_TRADE_PANEL_ADMIN_MARKET_REQUEST",
  async (d) => {
    try {
      const { data, status } = await axios.get(
        `kill-house-market-info-dashboard`,
        {
          params: { ...d, role: getRoleFromUrl() || "" },
        }
      );
      return { data, status };
    } catch (e) {
      return { error: e.response.data.result };
    }
  }
);
