import VmGasModal from '../vm-gas-modal';
import React from 'react';
import PropTypes from 'prop-types';
import BaseContent from './base';
import './style';
import useModal from '../vm-hooks/useModal';

const TABS_BASE = 'gas-station-base';
const Modal = ({ id, ...resetProps }) => {
    const tabs = [
        {
            value: '站点信息',
            content: <BaseContent id={id} />,
            key: TABS_BASE,
        },
    ];
    return <VmGasModal tabs={tabs} title="场站" {...resetProps} />;
};

const VtxGasStationModal = props => {
    const { label, id } = props;
    const { showModal, ...modalProps } = useModal();

    return (
        <>
            {label ? (
                <a type="link" onClick={showModal}>
                    {label}
                </a>
            ) : (
                <span>-</span>
            )}
            {modalProps.visible && <Modal id={id} {...modalProps} />}
        </>
    );
};

Modal.propTypes = {
    id: PropTypes.string.isRequired,
};

VtxGasStationModal.propTypes = {
    id: PropTypes.string.isRequired,
    label: PropTypes.string.isRequired,
};

VtxGasStationModal.Modal = Modal;

export default VtxGasStationModal;
