From 28d912c13822ef9729b46956dd1a8024d0ea4625 Mon Sep 17 00:00:00 2001 From: Alexander Midteide Date: Tue, 26 Nov 2024 12:31:23 +0100 Subject: [PATCH] More work --- .../src/components/Sidebar/useSidebarMenu.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/components/Sidebar/useSidebarMenu.tsx b/packages/frontend/src/components/Sidebar/useSidebarMenu.tsx index 026be809..829b8cad 100644 --- a/packages/frontend/src/components/Sidebar/useSidebarMenu.tsx +++ b/packages/frontend/src/components/Sidebar/useSidebarMenu.tsx @@ -1,6 +1,6 @@ import type { BadgeColor, BadgeProps, MenuProps } from '@altinn/altinn-components'; import { useTranslation } from 'react-i18next'; -import { useLocation } from 'react-router-dom'; +import { Link, useLocation } from 'react-router-dom'; import type { InboxViewType } from '../../api/useDialogs.tsx'; import { Routes } from '../../pages/Inbox/Inbox'; export type SideBarView = InboxViewType | 'saved-searches' | 'archive' | 'bin'; @@ -25,7 +25,7 @@ const getBadgeProps = (count: number, color?: BadgeColor): BadgeProps | undefine export const useSidebarMenu = ({ itemsPerViewCount }: UseSidebarProps): MenuProps => { const { t } = useTranslation(); - const { pathname } = useLocation(); + const { pathname, search } = useLocation(); return { groups: {}, @@ -39,6 +39,8 @@ export const useSidebarMenu = ({ itemsPerViewCount }: UseSidebarProps): MenuProp color: 'strong', badge: getBadgeProps(itemsPerViewCount.inbox, 'alert'), selected: pathname === Routes.inbox, + as: Link, + to: Routes.inbox + search, }, { id: '2', @@ -47,6 +49,8 @@ export const useSidebarMenu = ({ itemsPerViewCount }: UseSidebarProps): MenuProp title: t('sidebar.drafts'), badge: getBadgeProps(itemsPerViewCount.drafts), selected: pathname === Routes.drafts, + as: Link, + to: Routes.drafts + search, }, { id: '3', @@ -55,6 +59,8 @@ export const useSidebarMenu = ({ itemsPerViewCount }: UseSidebarProps): MenuProp title: t('sidebar.sent'), badge: getBadgeProps(itemsPerViewCount.sent), selected: pathname === Routes.sent, + as: Link, + to: Routes.sent + search, }, { id: '4', @@ -63,6 +69,8 @@ export const useSidebarMenu = ({ itemsPerViewCount }: UseSidebarProps): MenuProp title: t('sidebar.saved_searches'), badge: getBadgeProps(itemsPerViewCount['saved-searches']), selected: pathname === Routes.savedSearches, + as: Link, + to: Routes.savedSearches + search, }, { id: '5', @@ -71,6 +79,8 @@ export const useSidebarMenu = ({ itemsPerViewCount }: UseSidebarProps): MenuProp title: t('sidebar.archived'), badge: getBadgeProps(itemsPerViewCount.archive), selected: pathname === Routes.archive, + as: Link, + to: Routes.archive + search, }, { id: '6', @@ -80,6 +90,8 @@ export const useSidebarMenu = ({ itemsPerViewCount }: UseSidebarProps): MenuProp title: t('sidebar.deleted'), badge: getBadgeProps(itemsPerViewCount.bin), selected: pathname === Routes.bin, + as: Link, + to: Routes.bin + search, }, ], };