Files
twenty_crm/packages/twenty-front/src/modules/settings/components/SettingsNavigationDrawerItem.tsx
Tushar Ranjan ccdef0e97b Fix: Nav Item Api & Webhook and Functions stay selected (#7628)
Fixed Nav Item Api & Webhook and Functions stay selected like data model
settings.
 Now when clicked stays selected and deos not loose its selection

Fixes #7573


https://github.com/user-attachments/assets/4cb78158-8411-4ee1-9bcc-2870344c0c62

---------

Co-authored-by: ehconitin <nitinkoche03@gmail.com>
Co-authored-by: Félix Malfait <felix@twenty.com>
2024-10-13 13:18:33 +02:00

49 lines
1.2 KiB
TypeScript

import { useMatch, useResolvedPath } from 'react-router-dom';
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
import { SettingsPath } from '@/types/SettingsPath';
import {
NavigationDrawerItem,
NavigationDrawerItemProps,
} from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
import { NavigationDrawerSubItemState } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerSubItemState';
type SettingsNavigationDrawerItemProps = Pick<
NavigationDrawerItemProps,
'Icon' | 'label' | 'indentationLevel' | 'soon'
> & {
matchSubPages?: boolean;
path: SettingsPath;
subItemState?: NavigationDrawerSubItemState;
};
export const SettingsNavigationDrawerItem = ({
Icon,
label,
indentationLevel,
matchSubPages = true,
path,
soon,
subItemState,
}: SettingsNavigationDrawerItemProps) => {
const href = getSettingsPagePath(path);
const pathName = useResolvedPath(href).pathname;
const isActive = !!useMatch({
path: pathName,
end: !matchSubPages,
});
return (
<NavigationDrawerItem
indentationLevel={indentationLevel}
subItemState={subItemState}
label={label}
to={href}
Icon={Icon}
active={isActive}
soon={soon}
/>
);
};