import http from '@/utils/http';
import { Estate, EstateType } from '@/types/common';
import { calcEstate } from '@/utils/transform';

export async function getEstateDetail(id: string) {
  const {
    ok,
    data,
    msg,
  } = await http.get<Estate>('/estateorder/detail', { id });
  if (ok && data) {
    data.type = data.outTime ? EstateType.Sold : EstateType.Hold;
    calcEstate(data);
    return data;
  }

  throw Error(msg);
}
