Skip to content

Commit

Permalink
More work
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdigdir committed Nov 26, 2024
1 parent efd4766 commit 28d912c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/frontend/src/components/Sidebar/useSidebarMenu.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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: {},
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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,
},
],
};
Expand Down

0 comments on commit 28d912c

Please sign in to comment.