import React from 'react';
import PropTypes from 'prop-types';
import VmGasModal from '../vm-gas-modal';

import BaseContent from './base';
import useModal from '../vm-hooks/useModal';
import './style';
const TABS_BASE = 'gas-security-check-base';
const Modal = ({ id, ...resetProps }) => {
    const tabs = [
        {
            value: '入户安检记录',
            key: TABS_BASE,
            content: <BaseContent id={id} />,
        },
    ];
    return <VmGasModal title="入户安检记录" {...resetProps} tabs={tabs} />;
};

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

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

VtxGasSecurityCheckModal.Modal = Modal;

export default VtxGasSecurityCheckModal;
