diff --git a/src/new-frontend/src/components/Sidebar.tsx b/src/new-frontend/src/components/Sidebar.tsx new file mode 100644 index 0000000000..d2f2e83334 --- /dev/null +++ b/src/new-frontend/src/components/Sidebar.tsx @@ -0,0 +1,48 @@ +import React from 'react'; + +import { Box, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerOverlay, Flex, IconButton, Image, useDisclosure } from '@chakra-ui/react'; +import { FiMenu } from 'react-icons/fi'; + +import Logo from "../assets/images/fastapi-logo.png"; +import SidebarItems from './SidebarItems'; +import UserInfo from './UserInfo'; + + +const Sidebar: React.FC = () => { + const { isOpen, onOpen, onClose } = useDisclosure(); + + return ( + <> + {/* Mobile */} + } /> + + + + + + + + Logo + + + + + + + + + {/* Desktop */} + + + + Logo + + + + + + + ); +} + +export default Sidebar; diff --git a/src/new-frontend/src/components/SidebarItems.tsx b/src/new-frontend/src/components/SidebarItems.tsx new file mode 100644 index 0000000000..8970410d8c --- /dev/null +++ b/src/new-frontend/src/components/SidebarItems.tsx @@ -0,0 +1,37 @@ +import React from 'react'; + +import { Flex, Icon, Text } from '@chakra-ui/react'; +import { FiBriefcase, FiHome, FiLogOut, FiUser, FiUsers } from 'react-icons/fi'; +import { Link } from 'react-router-dom'; + +const items = [ + { icon: FiHome, title: 'Dashboard', path: "/" }, + { icon: FiUser, title: 'Profile', path: "/profile" }, + { icon: FiBriefcase, title: 'Items', path: "/items" }, + { icon: FiUsers, title: 'Admin', path: "/admin" }, + { icon: FiLogOut, title: 'Log out' } +]; + +const SidebarItems: React.FC = () => { + const listItems = items.map((item) => ( + + + + + {item.title} + + + + )); + + return ( + <> + {listItems} + + ); +}; + +export default SidebarItems; diff --git a/src/new-frontend/src/components/UserInfo.tsx b/src/new-frontend/src/components/UserInfo.tsx new file mode 100644 index 0000000000..3cf059b3f2 --- /dev/null +++ b/src/new-frontend/src/components/UserInfo.tsx @@ -0,0 +1,40 @@ +import React, { useEffect, useState } from 'react'; + +import { Avatar, Flex, Skeleton, Text } from '@chakra-ui/react'; +import { FaUserAstronaut } from 'react-icons/fa'; + +import { UserOut, UsersService } from '../client'; + +const UserInfo: React.FC = () => { + const [userData, setUserData] = useState(); + + useEffect(() => { + const fetchUserData = async () => { + try { + const userResponse = await UsersService.readUserMe(); + setUserData(userResponse); + } catch (error) { + // TODO: Handle error to give feedback to the user + console.error(error); + } + }; + fetchUserData(); + }, []); + + return ( + <> + {userData ? ( + + } size='sm' alignSelf="center" /> + {/* TODO: Conditional tooltip based on email length */} + {userData.email} + + ) : + + } + + ); + +} + +export default UserInfo; \ No newline at end of file diff --git a/src/new-frontend/src/pages/Layout.tsx b/src/new-frontend/src/pages/Layout.tsx new file mode 100644 index 0000000000..80e78f16c9 --- /dev/null +++ b/src/new-frontend/src/pages/Layout.tsx @@ -0,0 +1,14 @@ +import Sidebar from '../components/Sidebar'; + +import { Flex } from '@chakra-ui/react'; + +const Layout = ({ children }: { children: React.ReactNode }) => { + return ( + + + {children} + + ); +}; + +export default Layout;