import { usePost, stringify, useGet } from "@/.cool";
export type LoginData = {
  access_token: string;
  refresh_token: string;
}
export interface GetInfoResult {
  permissions: any[]
  roles: any[]
  sysRoles: any[]
  userInfo: any
}
export interface CONFIG_OPEN_CHILDREN_ALL {
  code: string
  name: string
  id: string
  content: string
  description: string
  type: number
  openFlag: boolean
}
export interface DICT_CHILDREN_ALL {
  code: string
  label: string
  value: string
}
export interface CONFIG_OPEN_VALUE {
  [key: string]: string
}
export interface DICT_DATA {
  'config:open:children-all': CONFIG_OPEN_CHILDREN_ALL[]
  'config:open:value': CONFIG_OPEN_VALUE
  'dict:children': {
    [key: string]: CONFIG_OPEN_VALUE
  }
  'dict:value:obj': {
    [key: string]: CONFIG_OPEN_VALUE
  }
  'dict:value': { [key: string]: CONFIG_OPEN_VALUE }
  'dict:code': { [key: string]: CONFIG_OPEN_VALUE }
  'dict:label': { [key: string]: CONFIG_OPEN_VALUE }
  'dict:children-all': { [key: string]: DICT_CHILDREN_ALL[] }
}
export function loginApi(params) {
  return usePost(`/oauth/token?${stringify(params)}`) as Promise<LoginData>
}
export function sendSmsCode(params) {
  return usePost(`/verify/sms/code/send`, params) as Promise<string>
}
export function getUsersInfo() {
  return useGet(`/upms/users/info`) as Promise<GetInfoResult>
}
export function dictData() {
  return useGet(`/upms/dicts/data`) as Promise<DICT_DATA>
}