Skip to content

Commit

Permalink
Merge pull request #148 from dvishal485/main
Browse files Browse the repository at this point in the history
stuff
  • Loading branch information
dvishal485 authored May 21, 2024
2 parents 6a58a06 + 5cf3c9e commit 88f5373
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 31 deletions.
18 changes: 0 additions & 18 deletions src/assets/ChevronUpIcon.tsx

This file was deleted.

11 changes: 5 additions & 6 deletions src/components/SideNavigation/sideNavItems.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import DownArrow from "@/assets/ChevronDownIcon";
import UpArrow from "@/assets/ChevronUpIcon";
import { PermissionProtector } from "@/components/PermissionProtector";
import RouteElement from "@/types/routeElement";
import { useEffect, useState } from "react";
Expand Down Expand Up @@ -44,10 +43,10 @@ function SidebarItem({
return null;
}

if (items.children) {
if (items.submenu) {
return (
<PermissionProtector permission={items.permission} fallback={true}>
<div className="flex flex-col">
<div className="flex flex-col w-min">
<div
className={`flex items-center justify-between text-white p-2 cursor-pointer w-[220px] h-[45px] ${isSidebarOpen ? "hover:bg-gray-500 hover:rounded transition-all duration-600" : "w-[45px] transition-all duration-600"}`}
onClick={menu_open}
Expand All @@ -68,12 +67,12 @@ function SidebarItem({
<div
className={`ml-3 ${isSidebarOpen ? "transition-all duration-600" : "hidden transition-all duration-600"}`}
>
{is_expanded ? <UpArrow /> : <DownArrow />}
<DownArrow className={is_expanded ? "rotate-180" : ""} />
</div>
</div>
{isSidebarOpen && is_expanded ? (
<div className="pl-4">
{items.children.map((item, index) => (
{items.submenu.map((item, index) => (
<PermissionProtector
key={`nested-${item.label}.${index}`}
permission={item.permission}
Expand Down Expand Up @@ -112,7 +111,7 @@ function SidebarItem({
to={items.path}
>
<div
className={`flex items-center w-[220px] h-[45px] p-2 cursor-pointer ${isSidebarOpen ? "hover:bg-gray-500 hover:rounded transition-all duration-600" : "w-[45px] transition-all duration-600"}`}
className={`flex items-center h-[45px] p-2 cursor-pointer ${isSidebarOpen ? "w-[220px] hover:bg-gray-500 hover:rounded transition-all duration-600" : "w-[45px] transition-all duration-600"}`}
>
<span
className={`${isSidebarOpen ? "transition-all duration-800 " : "scale-[1.5] transition-all duration-800 hover:bg-gray-500 hover:rounded w-[40px] h-[30px] flex justify-center items-center"}`}
Expand Down
12 changes: 6 additions & 6 deletions src/router/routeMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const routeMap: CustomRouteElement[] = [
label: "Story",
icon: <StoryIcon />,
permission: [Permission.ReadBlog],
children: [
submenu: [
{
path: "new-story/",
element: <NewStory />,
Expand Down Expand Up @@ -117,7 +117,7 @@ const routeMap: CustomRouteElement[] = [
<Outlet />
</>
),
children: [
submenu: [
{
path: "new-edition/",
element: <NewEdition key="new-edition" />,
Expand Down Expand Up @@ -149,7 +149,7 @@ const routeMap: CustomRouteElement[] = [
<Outlet />
</>
),
children: [
submenu: [
{
path: "all-roles/",
element: <AllRoles />,
Expand Down Expand Up @@ -180,7 +180,7 @@ const routeMap: CustomRouteElement[] = [
permission: [],
label: "Member",
icon: <MemberIcon />,
children: [
submenu: [
{
path: "all-members/",
element: <AllMembers />,
Expand Down Expand Up @@ -240,8 +240,8 @@ const routeMap: CustomRouteElement[] = [

const make_protected = (routes: CustomRouteElement[]) => {
return routes.map((route) => {
if (route.children) {
route.children = make_protected(route.children);
if (route.submenu) {
route.children = make_protected(route.submenu);
} else {
route.element = (
<PermissionProtector permission={route.permission}>
Expand Down
2 changes: 1 addition & 1 deletion src/types/routeElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface RouteElement extends NonIndexRouteObject {
label: string;
icon?: React.SVGProps<SVGSVGElement>;
hide?: true;
children?: RouteElement[];
submenu?: RouteElement[];
}

export default RouteElement;

0 comments on commit 88f5373

Please sign in to comment.