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

export const getUserRoleInfo = createAsyncThunk(
  "GET_USER_ROLE_INFO",
  async ({ userKey, role }, { dispatch }) => {
    try {
      dispatch(LOADING_START());
      const { data, status } = await axios.get("user-role-info/", {
        params: {
          user_key: userKey,
          role: role,
        },
      });
      dispatch(LOADING_END());
      return { data, status };
    } catch (error) {
      dispatch(LOADING_END());
      throw error;
    }
  }
);
