import React, {Component} from 'react';

import {Layout, Menu} from 'antd';

import SchemaCreate from "./schemaCreate/SchemaCreate";
import DatabaseSetting from "./databaseSetting/DatabaseSetting";

const { Content } = Layout;

class DataStorage extends Component {
    constructor() {
        super();
        this.state = {
            menuLevel2: "schema-creations",
        }
    }

    switchMenu = (menuName, e) => {
        console.log('menuName', menuName, 'e', e);
        this.setState({
            [menuName]: e.key,
        });
    };

    render() {
        return (
            <div>
                <Menu
                    mode="horizontal"
                    defaultSelectedKeys={['schema-creations']}
                    style={{padding: '0 24px', position: 'fixed', width: '100%', zIndex: '1'}}
                    onClick={(e) => this.switchMenu('menuLevel2', e)}
                    selectedKeys={[this.state.menuLevel2]}
                >
                    <Menu.Item key="schema-creations">schema creations</Menu.Item>
                    <Menu.Item key="database-settings">database settings</Menu.Item>
                </Menu>

                <Layout style={{ padding: '24px', zIndex: '0'}}>
                    <Content style={{ padding: '24px', minHeight: 280, background: '#fff',marginTop: '48px'  }}>
                        {(() => {
                            switch (this.state.menuLevel2) {
                                case 'schema-creations':
                                    return <SchemaCreate />;
                                case 'database-settings':
                                    return <DatabaseSetting />;
                                default:
                                    return <SchemaCreate />
                            }
                        })()}
                    </Content>
                </Layout>
            </div>
        )
    }
}

export default DataStorage;