import React, {useState} from 'react';
import { SettingOutlined, QuestionCircleOutlined, LogoutOutlined, RightOutlined} from '@ant-design/icons';
import Icon from '@ant-design/icons';

import AdministrationIcon from '~/components/customIcon/AdministrationIcon';
import MyCoursesIcon from '~/components/customIcon/MyCoursesIcon';
import ExaminationIcon from '~/components/customIcon/ExaminationIcon';
import CommunityIcon from '~/components/customIcon/CommunityIcon';
import NotificationIcon from '~/components/customIcon/NotificationIcon';
import {Layout, Menu, theme, Button, Modal, MenuProps, Breadcrumb, Dropdown, Space} from 'antd';
import '../../public/assets/left_side_nav.css';

    let classmatesData = [
        {
            id: "1",
            name: "Daniel Nguyen",
            program: "Graduate Program",
            type: "Student",
            avatar: "avatar1.png"
        },
        {
            id: "2",
            name: "Sarah Anderson",
            program: "Post-Graduate Program",
            type: "Student",
            avatar: "avatar2.png"
        },
        {
            id: "3",
            name: "John Smith",
            program: "Undergraduate Program",
            type: "Student",
            avatar: "avatar3.png"
        },
        {
            id: "4",
            name: "Emily Davis",
            program: "Graduate Program",
            type: "Student",
            avatar: "avatar4.png"
        },
        {
            id: "5",
            name: "Michael Johnson",
            program: "Post-Graduate Program",
            type: "Student",
            avatar: "avatar5.png"
        },
        {
            id: "6",
            name: "Jessica Wilson",
            program: "Undergraduate Program",
            type: "Student",
            avatar: "avatar6.png"
        },
        {
            id: "7",
            name: "David Brown",
            program: "Graduate Program",
            type: "Student",
            avatar: "avatar1.png"
        },
        {
            id: "8",
            name: "Laura Lee",
            program: "Post-Graduate Program",
            type: "Student",
            avatar: "avatar2.png"
        },
        {
            id: "9",
            name: "Chris Miller",
            program: "Undergraduate Program",
            type: "Student",
            avatar: "avatar3.png"
        },
        {
            id: "10",
            name: "Sophia Taylor",
            program: "Graduate Program",
            type: "Student",
            avatar: "avatar4.png"
        },
        {
            id: "11",
            name: "James Anderson",
            program: "Post-Graduate Program",
            type: "Student",
            avatar: "avatar5.png"
        },
        {
            id: "12",
            name: "Olivia Thomas",
            program: "Undergraduate Program",
            type: "Student",
            avatar: "avatar6.png"
        },
        {
            id: "13",
            name: "Ethan Martinez",
            program: "Graduate Program",
            type: "Student",
            avatar: "avatar1.png"
        },
        {
            id: "14",
            name: "Ava Garcia",
            program: "Post-Graduate Program",
            type: "Student",
            avatar: "avatar2.png"
        },
        {
            id: "15",
            name: "Noah Rodriguez",
            program: "Undergraduate Program",
            type: "Student",
            avatar: "avatar3.png"
        },
        {
            id: "16",
            name: "Mia Martinez",
            program: "Graduate Program",
            type: "Student",
            avatar: "avatar4.png"
        },
        {
            id: "17",
            name: "Lucas Wilson",
            program: "Post-Graduate Program",
            type: "Student",
            avatar: "avatar5.png"
        },
        {
            id: "18",
            name: "Isabella Clark",
            program: "Undergraduate Program",
            type: "Student",
            avatar: "avatar6.png"
        },
        {
            id: "19",
            name: "Liam Walker",
            program: "Graduate Program",
            type: "Student",
            avatar: "avatar1.png"
        },
        {
            id: "20",
            name: "Charlotte Lewis",
            program: "Post-Graduate Program",
            type: "Student",
            avatar: "avatar2.png"
        }
    ];

    const { Header, Content, Sider } = Layout;

    const items1: MenuProps['items'] = ['1', '2', '3'].map((key) => ({
    key,
    label: `navsd ${key}`,
    }));

    type MenuItem = Required<MenuProps>['items'][number];


    const items2: MenuProps['items'] = [
        {
            key: 'subsd1',
            icon: <AdministrationIcon />,
            label: 'Administration',
            children: [
                {
                key: '1sd',
                label: (<a href='#'>Class Schedules</a>),
                },
                {
                key: '2sd',
                label: (<a href='#'>Classmate Directory</a>),
                },
                {
                key: '3sd',
                label: (<a href='#'>Qualifications</a>),
                },
            ],
        },
        {
            key: 'subsd2',
            icon: <MyCoursesIcon />,
            label: 'My Courses',
            children: [
                {
                key: '4sd',
                label: (<a href='#'>Graduate Program</a>),
                },
                {
                key: '5sd',
                label: (<a href='#'>Post-Graduate Program</a>),
                },
            ],
        },
        {
            key: 'subsd3',
            icon: <ExaminationIcon />,
            label: 'Examinations',
            children: [
                {
                key: '6sd',
                label: (<a href='#'>Exam Scheduled</a>),
                },
                {
                key: '7sd',
                label: (<a href='#'>Upcoming Exam</a>),
                },
                {
                key: '8sd',
                label: (<a href='#'>Passed Exam</a>),
                },
            ],
        },
        {
            key: 'subsd4',
            icon: <CommunityIcon />,
            label: 'Community',
            children: [
            {
                key: '9sd',
                label: (<a href='#'>Exam Scheduled</a>),
            },
            {
                key: '10sd',
                label: (<a href='#'>Upcoming Exam</a>),
            },
            {
                key: '11sd',
                label: (<a href='#'>Passed Exam</a>),
            },
            ],
        },
        {
            key: 'subsd5',
            icon: <NotificationIcon />,
            label: 'Notifications',
            children: [
                {
                key: '12sd',
                label: (<a href='#'>Exam Scheduled</a>),
                },
                {
                key: '13sd',
                label: (<a href='#'>Upcoming Exam</a>),
                },
                {
                key: '14sd',
                label: (<a href='#'>Passed Exam</a>),
                },
            ],
        },
        // getItem('Files', '9', <FileOutlined />),
        {
            key: 'grp',
            label: '',
            type: 'group',
            style: { marginTop: '100px' },
            children: [
            {   
                key: '15sd', style: {paddingTop: '10px', paddingBottom: '10px', border: 'none'}, 
                icon: React.createElement(SettingOutlined, { style: { color: '#000' } }), 
                label: (<h2 className='text-[18px] font-[700] text-[#000]'>Settings</h2>)
            },
            {
                key: '16sd', style: {paddingTop: '10px', paddingBottom: '10px', border: 'none'},
                icon: React.createElement(QuestionCircleOutlined, { style: { color: '#000' } }),
                label: (<h2 className='text-[18px] font-[700] text-[#000]'>Help & Support</h2>)
            },
            {
                key: '17sd', style: {paddingTop: '10px', paddingBottom: '10px', border: 'none'},
                icon: React.createElement(LogoutOutlined, { style: { color: '#000' } }),
                label: (<h2 className='text-[18px] font-[700] text-[#000]'>Logout</h2>)
            },     
            ],
        },
    ];
    const items: MenuProps['items'] = [
        {
        label: <a href="https://www.antgroup.com">1st menu item</a>,
        key: '01sd',
        },
        {
        type: 'divider',
        },
        {
        label: <a href="https://www.aliyun.com">2nd menu item</a>,
        key: '02sd',
        },
        {
        type: 'divider',
        },
        {
        label: '3rd menu item',
        key: '03sd',
        },
];

const App: React.FC = () => {
    const [collapsed, setCollapsed] = useState(false);
    const [open, setOpen] = React.useState<boolean>(false);
    const [loading, setLoading] = React.useState<boolean>(true);

    const showLoading = () => {
        setOpen(true);
        setLoading(true);

        // Simple loading mock. You should add cleanup logic in real world.
        setTimeout(() => {
        setLoading(false);
        }, 100);
    };
    const { token: { colorBgContainer}, } = theme.useToken();

  return (
    
    <Layout>
        <>
            {/* <Button type="primary" onClick={showLoading}>Open Modal</Button> */}
            <Modal style={{top: '20px', right: '0px'}} title={<p>Loading Modal</p>} footer={ <Button type="primary" onClick={showLoading}> Reload </Button>} loading={loading} open={open} onCancel={() => setOpen(false)} >
                <p>Some contents...</p>
                <p>Some contents...</p>
                <p>Some contents...</p>
            </Modal>
        </>
        {/* <Header style={{ display: 'flex', alignItems: 'center' }}>
            <div className="demo-logo" />
            <Menu theme="dark" mode="horizontal" defaultSelectedKeys={['2']} items={items1} style={{ flex: 1, minWidth: 0 }} />
        </Header> */}
        <Layout>
            <div >
            <Sider collapsible collapsed={collapsed} onCollapse={(value) => setCollapsed(value)} width={366} style={{overflow: 'auto', height: '110vh', position: 'fixed', left: 0, top: 0, bottom: 0,  background: '#FFF', borderRight: '1px solid #CFCFCF', borderBottom: '2px solid #000'}}>
                <div className='flex flex-col justify-center demo-logo-vertical'>
                    <div className='px-4'>
                        <h1 className='text-[22px] font-[700] my-[37px] text-left text-[#000]'>IIMTT Logo</h1>    
                    </div>
                </div>
                <Menu className='custom-menu' mode="inline"  style={{ height: '100%', borderRight: 0, paddingTop: 30, background: 'transparent'}} items={items2} />
            </Sider>
            </div>
            {/* defaultSelectedKeys={['1']} defaultOpenKeys={['sub1']} */}
            <Layout style={{marginLeft: 366, background: '#FFF'}}>
                <Content style={{  overflow: 'initial',}}>
                    <div className='py-2'>
                        <div className='container mx-auto flex flex-row justify-between pr-10'>
                            <div className='inline-flex justify-center place-items-center'>
                                <Breadcrumb separator=">" items={[{title: <a href="">Administration</a>,},{title: 'Class Directory',},]}/>
                            </div>
                            <div>
                                <Button className='border-none shadow-none bg-transparent hover:bg-transparent' onClick={showLoading}>
                                    <div className='border-[1px] border[#525252] rounded-full p-2 w-[47px] h-[47px]'>
                                        <svg  viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg">
                                            <path d="M5.06445 20.2658V18.2111H7.1191V11.0198C7.1191 9.59872 7.54715 8.33597 8.40325 7.2316C9.25935 6.12723 10.3723 5.40382 11.742 5.06138V4.34225C11.742 3.9142 11.8919 3.55036 12.1915 3.25072C12.4911 2.95109 12.855 2.80127 13.283 2.80127C13.7111 2.80127 14.0749 2.95109 14.3746 3.25072C14.6742 3.55036 14.824 3.9142 14.824 4.34225V5.06138C16.1938 5.40382 17.3067 6.12723 18.1628 7.2316C19.0189 8.33597 19.447 9.59872 19.447 11.0198V18.2111H21.5016V20.2658H5.06445ZM13.283 23.3477C12.718 23.3477 12.2343 23.1465 11.8319 22.7442C11.4296 22.3418 11.2284 21.8581 11.2284 21.2931H15.3377C15.3377 21.8581 15.1365 22.3418 14.7341 22.7442C14.3318 23.1465 13.8481 23.3477 13.283 23.3477ZM9.17374 18.2111H17.3923V11.0198C17.3923 9.88979 16.99 8.9224 16.1852 8.11766C15.3805 7.31293 14.4131 6.91056 13.283 6.91056C12.153 6.91056 11.1856 7.31293 10.3808 8.11766C9.57611 8.9224 9.17374 9.88979 9.17374 11.0198V18.2111Z" fill="black"/>
                                            <circle cx="19.4462" cy="19.2384" r="4.23771" fill="#FF0000" stroke="#fff" strokeWidth="2.31148"/>
                                        </svg>
                                    </div>
                                </Button>
                                <Dropdown menu={{ items }} trigger={['click']}>
                                    <a onClick={(e) => e.preventDefault()}>
                                        <Space>
                                            <div className='flex flex-row border-[1px] border-[#BBBBBB] rounded-full p-1 gap-x-6'>
                                                <img src="/assets/man.png" alt="" />
                                                <div>
                                                    <p className='text-[12px] text-[#EF7A0C] font-[500]'>My Profile</p>
                                                    <p className='text-[16px] text-[#27549F] font-[700]'>Rayan Holiday</p>
                                                </div>
                                                <RightOutlined style={{ fontSize: '12px', paddingRight: '10px' }} />
                                            </div>
                                        </Space>
                                    </a>
                                </Dropdown>
                            </div>
                        </div>
                    </div>


                    <section className='container mx-auto '>
                        <div className='grid gridcols-1 md:grid-cols-7 border-[1px] border-[#CFCFCF]'>
                            <div className='col-span-5 border-r-[1px] border-[#CFCFCF]'>
                                <p className='text-[18px] font-[700] text-[#525252] border-b-[1px] border-[#CFCFCF] py-5 pl-5'><span>Your Classmates </span>| <span>Graduate Program</span></p>
                                <div className='grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4'>
                                    {classmatesData.map(data => (
                                        <div key={data.id} className='w-60 h-60 bg-cover bg-center' style={{ backgroundImage: `url('../../assets/${data.avatar}')` }}>
                                            <img className='w-[60px] h-[60px]' src={`../../assets/${data.avatar}`} alt="" />
                                        </div>
                                    ))}
                                </div>
                            </div>
                            <div className='col-span-2'>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur dignissimos nostrum fugit animi nobis. Explicabo nam accusamus harum doloremque praesentium officia, vel laborum nobis eveniet quibusdam ex rem asperiores alias!</div>
                        </div>
                    </section>                   
                </Content>
            </Layout>
        </Layout>
    </Layout>
  );
};
export default App;