// import store, { AppDispatch } from ".."
import http from "@/utils/http";
import { AppDispatch } from "..";

/**
 * 用户登录接口
 */
export const userLoginAPI = (data: any) => {
  return http.post("admin/login", { ...data });
};

/**
 * 修改密码接口
 */
export const passWordEditAPI = (data: any) => {
  return http.post("sys/user/updatePwd", { ...data });
};

/**
 * 获取所有下拉列表
 */
export const getSelectAllAPI = () => {
  return async (dispatch: AppDispatch) => {
    const res: any = await http.post("cms/dict/getTree", {});
    const data: any = res.data;
    const obj = {} as any;
    data.forEach((v: any) => {
      obj[v.name] = v.children;
    });

    // console.log(123, obj);
    dispatch({ type: "login/getSelectAll", payload: obj });
  };
};

/**
 * 首页的审核提醒
 */
export const getHomeNumsAPI = () => {
  return http.get("cms/report/remind");
};

/**
 * 获取用户权限
 */
export const getPowerInfoAPI = () => {
  return http.get("sys/resource/getTreePermissions");
};
