import { request } from '@umijs/max';
import type { CurrentUser, GeographicItemType } from './data';
import { CommonResponse } from '@/types/common';

export async function queryCurrent(): Promise<{ data: CurrentUser }> {
  return request('/user-api/info');
}
export async function updateCurrentUser(params: CurrentUser): Promise<{data: CommonResponse<string>}> {
  return request('/user-api/info', {
    method: 'PUT',
    data: params,
  })
}
export async function queryProvince(): Promise<{ data: GeographicItemType[] }> {
  return request('/api/geographic/province');
}

export async function queryCity(province: string): Promise<{ data: GeographicItemType[] }> {
  return request(`/api/geographic/city/${province}`);
}

export async function query() {
  return request('/api/users');
}
