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

export const provinceGetGuildsNumbersNamesService = createAsyncThunk(
  "PROVINCE_GET_GUILDS_NUMBERS_NAMES_SERVICE",
  async (d, { dispatch }) => {
    dispatch(LOADING_START());
    d = d || moment(new Date()).format("YYYY-MM-DD");
    const { data, status } = await axios.get("guilds/", {
      params: { type: "kill_house_percentage", percentage_key: d.key },
    });
    dispatch(LOADING_END());
    return { data, status };
  }
);
