import {
  DATA_URL,
  PROCEDURES,
} from 'config'
import { callApi } from 'helpers'

const proc = PROCEDURES.get_user_info

export type UserInfo = {
  address_line1: string | null,
  address_line2: string | null,
  city: string | null,
  cityId: number | null,
  country?: {
    id: number,
    name_eng: string,
    name_rus: string,
  },
  firstname: string | null,
  lastname: string | null,
  password: string | null,
  phone: string | null,
  region: string | null,
}

export const getUserInfo = (): Promise<UserInfo> => {
  const config = {
    body: { params: {}, proc },
  }

  return callApi({
    config,
    url: DATA_URL,
  })
}
