|
|
|
import React, { useState } from "react";
|
|
|
|
|
|
|
|
import "./index.scss";
|
|
|
|
|
|
|
|
import downwardArrow from "./arrow-down.svg";
|
|
|
|
import profilePic from "./profile-pic.svg";
|
|
|
|
import home from "./home-2.svg";
|
|
|
|
import square from "./square.svg";
|
|
|
|
import wallet from "./wallet-3.svg";
|
|
|
|
import discount from "./discount-shape.svg";
|
|
|
|
import receipt from "./receipt-text.svg";
|
|
|
|
import profileIcon from "./profilee.svg";
|
|
|
|
import setting from "./setting.svg";
|
|
|
|
import logout from "./logout.svg";
|
|
|
|
import search from "./search-normal.svg";
|
|
|
|
import notification from "./notification.svg";
|
|
|
|
|
|
|
|
import Switch from "../../Switch";
|
|
|
|
|
|
|
|
const SidebarMenu = ({ items, buttons, username, userJob }) => {
|
|
|
|
const [activeDropdown, setActiveDropdown] = useState(null);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<section>
|
|
|
|
<div
|
|
|
|
style={{ width: "20%" }}
|
|
|
|
className="mr-10 bg-white p-5 h-screen shadow-sm border border-gray-300 overflow-y-scroll no-scrollbar relative"
|
|
|
|
>
|
|
|
|
{/* profile */}
|
|
|
|
<div className="flex flex-row items-center">
|
|
|
|
<img src={profilePic} alt="" className="w-12 rounded-full" />
|
|
|
|
<div className="flex flex-col flex-1 mr-3">
|
|
|
|
<p className="text-blue-900 text-sm">{username}</p>
|
|
|
|
<p className="text-blue-700 text-xs">{userJob}</p>
|
|
|
|
</div>
|
|
|
|
<img src={downwardArrow} alt="" className="w-5 cursor-pointer" />
|
|
|
|
</div>
|
|
|
|
{/* search box */}
|
|
|
|
<div className="flex flex-row-reverse items-center relative w-full my-6">
|
|
|
|
<img
|
|
|
|
src={search}
|
|
|
|
alt=""
|
|
|
|
className="w-5 h-5 absolute left-3 cursor-pointer"
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
placeholder="جستجو در منو کاربری..."
|
|
|
|
className="text-xs rounded pr-4 pl-10 py-2 w-full border border-blue-300 focus:outline-none placeholder:text-blue-300"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
{/* items */}
|
|
|
|
{items.map((item, i) => (
|
|
|
|
<div className="flex flex-col item-center" key={i}>
|
|
|
|
<p className="text-xs text-blue-800 my-2">{item.title}</p>
|
|
|
|
{/* menu items */}
|
|
|
|
{item.menuItems.map((menuItem, index) => (
|
|
|
|
<div className="flex flex-col justify-center">
|
|
|
|
<div className="flex flex-row items-center">
|
|
|
|
{/* right active border */}
|
|
|
|
<div
|
|
|
|
style={{}}
|
|
|
|
className={`absolute right-0 w-1 h-8 rounded transition duration-300 ease-linear ${
|
|
|
|
activeDropdown === menuItem ? "bg-blue-600" : ""
|
|
|
|
}`}
|
|
|
|
></div>
|
|
|
|
{/* left content */}
|
|
|
|
<div
|
|
|
|
key={index}
|
|
|
|
className={`flex flex-row flex-1 items-center cursor-pointer hover:bg-blue-100 rounded-md p-2 transition duration-300
|
|
|
|
${activeDropdown === menuItem ? "bg-blue-100" : ""}
|
|
|
|
`}
|
|
|
|
onClick={() => setActiveDropdown(activeDropdown === menuItem ? null : menuItem)}
|
|
|
|
>
|
|
|
|
<img src={menuItem.icon} alt="" className="w-7 h-7" />
|
|
|
|
<p className="text-blue-800 text-sm flex-1 mx-2">
|
|
|
|
{menuItem.title}
|
|
|
|
</p>
|
|
|
|
{menuItem.notification && (
|
|
|
|
<div
|
|
|
|
className={`w-7 h-7 text-center flex flex-col items-center justify-center border-2 ${menuItem.borderRadius} ${menuItem.backgroundColor} ${menuItem.borderColor}`}
|
|
|
|
>
|
|
|
|
<span className=" text-blue-400 text-xs">
|
|
|
|
{menuItem.notification}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{menuItem.leftIcon && (
|
|
|
|
<img
|
|
|
|
src={menuItem.leftIcon}
|
|
|
|
alt=""
|
|
|
|
className={`${
|
|
|
|
activeDropdown === menuItem
|
|
|
|
? "rotate-60 "
|
|
|
|
: "rotate-90"
|
|
|
|
} `}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/* menuSubItems */}
|
|
|
|
{activeDropdown === menuItem &&
|
|
|
|
menuItem.menuSubItems.map((menuSubItem, j) => (
|
|
|
|
<div
|
|
|
|
key={j}
|
|
|
|
className="flex flex-row items-center w-10/12 transition duration-300 ease-linear"
|
|
|
|
style={{
|
|
|
|
transform: "translate(-8%,-10px)",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className=" transition duration-300 ease-linear"
|
|
|
|
style={{
|
|
|
|
borderRight: "1px solid gray",
|
|
|
|
color: "gray",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
-
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
className="flex flex-row items-center justify-between flex-1 hover:bg-indigo-300 p-1 rounded cursor-pointer transition duration-300 ease-linear"
|
|
|
|
onClick={() => setActiveDropdown(menuSubItem)}
|
|
|
|
>
|
|
|
|
<p className="text-xs transition duration-300">
|
|
|
|
{menuSubItem.title}
|
|
|
|
</p>
|
|
|
|
<img
|
|
|
|
src={menuSubItem.leftIcon}
|
|
|
|
alt=""
|
|
|
|
className={`w-4 cursor-pointer transition duration-300 ${
|
|
|
|
activeDropdown === menuSubItem
|
|
|
|
? "rotate-60"
|
|
|
|
: "rotate-90"
|
|
|
|
}`}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
<div className="border border-gray-100 my-2"></div>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
{/* blue left border */}
|
|
|
|
<div
|
|
|
|
style={{ bottom: "15%" }}
|
|
|
|
className="absolute left-0.5 transform -translate-x-1/2 -translate-y-1/2 bg-blue-600 w-1 h-20 rounded"
|
|
|
|
></div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SidebarMenu;
|
|
|
|
|
|
|
|
SidebarMenu.defaultProps = {
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
title: "منوی کاربری برای شما",
|
|
|
|
menuItems: [
|
|
|
|
{
|
|
|
|
icon: home,
|
|
|
|
title: "صفحه اصلی",
|
|
|
|
borderRadius: "rounded",
|
|
|
|
backgroundColor: "bg-gray-200",
|
|
|
|
borderColor: "border-gray-200",
|
|
|
|
notification: "8+",
|
|
|
|
menuSubItems: [],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: square,
|
|
|
|
title: "داشبود من",
|
|
|
|
borderRadius: null,
|
|
|
|
backgroundColor: null,
|
|
|
|
borderColor: null,
|
|
|
|
notification: null,
|
|
|
|
menuSubItems: [],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: notification,
|
|
|
|
title: "مرکز اعلانات",
|
|
|
|
borderRadius: "rounded-full",
|
|
|
|
backgroundColor: "bg-transparent",
|
|
|
|
borderColor: "border-gray-200",
|
|
|
|
notification: "+8",
|
|
|
|
menuSubItems: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "حسابداری و مالی",
|
|
|
|
menuItems: [
|
|
|
|
{
|
|
|
|
icon: wallet,
|
|
|
|
title: "کیف پول",
|
|
|
|
borderRadius: null,
|
|
|
|
backgroundColor: null,
|
|
|
|
borderColor: null,
|
|
|
|
notification: null,
|
|
|
|
leftIcon: downwardArrow,
|
|
|
|
menuSubItems: [
|
|
|
|
{ title: "کوپن ها", leftIcon: downwardArrow },
|
|
|
|
{ title: "رسید ها", leftIcon: downwardArrow },
|
|
|
|
{ title: "صندوق", leftIcon: downwardArrow },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: discount,
|
|
|
|
title: "کوپن ها",
|
|
|
|
borderRadius: "rounded-full",
|
|
|
|
backgroundColor: "bg-transparent",
|
|
|
|
borderColor: "border-gray-200",
|
|
|
|
notification: "+",
|
|
|
|
menuSubItems: [],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: receipt,
|
|
|
|
title: "رسید ها",
|
|
|
|
borderRadius: null,
|
|
|
|
backgroundColor: null,
|
|
|
|
borderColor: null,
|
|
|
|
notification: null,
|
|
|
|
menuSubItems: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "حساب کاربری",
|
|
|
|
menuItems: [
|
|
|
|
{
|
|
|
|
icon: profileIcon,
|
|
|
|
title: "حساب کاربری",
|
|
|
|
borderRadius: null,
|
|
|
|
backgroundColor: null,
|
|
|
|
borderColor: null,
|
|
|
|
notification: null,
|
|
|
|
menuSubItems: [],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: setting,
|
|
|
|
title: "تنظیمات",
|
|
|
|
borderRadius: null,
|
|
|
|
backgroundColor: null,
|
|
|
|
borderColor: null,
|
|
|
|
notification: null,
|
|
|
|
menuSubItems: [],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: logout,
|
|
|
|
title: "خروج از حساب کاربری",
|
|
|
|
borderRadius: null,
|
|
|
|
backgroundColor: null,
|
|
|
|
borderColor: null,
|
|
|
|
notification: null,
|
|
|
|
menuSubItems: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
username: "رستم پهلوان زاده",
|
|
|
|
userJob: "مدیریت سامانه هوشمند",
|
|
|
|
};
|