import { IGenericLocation } from "../../../../generic/types";
import { IRWCAnswerComponent } from "../../../types";

export const transformGeoLocation = (msg: IRWCAnswerComponent): IGenericLocation => {
  const result: IGenericLocation = {
    type: 'location',
    props: {
      label: msg.vBind?.buttonLabel,
    }
  };

   if (msg.vBind?.useDefault) {
      const defaultLat = msg.vBind?.defaultLat || 0;
      const defaultLng = msg.vBind?.defaultLng || 0;
      result.props.value = [defaultLat, defaultLng];
   }

  return result;
};
