/**
 * 通用弹窗
 */
import { useSetState } from 'ahooks';
import React, { useEffect } from 'react';
import VtxBaseModal from '../vtx-base-modal';
import { BaseInfo } from './components';
// import useSettings from '../vm-hooks/useSettings';
import '../style';
import Appraisal from '../vm-appraisal-info';
import RepaireMaintain from '../vm-repair-maintain';

const TABS_BASE = 'default-base';
const TABS_APPRAISAL = 'default-appraisal';
const TABS_RM = 'default-rm';
// const TABS_WARNNING = 'cp-warning';

export interface VtxDefaultModalProps {
    id: string;
    visible: boolean;
    onCancel: () => void;
    title: string;
    subTitle?: string;
    theme: string;
}

const VtxDefaultModal = (props: VtxDefaultModalProps) => {
    const { id, title, subTitle, visible, onCancel, theme } = props;
    const isDark = theme === 'dark';
    const [state, setState] = useSetState({
        tab: TABS_BASE,
        time: new Date().toString(),
    });
    useEffect(() => {
        if (visible) {
            setState({ time: new Date().toString() });
        }
    }, [visible]);

    useEffect(() => {
        //
        window.console.log(isDark);
    }, [state.tab]);

    return (
        <>
            {visible && (
                <VtxBaseModal
                    title={title}
                    subTitle={subTitle}
                    width={1210}
                    height={550}
                    visible={visible}
                    onCancel={onCancel}
                    onTabsChange={tab => {
                        setState({ tab });
                    }}
                    tabs={[
                        { key: TABS_BASE, title: '总览信息' },
                        { key: TABS_APPRAISAL, title: '考核信息' },
                        { key: TABS_RM, title: '维保信息' },
                    ]}
                    contents={{
                        [TABS_BASE]: <BaseInfo id={id} />,
                        [TABS_APPRAISAL]: <Appraisal id={id} />,
                        [TABS_RM]: <RepaireMaintain id={id} />,
                    }}
                />
            )}
        </>
    );
};

export default VtxDefaultModal;
