116 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			116 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import React, { useState } from "react";
 | |
| import { useSelector } from "react-redux";
 | |
| import { NavLink } from "react-router-dom";
 | |
| 
 | |
| import { getProfileInfo } from "@redux/outstaffingSlice";
 | |
| 
 | |
| import { urlForLocal } from "@utils/helper";
 | |
| 
 | |
| import avatarMok from "assets/images/avatarMok.png";
 | |
| 
 | |
| export const Navigation = () => {
 | |
|   const profileInfo = useSelector(getProfileInfo);
 | |
|   const currentPath = window.location.pathname;
 | |
|   const [user] = useState(
 | |
|     localStorage.getItem("role_status") === "18" ? "partner" : "developer"
 | |
|   );
 | |
| 
 | |
|   const [navInfo] = useState({
 | |
|     developer: [
 | |
|       {
 | |
|         path: "/summary",
 | |
|         name: "Резюме"
 | |
|       },
 | |
|       {
 | |
|         path: "/calendar",
 | |
|         name: "Отчеты"
 | |
|       },
 | |
|       {
 | |
|         path: "/tracker",
 | |
|         name: "Трекер"
 | |
|       },
 | |
|       // {
 | |
|       //   path: "/payouts",
 | |
|       //   name: "Выплаты"
 | |
|       // },
 | |
|       {
 | |
|         path: "/quiz",
 | |
|         name: "Тесты"
 | |
|       },
 | |
|       {
 | |
|         path: "/settings",
 | |
|         name: "Настройки"
 | |
|       }
 | |
|     ],
 | |
|     partner: [
 | |
|       {
 | |
|         path: "/catalog",
 | |
|         active: "candidate",
 | |
|         name: "Каталог"
 | |
|       },
 | |
|       {
 | |
|         path: "/requests",
 | |
|         name: "Запросы"
 | |
|       },
 | |
|       {
 | |
|         path: "/employees",
 | |
|         active: "calendar",
 | |
|         name: "Персонал"
 | |
|       },
 | |
|       {
 | |
|         path: "/tracker",
 | |
|         name: "Трекер"
 | |
|       },
 | |
|       // {
 | |
|       //   path: "/treaties",
 | |
|       //   name: "Договоры"
 | |
|       // },
 | |
|       {
 | |
|         path: "/settings",
 | |
|         name: "Настройки"
 | |
|       }
 | |
|     ]
 | |
|   });
 | |
| 
 | |
|   return (
 | |
|     <div className="profile-header__info">
 | |
|       <div className="profile-header__container">
 | |
|         <nav className="profile-header__nav">
 | |
|           {navInfo[user].map((link, index) => {
 | |
|             return (
 | |
|               <NavLink
 | |
|                 key={index}
 | |
|                 end
 | |
|                 to={link.path === "/Quiz" ? link.path : `/profile${link.path}`}
 | |
|                 className={
 | |
|                   currentPath.includes(link.path) ||
 | |
|                   currentPath.includes(link.active)
 | |
|                     ? "active"
 | |
|                     : ""
 | |
|                 }
 | |
|               >
 | |
|                 {link.name}
 | |
|               </NavLink>
 | |
|             );
 | |
|           })}
 | |
|         </nav>
 | |
| 
 | |
|         <div className="profile-header__personal-info">
 | |
|           <h3 className="profile-header__personal-info-name">
 | |
|             {profileInfo?.fio || profileInfo?.username}
 | |
|           </h3>
 | |
|           <NavLink end to={"/profile"}>
 | |
|             <img
 | |
|               src={
 | |
|                 profileInfo?.photo ? urlForLocal(profileInfo.photo) : avatarMok
 | |
|               }
 | |
|               className="profile-header__personal-info-avatar"
 | |
|               alt="avatar"
 | |
|             />
 | |
|           </NavLink>
 | |
|         </div>
 | |
|       </div>
 | |
|     </div>
 | |
|   );
 | |
| };
 | 
