From ca8148323348f803f1cf7a843a798359796e61cc Mon Sep 17 00:00:00 2001 From: pdovhomilja <41537049+pdovhomilja@users.noreply.github.com> Date: Fri, 27 Oct 2023 16:12:05 +0200 Subject: [PATCH] Update - Menu - active menu highlighted --- .../(routes)/admin/_components/GptCard.tsx | 16 ++--- .../(routes)/components/ModuleMenu.tsx | 54 +++++--------- .../components/menu-items/Administration.tsx | 25 +++++++ .../components/menu-items/ChatGPT.tsx | 27 +++---- .../(routes)/components/menu-items/Crm.tsx | 10 ++- .../components/menu-items/Dashboard.tsx | 27 +++++++ .../components/menu-items/Databoxes.tsx | 27 +++---- .../components/menu-items/Documents.tsx | 26 +++---- .../components/menu-items/Employees.tsx | 8 ++- .../components/menu-items/Invoices.tsx | 19 +++-- .../components/menu-items/Projects.tsx | 19 +++-- .../components/menu-items/Reports.tsx | 29 +++----- .../components/menu-items/SecondBrain.tsx | 9 ++- .../(routes)/components/ui/MenuItem.tsx | 72 ------------------- app/[locale]/(routes)/devmode/page.tsx | 6 +- .../(routes)/projects/dialogs/NewProject.tsx | 6 +- .../(routes)/projects/dialogs/NewTask.tsx | 2 +- 17 files changed, 158 insertions(+), 224 deletions(-) create mode 100644 app/[locale]/(routes)/components/menu-items/Administration.tsx create mode 100644 app/[locale]/(routes)/components/menu-items/Dashboard.tsx delete mode 100644 app/[locale]/(routes)/components/ui/MenuItem.tsx diff --git a/app/[locale]/(routes)/admin/_components/GptCard.tsx b/app/[locale]/(routes)/admin/_components/GptCard.tsx index 9f8d8bf..c4d5271 100644 --- a/app/[locale]/(routes)/admin/_components/GptCard.tsx +++ b/app/[locale]/(routes)/admin/_components/GptCard.tsx @@ -20,15 +20,13 @@ const GptCard = async () => { AI assistant GPT model -
- actual model:{" "} - { - //filter in gptModels where status = ACTIVE - gptModels - .filter((model) => model.status === "ACTIVE") - .map((model) => model.model) - } -
+ actual model:{" "} + { + //filter in gptModels where status = ACTIVE + gptModels + .filter((model) => model.status === "ACTIVE") + .map((model) => model.model) + }
diff --git a/app/[locale]/(routes)/components/ModuleMenu.tsx b/app/[locale]/(routes)/components/ModuleMenu.tsx index 330df79..75d648e 100644 --- a/app/[locale]/(routes)/components/ModuleMenu.tsx +++ b/app/[locale]/(routes)/components/ModuleMenu.tsx @@ -1,7 +1,6 @@ "use client"; -import React, { useState } from "react"; -import MenuItem from "./ui/MenuItem"; +import React, { useEffect, useState } from "react"; import ProjectModuleMenu from "./menu-items/Projects"; import SecondBrainModuleMenu from "./menu-items/SecondBrain"; @@ -13,12 +12,24 @@ import EmployeesModuleMenu from "./menu-items/Employees"; import DataboxModuleMenu from "./menu-items/Databoxes"; import CrmModuleMenu from "./menu-items/Crm"; +import AdministrationMenu from "./menu-items/Administration"; +import DashboardMenu from "./menu-items/Dashboard"; + type Props = { modules: any; }; const ModuleMenu = ({ modules }: Props) => { const [open, setOpen] = useState(true); + const [isMounted, setIsMounted] = useState(false); + + useEffect(() => { + setIsMounted(true); + }, []); + + if (!isMounted) { + return null; + } //Console logs //console.log(modules, "modules"); @@ -28,7 +39,7 @@ const ModuleMenu = ({ modules }: Props) => {
{ {process.env.NEXT_PUBLIC_APP_NAME}
-
    - +
    + {modules.find( (menuItem: any) => menuItem.name === "crm" && menuItem.enabled ) ? ( @@ -101,32 +107,8 @@ const ModuleMenu = ({ modules }: Props) => { ) ? ( ) : null} - - {/* {modules.map((menuItem: any) => { - if (menuItem.enabled === true) { - return ( - - ); - } else { - return null; - } - })} */} -
  • - {/* Admin menu item is allways enabled */} - -
  • -
+ +
); diff --git a/app/[locale]/(routes)/components/menu-items/Administration.tsx b/app/[locale]/(routes)/components/menu-items/Administration.tsx new file mode 100644 index 0000000..fbe8cfe --- /dev/null +++ b/app/[locale]/(routes)/components/menu-items/Administration.tsx @@ -0,0 +1,25 @@ +import { Wrench } from "lucide-react"; +import Link from "next/link"; +import { usePathname } from "next/navigation"; + +type Props = { + open: boolean; +}; + +const AdministrationMenu = ({ open }: Props) => { + const pathname = usePathname(); + const isPath = pathname.includes("admin"); + return ( +
+ + + Administration + +
+ ); +}; + +export default AdministrationMenu; diff --git a/app/[locale]/(routes)/components/menu-items/ChatGPT.tsx b/app/[locale]/(routes)/components/menu-items/ChatGPT.tsx index 62e09d0..f3e0135 100644 --- a/app/[locale]/(routes)/components/menu-items/ChatGPT.tsx +++ b/app/[locale]/(routes)/components/menu-items/ChatGPT.tsx @@ -1,23 +1,9 @@ "use client"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuSeparator, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { - Bot, - FileBarChart, - FileCheck, - FileText, - Lightbulb, - ServerIcon, - UserIcon, -} from "lucide-react"; + +import { Bot } from "lucide-react"; import Link from "next/link"; +import { usePathname } from "next/navigation"; -import { useRouter } from "next/navigation"; import React from "react"; type Props = { @@ -25,9 +11,14 @@ type Props = { }; const ChatGPTModuleMenu = ({ open }: Props) => { + const pathname = usePathname(); + const isPath = pathname.includes("openAi"); return (
- + ChatGPT diff --git a/app/[locale]/(routes)/components/menu-items/Crm.tsx b/app/[locale]/(routes)/components/menu-items/Crm.tsx index e5d05ec..4246366 100644 --- a/app/[locale]/(routes)/components/menu-items/Crm.tsx +++ b/app/[locale]/(routes)/components/menu-items/Crm.tsx @@ -6,7 +6,7 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; -import { Coins, UserIcon } from "lucide-react"; +import { Coins } from "lucide-react"; import { useRouter } from "next/navigation"; import React, { startTransition } from "react"; @@ -33,8 +33,14 @@ const CrmModuleMenu = ({ open }: Props) => { }); } + const isPath = pathname.includes("crm"); + return ( -
+
{ + const pathname = usePathname(); + const isPath = pathname.includes("nevermind"); + return ( +
+ + + Dashboard + +
+ ); +}; + +export default DashboardMenu; diff --git a/app/[locale]/(routes)/components/menu-items/Databoxes.tsx b/app/[locale]/(routes)/components/menu-items/Databoxes.tsx index 2abc64c..ffadd51 100644 --- a/app/[locale]/(routes)/components/menu-items/Databoxes.tsx +++ b/app/[locale]/(routes)/components/menu-items/Databoxes.tsx @@ -1,24 +1,8 @@ "use client"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuSeparator, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { - Bot, - FileBarChart, - FileCheck, - FileEdit, - FileText, - Lightbulb, - ServerIcon, - UserIcon, -} from "lucide-react"; +import { FileEdit } from "lucide-react"; import Link from "next/link"; -import { useRouter } from "next/navigation"; +import { usePathname } from "next/navigation"; import React from "react"; type Props = { @@ -26,9 +10,14 @@ type Props = { }; const DataboxModuleMenu = ({ open }: Props) => { + const pathname = usePathname(); + const isPath = pathname.includes("databox"); return (
- + Databox diff --git a/app/[locale]/(routes)/components/menu-items/Documents.tsx b/app/[locale]/(routes)/components/menu-items/Documents.tsx index 66d9ce9..eeaf365 100644 --- a/app/[locale]/(routes)/components/menu-items/Documents.tsx +++ b/app/[locale]/(routes)/components/menu-items/Documents.tsx @@ -1,22 +1,7 @@ -"use client"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuSeparator, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { - FileBarChart, - FileCheck, - FileText, - Lightbulb, - ServerIcon, - UserIcon, -} from "lucide-react"; +import { FileText } from "lucide-react"; import Link from "next/link"; -import { useRouter } from "next/navigation"; +import { usePathname } from "next/navigation"; import React from "react"; type Props = { @@ -24,9 +9,14 @@ type Props = { }; const DocumentsModuleMenu = ({ open }: Props) => { + const pathname = usePathname(); + const isPath = pathname.includes("documents"); return (
- + Documents diff --git a/app/[locale]/(routes)/components/menu-items/Employees.tsx b/app/[locale]/(routes)/components/menu-items/Employees.tsx index 9c5b4bc..7c27848 100644 --- a/app/[locale]/(routes)/components/menu-items/Employees.tsx +++ b/app/[locale]/(routes)/components/menu-items/Employees.tsx @@ -1,5 +1,6 @@ import { Users } from "lucide-react"; import Link from "next/link"; +import { usePathname } from "next/navigation"; import React from "react"; @@ -8,9 +9,14 @@ type Props = { }; const EmployeesModuleMenu = ({ open }: Props) => { + const pathname = usePathname(); + const isPath = pathname.includes("employees"); return (
- + Employees diff --git a/app/[locale]/(routes)/components/menu-items/Invoices.tsx b/app/[locale]/(routes)/components/menu-items/Invoices.tsx index d793c73..f511821 100644 --- a/app/[locale]/(routes)/components/menu-items/Invoices.tsx +++ b/app/[locale]/(routes)/components/menu-items/Invoices.tsx @@ -1,15 +1,7 @@ -"use client"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuSeparator, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { FileCheck, Lightbulb, ServerIcon, UserIcon } from "lucide-react"; +import { FileCheck } from "lucide-react"; import Link from "next/link"; -import { useRouter } from "next/navigation"; +import { usePathname } from "next/navigation"; import React from "react"; type Props = { @@ -17,9 +9,14 @@ type Props = { }; const InvoicesModuleMenu = ({ open }: Props) => { + const pathname = usePathname(); + const isPath = pathname.includes("invoice"); return (
- + Invoices diff --git a/app/[locale]/(routes)/components/menu-items/Projects.tsx b/app/[locale]/(routes)/components/menu-items/Projects.tsx index c27a940..6379851 100644 --- a/app/[locale]/(routes)/components/menu-items/Projects.tsx +++ b/app/[locale]/(routes)/components/menu-items/Projects.tsx @@ -1,15 +1,7 @@ -"use client"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuSeparator, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { ServerIcon, UserIcon } from "lucide-react"; +import { ServerIcon } from "lucide-react"; import Link from "next/link"; -import { useRouter } from "next/navigation"; +import { usePathname } from "next/navigation"; import React from "react"; type Props = { @@ -17,9 +9,14 @@ type Props = { }; const ProjectModuleMenu = ({ open }: Props) => { + const pathname = usePathname(); + const isPath = pathname.includes("projects"); return (
- + Projects diff --git a/app/[locale]/(routes)/components/menu-items/Reports.tsx b/app/[locale]/(routes)/components/menu-items/Reports.tsx index 6f02581..a1d26b6 100644 --- a/app/[locale]/(routes)/components/menu-items/Reports.tsx +++ b/app/[locale]/(routes)/components/menu-items/Reports.tsx @@ -1,21 +1,7 @@ -"use client"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuSeparator, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { - FileBarChart, - FileCheck, - Lightbulb, - ServerIcon, - UserIcon, -} from "lucide-react"; +import { FileBarChart } from "lucide-react"; import Link from "next/link"; -import { useRouter } from "next/navigation"; +import { usePathname } from "next/navigation"; import React from "react"; type Props = { @@ -23,10 +9,15 @@ type Props = { }; const ReportsModuleMenu = ({ open }: Props) => { + const pathname = usePathname(); + const isPath = pathname.includes("reports"); return ( -
- - +
+ + Reports
diff --git a/app/[locale]/(routes)/components/menu-items/SecondBrain.tsx b/app/[locale]/(routes)/components/menu-items/SecondBrain.tsx index e88b5d2..f5f40ae 100644 --- a/app/[locale]/(routes)/components/menu-items/SecondBrain.tsx +++ b/app/[locale]/(routes)/components/menu-items/SecondBrain.tsx @@ -9,7 +9,7 @@ import { import { Lightbulb, ServerIcon, UserIcon } from "lucide-react"; import Link from "next/link"; -import { useRouter } from "next/navigation"; +import { usePathname, useRouter } from "next/navigation"; import React from "react"; type Props = { @@ -17,9 +17,14 @@ type Props = { }; const SecondBrainModuleMenu = ({ open }: Props) => { + const pathname = usePathname(); + const isPath = pathname.includes("secondBrain"); return (
- + Second brain diff --git a/app/[locale]/(routes)/components/ui/MenuItem.tsx b/app/[locale]/(routes)/components/ui/MenuItem.tsx deleted file mode 100644 index 8f7293f..0000000 --- a/app/[locale]/(routes)/components/ui/MenuItem.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import { Inbox, WrenchIcon } from "lucide-react"; -import { - ClipboardEditIcon, - FileBarChart, - FileCheckIcon, - FileTextIcon, - GraduationCapIcon, - Home, - LightbulbIcon, - Server, - Users, - UsersIcon, -} from "lucide-react"; -import Link from "next/link"; - -function MenuItem({ open, icon, route, menuItem }: any) { - let showIcon; - switch (icon) { - case "home": - showIcon = ; - break; - case "userGroup": - showIcon = ; - break; - case "user": - showIcon = ; - break; - case "server": - showIcon = ; - break; - case "document": - showIcon = ; - break; - case "documentChart": - showIcon = ; - break; - case "lightBulb": - showIcon = ; - break; - case "documentCheck": - showIcon = ; - break; - case "clipBoardDocument": - showIcon = ; - break; - case "academicCap": - showIcon = ; - break; - case "wrenchScrewdriver": - showIcon = ; - break; - case "inboxIcon": - showIcon = ; - break; - default: - ; - } - - return ( - -
-
{showIcon}
- {open &&
{menuItem}
} -
- - ); -} - -export default MenuItem; diff --git a/app/[locale]/(routes)/devmode/page.tsx b/app/[locale]/(routes)/devmode/page.tsx index 7ad2e8f..be78373 100644 --- a/app/[locale]/(routes)/devmode/page.tsx +++ b/app/[locale]/(routes)/devmode/page.tsx @@ -1,9 +1,13 @@ +/* + This route is used to test the different components of the app. +*/ + import MultiSelect from "@/shadcn-examples/MultiSelect"; import React from "react"; const DevModePage = () => { return ( -
+
); diff --git a/app/[locale]/(routes)/projects/dialogs/NewProject.tsx b/app/[locale]/(routes)/projects/dialogs/NewProject.tsx index b3e0d04..71a3d3b 100644 --- a/app/[locale]/(routes)/projects/dialogs/NewProject.tsx +++ b/app/[locale]/(routes)/projects/dialogs/NewProject.tsx @@ -37,9 +37,7 @@ import React, { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { z } from "zod"; -type Props = {}; - -const NewProjectDialog = (props: Props) => { +const NewProjectDialog = () => { const [open, setOpen] = useState(false); const [isLoading, setIsLoading] = useState(false); @@ -94,7 +92,7 @@ const NewProjectDialog = (props: Props) => { return ( - + diff --git a/app/[locale]/(routes)/projects/dialogs/NewTask.tsx b/app/[locale]/(routes)/projects/dialogs/NewTask.tsx index 05d13e0..eece32b 100644 --- a/app/[locale]/(routes)/projects/dialogs/NewTask.tsx +++ b/app/[locale]/(routes)/projects/dialogs/NewTask.tsx @@ -115,7 +115,7 @@ const NewTaskDialog = ({ users, boards }: Props) => { return ( - +