Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. import React, { useState, useMemo, useRef, useEffect } from "react";
  2. import {
  3. AppBar,
  4. // Badge,
  5. Box,
  6. IconButton,
  7. Toolbar,
  8. Typography,
  9. List,
  10. // ListItem,
  11. ListItemButton,
  12. ListItemIcon,
  13. ListItemText,
  14. useMediaQuery,
  15. Button,
  16. } from "@mui/material";
  17. import HrLogo from "../../assets/images/HR.png";
  18. // import x from "../../assets/images/x.png";
  19. import avatarLogo from "../../assets/images/Avatar.png";
  20. import searchIcon from "../../assets/images/Vector.png";
  21. import { useTheme } from "@mui/system";
  22. import MenuOutlinedIcon from "@mui/icons-material/MenuOutlined";
  23. // import ShoppingBasketIcon from "@mui/icons-material/ShoppingBasket";
  24. // import Brightness4Icon from "@mui/icons-material/Brightness4";
  25. // import Brightness7Icon from "@mui/icons-material/Brightness7";
  26. // import MenuList from "./MenuListComponent";
  27. import Drawer from "./DrawerComponent";
  28. // import { ColorModeContext } from "../../context/ColorModeContext";
  29. import { useTranslation } from "react-i18next";
  30. import CloseIcon from "@mui/icons-material/Close";
  31. import LogoutIcon from "@mui/icons-material/Logout";
  32. import UserProfile from "../Profile/UserProfile";
  33. import { useSelector } from "react-redux";
  34. //import { userSelector } from "../../store/selectors/userSelectors";
  35. import { Link, useLocation } from "react-router-dom";
  36. const NavbarComponent = () => {
  37. const navItems = [
  38. "jobs",
  39. "selectionFlow",
  40. "candidates",
  41. "schedule",
  42. "patterns",
  43. "statistics",
  44. "users",
  45. // "signOut"
  46. ];
  47. const { pathname } = useLocation();
  48. const [openDrawer, setOpenDrawer] = useState(false);
  49. const [preview, setPreview] = useState(false);
  50. const theme = useTheme();
  51. const matches = useMediaQuery(theme.breakpoints.down("sm"));
  52. // const toggleColorMode = useContext(ColorModeContext);
  53. let userRef = useRef();
  54. let btnRef = useRef();
  55. // get authenticated user
  56. const { user } = useSelector((s) => s.user);
  57. const { t } = useTranslation();
  58. const handleToggleDrawer = () => {
  59. setOpenDrawer(!openDrawer);
  60. };
  61. const userPreviewHandler = () => {
  62. setPreview(!preview);
  63. };
  64. useEffect(() => {
  65. let handler = (e) => {
  66. if (userRef.current) {
  67. if (
  68. !userRef.current.contains(e.target) &&
  69. !btnRef.current.contains(e.target)
  70. ) {
  71. setPreview(false);
  72. }
  73. }
  74. };
  75. document.addEventListener("mousedown", handler, { capture: true });
  76. return () => {
  77. document.removeEventListener("mousedown", handler, { capture: true });
  78. };
  79. }, []);
  80. const drawerContent = useMemo(
  81. () => (
  82. <div style={{ width: "100vw", padding: "36px" }}>
  83. <div
  84. className="flex-center"
  85. style={{ justifyContent: "space-between", marginBottom: "20px" }}
  86. >
  87. <Typography
  88. sx={{ fontWeight: 600, fontSize: "18px", letterSpacing: "1.5px" }}
  89. >
  90. {t("nav.navigation")}
  91. </Typography>
  92. {/* <img src={x}/> */}
  93. <IconButton onClick={handleToggleDrawer}>
  94. <CloseIcon />
  95. </IconButton>
  96. </div>
  97. <div className="flex-center flex-col">
  98. <img src={avatarLogo} width="64px" height="64px" />
  99. <Typography
  100. variant="h5"
  101. sx={{ fontSize: "18px", marginTop: "15px" }}
  102. className="text-blue"
  103. >
  104. {user.firstName + " " + user.lastName}
  105. </Typography>
  106. <Typography
  107. variant="body1"
  108. sx={{ fontSize: "14px", marginTop: "8px" }}
  109. className="text-grey9d"
  110. >
  111. HR {t("common.specialist")}
  112. </Typography>
  113. <div className="hr" style={{ width: "90%", marginTop: "18px" }}></div>
  114. </div>
  115. <List>
  116. {navItems.map((n) => (
  117. <ListItemButton key={n} onClick={handleToggleDrawer}>
  118. <ListItemIcon>
  119. <ListItemText
  120. variant="body1"
  121. sx={{
  122. // marginRight: "50px",
  123. cursor: "pointer",
  124. textAlign: "left",
  125. lineHeight: "17.6px",
  126. fontWeight: "400",
  127. color: "#353535",
  128. marginY: "0",
  129. padding: "0",
  130. textDecoration: "none",
  131. }}
  132. className="text-black"
  133. as={Link}
  134. to={`/${n}`}
  135. >
  136. {t("nav." + n)}
  137. </ListItemText>
  138. </ListItemIcon>
  139. </ListItemButton>
  140. ))}
  141. {/* <ListItem divider>
  142. <IconButton onClick={toggleColorMode}>
  143. <ListItemText>Toggle {theme.palette.mode} mode</ListItemText>
  144. {theme.palette.mode === "dark" ? (
  145. <Brightness7Icon />
  146. ) : (
  147. <Brightness4Icon />
  148. )}
  149. </IconButton>
  150. </ListItem> */}
  151. </List>
  152. {/* <button style={{width:'90%', margin: 'auto'}} className="flex-center"> */}
  153. {/* <Typography>s</Typography> */}
  154. <div className="flex-center">
  155. <Button
  156. sx={{
  157. padding: "18px 72px",
  158. border: "1px solid #226cb0",
  159. borderRadius: "9px",
  160. background: "white",
  161. width: "90%",
  162. marginTop: "50px",
  163. }}
  164. startIcon={<LogoutIcon />}
  165. >
  166. {t("nav.signOut")}
  167. </Button>
  168. </div>
  169. </div>
  170. ),
  171. [handleToggleDrawer]
  172. );
  173. return (
  174. <AppBar
  175. elevation={0}
  176. sx={{
  177. backgroundColor: "transparent",
  178. position: "relative",
  179. width: "100%",
  180. padding: "0",
  181. }}
  182. >
  183. <Toolbar
  184. sx={{
  185. padding: "0px",
  186. margin: "0px",
  187. width: "100%",
  188. }}
  189. >
  190. <Box
  191. component="div"
  192. sx={{
  193. display: "flex",
  194. justifyContent: "space-between",
  195. alignItems: "center",
  196. width: "100%",
  197. padding: "0px",
  198. margin: "0px",
  199. // md: {paddingX: "72px"}
  200. // paddingX: "72px"
  201. }}
  202. >
  203. <Box
  204. sx={{
  205. display: "flex",
  206. justifyContent: "center",
  207. alignItems: "center",
  208. width: matches ? "100%" : "auto",
  209. }}
  210. >
  211. {matches ? (
  212. <Box
  213. className="responsive-nav-cont"
  214. style={{
  215. display: "flex",
  216. alignItems: "center",
  217. justifyContent: "space-between",
  218. }}
  219. >
  220. <img
  221. style={{ height: "37px", width: "37px", marginLeft: "0px" }}
  222. src={HrLogo}
  223. className="responsive-logo"
  224. />
  225. <div
  226. style={{
  227. display: "flex",
  228. alignItems: "center",
  229. }}
  230. className="icons-cont"
  231. >
  232. <img src={searchIcon} />
  233. <IconButton
  234. sx={{ marginLeft: "27px" }}
  235. onClick={handleToggleDrawer}
  236. >
  237. <MenuOutlinedIcon />
  238. </IconButton>
  239. </div>
  240. </Box>
  241. ) : (
  242. <Box>
  243. {/* <IconButton onClick={handleToggleDrawer}>
  244. <MenuOutlinedIcon />
  245. </IconButton> */}
  246. <img
  247. style={{ height: "37px", width: "37px", marginLeft: "72px" }}
  248. src={HrLogo}
  249. />
  250. </Box>
  251. )}
  252. </Box>
  253. {matches ? (
  254. <Drawer
  255. open={openDrawer}
  256. toggleOpen={handleToggleDrawer}
  257. content={drawerContent}
  258. />
  259. ) : (
  260. <Box
  261. sx={{
  262. display: "flex",
  263. alignItems: "center",
  264. paddingRight: "20px",
  265. justifyContent: "flex-end",
  266. // HEIGHT OF THE NAVBAR IN md & xl SIZE
  267. width: "1076px",
  268. borderBottom: "1px solid #F4F4F4",
  269. boxSizing: "border-box",
  270. }}
  271. className="navLinks-cont"
  272. >
  273. {navItems.map((n) => (
  274. <Typography
  275. variant="body1"
  276. key={n}
  277. sx={{
  278. marginRight: "50px",
  279. cursor: "pointer",
  280. textAlign: "right",
  281. lineHeight: "20.11px",
  282. fontWeight: "400",
  283. // color: "text.primary",
  284. marginY: "0",
  285. padding: "0",
  286. textDecoration: "none",
  287. }}
  288. className={pathname === `/${n}` ? "text-blue" : "text-black"}
  289. as={Link}
  290. to={`/${n}`}
  291. >
  292. {t("nav." + n)}
  293. </Typography>
  294. ))}
  295. <div className="search-Icon">
  296. <img src={searchIcon} />
  297. </div>
  298. <div
  299. onClick={userPreviewHandler}
  300. className="full-rounded user-avatar text-uppercase"
  301. ref={btnRef}
  302. >
  303. {/* user.profilePic ? user.profilePic : */}
  304. {user.firstName[0] + "" + user.lastName[0]}
  305. </div>
  306. </Box>
  307. )}
  308. {!matches && <UserProfile innerRef={userRef} show={preview} />}
  309. {/* <Box>
  310. <MenuList />
  311. </Box> */}
  312. </Box>
  313. </Toolbar>
  314. </AppBar>
  315. );
  316. };
  317. export default NavbarComponent;