ApplicationLayout.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import React, {useContext} from 'react';
  2. import {Navbar, Nav} from 'react-bootstrap';
  3. import {Link} from 'found';
  4. import {UserContext} from '../../context/User';
  5. interface Props {
  6. children?: React.ReactNode;
  7. }
  8. function ApplicationLayout({children}: Props): React.ReactElement {
  9. const {user} = useContext(UserContext);
  10. return (
  11. <div>
  12. <nav>
  13. <Navbar expand='md'>
  14. <Link to='/'>
  15. <Navbar.Brand>Pokemon.trade</Navbar.Brand>
  16. </Link>
  17. <Navbar.Toggle aria-controls='basic-navbar-nav' />
  18. <Navbar.Collapse id='basic-navbar-nav'>
  19. <Nav className='mr-auto'>
  20. <Nav.Link as={Link} to='/pokemon'>
  21. View Pokemon
  22. </Nav.Link>
  23. </Nav>
  24. {user && user.email}
  25. </Navbar.Collapse>
  26. </Navbar>
  27. </nav>
  28. {children}
  29. {
  30. user ? (
  31. <p>
  32. <Link to='/logout'>
  33. Logout
  34. </Link>
  35. </p>
  36. ) : (
  37. <>
  38. <p>
  39. <Link to='/login'>Signin</Link>
  40. </p>
  41. <p>
  42. <Link to='/signup'>Signup</Link>
  43. </p>
  44. </>
  45. )
  46. }
  47. <p>
  48. <Link to='/pokemon'>Show me the pokemon!</Link>
  49. </p>
  50. <p>
  51. <Link to='/pokemon/create'>Create a pokemon!</Link>
  52. </p>
  53. </div>
  54. );
  55. }
  56. export default ApplicationLayout;