import axios from 'axios';
import { UserState } from '@/store/modules/user/types';
import type {
  LoginData,
  SchoolItem,
  SysMenuRes,
  SchoolInfo,
} from './types/user';

export function login(data: LoginData): Promise<UserState> {
  return axios.post('/api/admin/common/login', data);
}

export function schoolList(): Promise<SchoolItem[]> {
  return axios.post('/api/admin/client/school/list', {});
}

export function schoolDetailInfo(code: string): Promise<SchoolInfo> {
  return axios.post(
    '/api/admin/common/school/query_by_school_code',
    {},
    {
      params: { code },
    }
  );
}

export function sysMenu(): Promise<SysMenuRes> {
  return axios.post('/api/admin/common/get_menu', {});
}
export function userLogout() {
  return axios.post('/api/admin/common/logout', {});
}
