import React from 'react';
import PropTypes from 'prop-types';
import BaseContent from './base';
import VmGasModal from '../vm-gas-modal';
import useModal from '../vm-hooks/useModal';
import SupplyStationInfo from './supplyStationInfo';
import BottleList from './bottleList';
import './style';
const TABS_BASE = 'gas-filling-station-base';
const TABS_SUPPLYSTATIONINFO = 'gas-filling-station-supply-station-info';
const TABS_BOTTLELIST = 'gas-filling-station-bottle-list';
const Modal = ({ id, ...resetProps }) => {
    const tabs = [
        {
            value: '基础信息',
            content: <BaseContent id={id} />,
            key: TABS_BASE,
        },
        {
            value: '供应站信息',
            content: <SupplyStationInfo id={id} />,
            key: TABS_SUPPLYSTATIONINFO,
        },
        {
            value: '气瓶信息 ',
            content: <BottleList id={id} />,
            key: TABS_BOTTLELIST,
        },
    ];

    return <VmGasModal tabs={tabs} title="储配站" {...resetProps} />;
};

const VtxGasFillingStationModal = 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,
};

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

VtxGasFillingStationModal.Modal = Modal;

export default VtxGasFillingStationModal;
