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>
49 lines
1.2 KiB
TypeScript
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}
|
|
/>
|
|
);
|
|
};
|