Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

DesktopNav.tsx 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import Box from '@mui/material/Box';
  2. import Image from 'next/image';
  3. import Link from 'next/link';
  4. import React from 'react';
  5. import { CART_PAGE, PROFILE_PAGE } from '../../../constants/pages';
  6. import { NavItemDesktop } from './NavItem';
  7. import { items } from './navItems';
  8. interface DesktopNavProps {
  9. router: any;
  10. totalQuantity: number;
  11. session: any;
  12. signOutHandler: () => void;
  13. }
  14. const DesktopNav: React.FC<DesktopNavProps> = ({ router, totalQuantity, session, signOutHandler }) => {
  15. return (
  16. <Box sx={{ display: { xs: 'none', md: 'flex' }, width: '100%' }}>
  17. <Box
  18. sx={{
  19. flexGrow: 1,
  20. maxWidth: '50%',
  21. height: 30,
  22. display: 'flex',
  23. justifyContent: 'center',
  24. }}
  25. >
  26. {items.map((item) => (
  27. <NavItemDesktop
  28. key={item.id}
  29. router={router}
  30. name={item.name}
  31. url={item.url}
  32. />
  33. ))}
  34. </Box>
  35. <Box
  36. sx={{
  37. flexGrow: 1,
  38. maxWidth: '50%',
  39. height: 30,
  40. display: 'flex',
  41. justifyContent: 'right',
  42. pt: 0.5,
  43. mr: 4,
  44. }}
  45. >
  46. {session?.user?._id && (
  47. <Box
  48. sx={{
  49. mx: 2,
  50. mt: 0.1,
  51. cursor: 'pointer',
  52. }}
  53. onClick={signOutHandler}
  54. >
  55. <Image
  56. src="/images/logout.svg"
  57. alt="profile"
  58. width={18}
  59. height={20}
  60. />
  61. </Box>
  62. )}
  63. <Box
  64. sx={{
  65. mx: 2,
  66. cursor: 'pointer',
  67. }}
  68. >
  69. <Link key="home" href={PROFILE_PAGE}>
  70. <a>
  71. <Image
  72. src="/images/profile.svg"
  73. alt="profile"
  74. width={24}
  75. height={24}
  76. />
  77. </a>
  78. </Link>
  79. </Box>
  80. <Box
  81. sx={{
  82. mr: 6,
  83. ml: 2,
  84. cursor: 'pointer',
  85. }}
  86. >
  87. <Link key="home" href={CART_PAGE}>
  88. <a>
  89. <Box>
  90. {totalQuantity !== 0 && (
  91. <Box
  92. sx={{
  93. color: 'white',
  94. zIndex: 3,
  95. width: 20,
  96. height: 20,
  97. borderRadius: 20,
  98. textAlign: 'center',
  99. px: 0.5,
  100. ml: 2.2,
  101. mt: -1,
  102. fontSize: 17,
  103. position: 'absolute',
  104. backgroundColor: 'primary.main',
  105. }}
  106. >
  107. {totalQuantity}
  108. </Box>
  109. )}
  110. <Image
  111. src="/images/cart.svg"
  112. alt="cart"
  113. width={24}
  114. height={24}
  115. />
  116. </Box>
  117. </a>
  118. </Link>
  119. </Box>
  120. </Box>
  121. </Box>
  122. );
  123. };
  124. export default DesktopNav;