From 7c41aa57bbb8e3e8eaa554973e87c897bd45de33 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sat, 2 Sep 2023 14:57:45 +0200 Subject: [PATCH] Error message as snack bar instead of 404 --- pkgs/ui/src/components/sidebar/index.tsx | 37 +++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/pkgs/ui/src/components/sidebar/index.tsx b/pkgs/ui/src/components/sidebar/index.tsx index 34f662875..a89f59b65 100644 --- a/pkgs/ui/src/components/sidebar/index.tsx +++ b/pkgs/ui/src/components/sidebar/index.tsx @@ -1,4 +1,5 @@ import { + Alert, Divider, Icon, IconButton, @@ -7,6 +8,7 @@ import { ListItemButton, ListItemIcon, ListItemText, + Snackbar, } from "@mui/material"; import Image from "next/image"; import { ReactNode, useState } from "react"; @@ -21,11 +23,13 @@ import Link from "next/link"; import { tw } from "@/utils/tailwind"; import ChevronLeftIcon from "@mui/icons-material/ChevronLeft"; +import React from "react"; type MenuEntry = { icon: ReactNode; label: string; to: string; + missing: boolean; } & { subMenuEntries?: MenuEntry[]; }; @@ -35,31 +39,37 @@ const menuEntries: MenuEntry[] = [ icon: , label: "Dashoard", to: "/", + missing: false, }, { icon: , label: "Machines", to: "/machines", + missing: false, }, { icon: , label: "Applications", to: "/applications", + missing: true, }, { icon: , label: "Network", to: "/network", + missing: true, }, { icon: , label: "Templates", to: "/templates", + missing: false, }, { icon: , label: "Backups", to: "/backups", + missing: true, }, ]; @@ -72,6 +82,23 @@ interface SidebarProps { } export function Sidebar(props: SidebarProps) { const { show, onClose } = props; + + const [open, setOpen] = React.useState(false); + const handleClick = () => { + setOpen(true); + }; + + const handleClose = ( + event?: React.SyntheticEvent | Event, + reason?: string, + ) => { + if (reason === "clickaway") { + return; + } + + setOpen(false); + }; + return (