diff --git a/src/components/Menu.tsx b/src/components/Menu.tsx index b6fd9cd..48a63d8 100644 --- a/src/components/Menu.tsx +++ b/src/components/Menu.tsx @@ -14,7 +14,6 @@ export default function Menu() { const location = useLocation(); const color = location.pathname === "/" ? "white" : "black"; - console.log(location) const arrayMenu: MenuItem[] = [ { @@ -42,49 +41,50 @@ export default function Menu() { overflow: "hidden", }} > - {location.pathname !== "/" ? arrayMenu.map(({ name, url, subMenu = [] }) => ( - setActiveSubMenu(subMenu)} - > - - {name} - - - )) - :arrayMenu.map(({ name, url, subMenu = [] }) => ( - - {name} - - )) - } + {location.pathname !== "/" + ? arrayMenu.map(({ name, url, subMenu = [] }) => ( + setActiveSubMenu(subMenu)} + state={{ previousUrl: location.pathname }} + > + + {name} + + + )) + : arrayMenu.map(({ name, url, subMenu = [] }) => ( + + {name} + + ))} setActiveSubMenu([])} > - {location.pathname !== "/" && activeSubMenu.map(({ name, url }) => ( - - - {name} - - - ))} + {location.pathname !== "/" && + activeSubMenu.map(({ name, url }) => ( + + + {name} + + + ))} ); diff --git a/src/components/Navbar/DialogMenu.tsx b/src/components/Navbar/DialogMenu.tsx index 007add9..4d69d83 100644 --- a/src/components/Navbar/DialogMenu.tsx +++ b/src/components/Navbar/DialogMenu.tsx @@ -85,7 +85,7 @@ export default function DialogMenu({ handleClose }: DialogMenuProps) { key={index} component={Link} to={url} - state={user ? undefined : { backgroundLocation: location }} + state={{ previousUrl: location.pathname }} disableRipple variant="text" onClick={() => @@ -134,6 +134,7 @@ export default function DialogMenu({ handleClose }: DialogMenuProps) { }} to={url} onClick={closeDialogMenu} + state={{ previousUrl: location.pathname }} > (""); const theme = useTheme(); const upMd = useMediaQuery(theme.breakpoints.up("md")); const ticketId = useParams().ticketId; const ticketApiPage = useTicketStore((state) => state.apiPage); const ticketsPerPage = useTicketStore((state) => state.ticketsPerPage); const token = useToken(); + const location = useLocation(); const fetchState = useTickets({ url: "https://hub.pena.digital/heruvym/getTickets", @@ -44,6 +46,10 @@ export default function Support() { }, []), }); + useEffect(() => { + setPreviousPage(location.state?.previousUrl || "/"); + }, []); + useSSESubscription({ enabled: Boolean(token), url: `https://admin.pena.digital/heruvym/subscribe?Authorization=${token}`, @@ -73,7 +79,7 @@ export default function Support() { }} >