New useNavigateApp (#9729)

Todo : 
- replace all instances of useNavigate(
- remove getSettingsPagePath
- add eslint rule to enfore usage of useNavigateApp instead of
useNavigate
This commit is contained in:
Félix Malfait
2025-01-18 13:58:12 +01:00
committed by GitHub
parent 8572471973
commit 152902d1be
115 changed files with 975 additions and 679 deletions

View File

@ -9,6 +9,7 @@ import { View } from '@/views/types/View';
import { useCallback, useMemo } from 'react';
import { useRecoilValue } from 'recoil';
import { isDefined } from '~/utils/isDefined';
import { getAppPath } from '~/utils/navigation/getAppPath';
export const useDefaultHomePagePath = () => {
const currentUser = useRecoilValue(currentUserState);
@ -79,11 +80,13 @@ export const useDefaultHomePagePath = () => {
}
const namePlural = defaultObjectPathInfo.objectMetadataItem?.namePlural;
const viewParam = defaultObjectPathInfo.view
? `?view=${defaultObjectPathInfo.view.id}`
: '';
const viewId = defaultObjectPathInfo.view?.id;
return `/objects/${namePlural}${viewParam}`;
return getAppPath(
AppPath.RecordIndexPage,
{ objectNamePlural: namePlural },
viewId ? { viewId } : undefined,
);
}, [currentUser, defaultObjectPathInfo]);
return { defaultHomePagePath };