import * as React from 'react';
import { ViewBoxBaseComponent } from '../../DocComponent';
import { FieldView, FieldViewProps } from '../FieldView';
import { MapBox } from './MapBox';

/**
 * Map Pushpin doc class
 */
export class MapPushpinBox extends ViewBoxBaseComponent<FieldViewProps>() {
    public static LayoutString(fieldKey: string) {
        return FieldView.LayoutString(MapPushpinBox, fieldKey);
    }
    componentDidMount() {
        this.mapBoxView.addPushpin(this.Document);
    }
    componentWillUnmount() {
        this.mapBoxView.deletePushpin(this.Document);
    }

    get mapBoxView() {
        return this.DocumentView?.()?.containerViewPath?.().lastElement()?.ComponentView as MapBox;
    }
    get mapBox() {
        return this.DocumentView?.().containerViewPath?.().lastElement()?.Document;
    }

    render() {
        return <div />;
    }
}
