Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove menu #32

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 30 additions & 24 deletions components/SideNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ import { useTranslation } from "../lib/TranslationContext"; // Import useTransla
import { useWindowWidth } from "@react-hook/window-size";

import {
ChevronRight,
ChevronLeft,
PanelRightClose,
PanelLeftClose,
LayoutDashboard,
MapIcon,
Route,
Trash2Icon,
Settings,
Settings2,
CornerLeftUp,
MessageSquareReply
} from "lucide-react";


const handleLogout = () => {
window.location.href = '/login'; // Redirect to the login page (where the authToken is cleared)
}

export default function SideNavbar() {
const [isCollapsed, setIsCollapsed] = useState(false);

Expand Down Expand Up @@ -80,17 +86,30 @@ export default function SideNavbar() {

const settingsLinks = [
{
title: t("menu.project"), // Translated text
title: t("menu.project_setting"), // Translated text
href: `/projects/${city}/${type}/settings`,
icon: Settings2,
variant: "ghost" as "default" | "ghost",
},
{
title: t("menu.account"), // Translated text
href: "/settings",
icon: Settings,
variant: "ghost" as "default" | "ghost",
title: t("menu.logout"), // Translated text
icon: MessageSquareReply, // Replace with an appropriate logout icon
href: '/login',
variant: "ghost" as "default" | "ghost",
custom: (
<Button
onClick={handleLogout}
variant="destructive"
className="w-full text-left"
>
{t("menu.logout")}
</Button>
)
//href: "/settings",
//icon: Settings,
//variant: "ghost" as "default" | "ghost",
},

];

return (
Expand All @@ -102,7 +121,7 @@ export default function SideNavbar() {
variant="secondary"
className="rounded-full p-2"
>
{isCollapsed ? <ChevronRight /> : <ChevronLeft />}
{isCollapsed ? <PanelRightClose /> : <PanelLeftClose />}
</Button>
</div>
)}
Expand All @@ -117,15 +136,12 @@ export default function SideNavbar() {
},
]}
/>


<div className="flex flex-col gap-4 flex-grow justify-between h-full pb-6">
<div>
{overviewLinks.length > 0 && (
<div>
{!isCollapsed && !mobileWidth && (
<h2 className="text-lg text-gray-600 font-seibold text-center">
{t("menu.overview")} {/* Translated heading */}
</h2>
)}
<div>
<Nav
isCollapsed={mobileWidth ? true : isCollapsed}
links={overviewLinks}
Expand All @@ -134,11 +150,6 @@ export default function SideNavbar() {
)}
{dataLinks.length > 0 && (
<div>
{!isCollapsed && !mobileWidth && (
<h2 className="text-lg text-gray-600 font-seibold text-center">
{t("menu.data")} {/* Translated heading */}
</h2>
)}
<Nav
isCollapsed={mobileWidth ? true : isCollapsed}
links={dataLinks}
Expand All @@ -150,11 +161,6 @@ export default function SideNavbar() {
<div>
{settingsLinks.length > 0 && (
<div>
{!isCollapsed && !mobileWidth && (
<h2 className="text-lg text-gray-600 font-seibold text-center">
{t("menu.settings")} {/* Translated heading */}
</h2>
)}
<Nav
isCollapsed={mobileWidth ? true : isCollapsed}
links={settingsLinks}
Expand Down
3 changes: 2 additions & 1 deletion lib/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"settings": "Settings",
"trashbins": "Trashbins",
"project": "Project",
"account": "Account",
"project_setting": "Project Settings",
"logout": "Logout",
"location": "Location",
"last_emptied": "Last Emptied",
"battery_level": "Battery Level",
Expand Down