diff --git a/src/pages/components/Navbar/MobileNav.tsx b/src/pages/components/Navbar/MobileNav.tsx new file mode 100644 index 00000000..d9aa68bf --- /dev/null +++ b/src/pages/components/Navbar/MobileNav.tsx @@ -0,0 +1,101 @@ +import React from 'react'; +import { + Avatar, + Box, + Flex, + FlexProps, + HStack, + IconButton, + Input, + InputGroup, + InputRightElement, + Menu, + MenuButton, + MenuDivider, + MenuItem, + MenuList, + Text, + VStack, + useBreakpointValue, + useColorModeValue, +} from '@chakra-ui/react'; +import Image from 'next/image'; +import { BellIcon, ChevronDownIcon, HamburgerIcon, Search2Icon } from '@chakra-ui/icons'; +import { useTranslation } from 'react-i18next'; +import { DEFAULT_AVATAR, LOGO_URL } from '../../../shared/constants/Developers'; + +interface MobileProps extends FlexProps { + onOpen: () => void; +} + +const MobileNav: React.FC = function MobileNav({ onOpen }) { + const { t } = useTranslation('dashboard'); + const showLogo = useBreakpointValue({ base: false, md: false }); + const showIconBtn = useBreakpointValue({ base: 'flex', md: false }); + const showMd = useBreakpointValue({ base: 'none', md: 'flex' }); + + return ( + + {showIconBtn ? ( + } /> + ) : null} + + {showLogo ? IgboAPI logo : null} + + + + + + + + + + + + + + + + + {showMd ? ( + <> + + Egorp David + + + + + + ) : null} + + + + + {t('Profile')} + + + {t('Settings')} + + + {t('Sign out')} + + + + + + ); +}; + +export default MobileNav; diff --git a/src/pages/components/Sidebar/Sidebar.tsx b/src/pages/components/Sidebar/Sidebar.tsx new file mode 100644 index 00000000..c88e583b --- /dev/null +++ b/src/pages/components/Sidebar/Sidebar.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { Drawer, DrawerContent, useBreakpointValue, useDisclosure } from '@chakra-ui/react'; +import SidebarContent from './SidebarContent'; +import MobileNav from '../Navbar/MobileNav'; + +const Sidebar: React.FC = function Sidebar() { + const { isOpen, onOpen, onClose } = useDisclosure(); + const showSidebar = useBreakpointValue({ base: false, md: true }); + + return ( + <> + {showSidebar ? : null} + + + + + + + + ); +}; + +export default Sidebar; diff --git a/src/pages/components/Sidebar/SidebarContent.tsx b/src/pages/components/Sidebar/SidebarContent.tsx new file mode 100644 index 00000000..d641dd0c --- /dev/null +++ b/src/pages/components/Sidebar/SidebarContent.tsx @@ -0,0 +1,55 @@ +import React from 'react'; +import { Box, BoxProps, CloseButton, Flex, Text, useColorModeValue } from '@chakra-ui/react'; +import { AtSignIcon, ChatIcon, HamburgerIcon, StarIcon, WarningIcon } from '@chakra-ui/icons'; +import { useTranslation } from 'react-i18next'; +import Image from 'next/image'; +import SidebarItem from './SidebarItem'; +import { LOGO_URL } from '../../../shared/constants/Developers'; + +interface SidebarProps extends BoxProps { + onClose: () => void; +} + +const SidebarContent: React.FC = function SidebarContent({ onClose }) { + const { t } = useTranslation('dashboard'); + + const LinkItems = [ + { name: t('Profile'), href: '/profile', icon: }, + { name: t('Dashboard'), href: '/dashboard', icon: }, + { name: t('API Documentation'), href: '/api-documentation', icon: }, + { name: t('Contact Us'), href: '/contact-us', icon: }, + ]; + + return ( + + + Igbo API logo + + + + } href="#" _active={{ bg: 'gray.200' }} _hover={{ bg: 'gray.200' }} mb={5}> + + {t('Menu')} + + + + {LinkItems.map((link) => ( + + + {link.name} + + + ))} + + ); +}; + +export default SidebarContent; diff --git a/src/pages/components/Sidebar/SidebarItem.tsx b/src/pages/components/Sidebar/SidebarItem.tsx new file mode 100644 index 00000000..5846a039 --- /dev/null +++ b/src/pages/components/Sidebar/SidebarItem.tsx @@ -0,0 +1,36 @@ +import React from 'react'; +import { Box, Flex, FlexProps } from '@chakra-ui/react'; + +interface IconType { + size?: string | number | boolean; +} + +interface SidebarItemProps extends FlexProps { + icon: React.ReactElement; + href: string; + children: React.ReactNode; +} + +const SidebarItem: React.FC = function SidebarItem({ icon, href, children }) { + return ( + + + {icon} + {children} + + + ); +}; + +export default SidebarItem; diff --git a/src/pages/components/Sidebar/index.ts b/src/pages/components/Sidebar/index.ts new file mode 100644 index 00000000..006af70c --- /dev/null +++ b/src/pages/components/Sidebar/index.ts @@ -0,0 +1,3 @@ +import Sidebar from './Sidebar'; + +export default Sidebar; diff --git a/src/pages/dashboard.js b/src/pages/dashboard.js deleted file mode 100644 index 60711740..00000000 --- a/src/pages/dashboard.js +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; -import { useTranslation } from 'react-i18next'; -import UserInfo from './components/UserInformation'; -import Navbar from './components/Navbar'; - -const Dashboard = () => { - const { t } = useTranslation('dashboard'); - - return ( -
- -
-
-

{t('Dashboard')}

- -
-
-
- ); -}; - -export default Dashboard; diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx new file mode 100644 index 00000000..d560c29c --- /dev/null +++ b/src/pages/dashboard.tsx @@ -0,0 +1,97 @@ +import React, { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { + Box, + Input, + InputGroup, + InputRightElement, + Text, + useColorModeValue, + Tooltip, + useToast, + useBreakpointValue, +} from '@chakra-ui/react'; +import { ArrowBackIcon, ChevronRightIcon, CopyIcon } from '@chakra-ui/icons'; +import { useRouter } from 'next/router'; +import Sidebar from './components/Sidebar'; + +const Dashboard: React.FC = function Dashboard() { + const { t } = useTranslation('dashboard'); + const router = useRouter(); + const [apiKey, setApiKey] = useState(''); + const toast = useToast(); + const ml = useBreakpointValue({ base: 10, lg: 270 }); + const pageHeaderDisplay = useBreakpointValue({ base: 'block', lg: 'flex' }); + + const handleCopyApiKey = () => { + setApiKey('example-api-key'); + navigator.clipboard.writeText(apiKey); + toast({ + title: t('API key copied'), + description: t('Your API key has been copied to your clipboard.'), + status: 'success', + duration: 5000, + isClosable: true, + }); + }; + + const handleGoBack = () => { + router.back(); + }; + + return ( + + + + + + {t('Back')} + + | + + {t('Dashboard')} {t('App one')} + + + + + {t('Dashboard')} + + + + {/* TODO: Remove hardcoded value */} + + + + + + + + + + + + + {t('Calls')} + + + + 54 + + + + {t('Total daily usage')} + + + + ); +}; + +export default Dashboard; diff --git a/src/public/locales/en/dashboard.json b/src/public/locales/en/dashboard.json new file mode 100644 index 00000000..2ee1577f --- /dev/null +++ b/src/public/locales/en/dashboard.json @@ -0,0 +1,13 @@ +{ + "Dashboard": "Dashboard", + "Back": "Back", + "Total daily usage": "Total daily usage", + "Calls": "Calls", + "Copy API key": "Copy API key", + "API key copied": "API key copied", + "Your API key has been copied to your clipboard.": "Your API key has been copied to your clipboard.", + "Profile": "Profile", + "Settings": "Settings", + "Sign out": "Sign out", + "Menu": "Menu" +} diff --git a/src/public/locales/en/index.js b/src/public/locales/en/index.js index 028e185f..32cc651f 100644 --- a/src/public/locales/en/index.js +++ b/src/public/locales/en/index.js @@ -1,9 +1,11 @@ import about from './about.json'; import common from './common.json'; import signup from './signup.json'; +import dashboard from './dashboard.json'; export default { about, common, signup, + dashboard, }; diff --git a/src/public/locales/ig/dashboard.json b/src/public/locales/ig/dashboard.json new file mode 100644 index 00000000..3e4dc364 --- /dev/null +++ b/src/public/locales/ig/dashboard.json @@ -0,0 +1,13 @@ +{ + "Dashboard": "Mgbonkiri", + "Back": "Azụ", + "Total daily usage": "Ugboro ole ị ga-abịanwu na API kwa ụbọchị", + "Calls": "Oku", + "Copy API key": "Mapịa ọtụchi API", + "API key copied": "A mapịala ọtụchi API", + "Your API key has been copied to your clipboard.": "A mapịala ọtụchi API gị na mgbonta gị", + "Profile": "Agụgụojingwa", + "Settings": "Ndozi", + "Sign out": "Pụọ", + "Menu": "Mgbonhọrọ" +} diff --git a/src/public/locales/ig/index.js b/src/public/locales/ig/index.js index 028e185f..32cc651f 100644 --- a/src/public/locales/ig/index.js +++ b/src/public/locales/ig/index.js @@ -1,9 +1,11 @@ import about from './about.json'; import common from './common.json'; import signup from './signup.json'; +import dashboard from './dashboard.json'; export default { about, common, signup, + dashboard, }; diff --git a/src/shared/constants/Developers.ts b/src/shared/constants/Developers.ts index cb386974..d184a6f1 100644 --- a/src/shared/constants/Developers.ts +++ b/src/shared/constants/Developers.ts @@ -1 +1,4 @@ export const TEST_EMAIL = 'developer@example.com'; +export const DEFAULT_AVATAR = `https://images.unsplash.com/photo-1619946794135-5bc917a + 27793?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&fit=crop&h=200&w=200&s=b616b2c5b373a80ffc9636ba24f7a4a9`; +export const LOGO_URL = 'https://igbo-api.s3.us-east-2.amazonaws.com/images/igboAPI.svg';