/**
 * 用户信息相关接口
 */
import type { LoginParams, LoginResult } from './types';
import { get, post } from '@/utils/request';
import type { UserState } from '@/store/modules/user/types';

enum URL {
  // login = '/member/login',
  login = '/wc/wechat/LoginByMa',
  loginByCode = '/wc/wechat/LoginByMaCode',
  logout = '/user/logout',
  profile = '/user/profile',
  addressList = '/addr/list',
  addressDetail = '/addr/find',
  addressCreate = '/addr/create',
  addressUpdate = '/addr/update',
  addressDelete = '/addr/delete',
}

export const getUserProfile = () => get<UserState>({ url: URL.profile });
export const login = (data: LoginParams) => post<LoginResult>({ url: URL.login, data });
export const loginByCode = (code: string, companyId: string) => post<any>({ url: URL.loginByCode + `?code=${code}` });
export const logout = () => post<any>({ url: URL.logout });

export const getAddressList = () => get<any>({ url: URL.addressList });
export const getAddressDetail = (id: string) => get<any>({ url: URL.addressDetail + `?id=${id}` });
export const addressCreate = (data: any) => post<any>({ url: URL.addressCreate, data });
export const addressUpdate = (data: any) => post<any>({ url: URL.addressUpdate, data });
export const addressDelete = (id: string) => post<any>({ url: URL.addressDelete + `?id=${id}` });
