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:
@ -70,7 +70,7 @@ describe('useDefaultHomePagePath', () => {
|
||||
setupMockPrefetchedData('viewId');
|
||||
const { result } = renderHooks(true);
|
||||
expect(result.current.defaultHomePagePath).toEqual(
|
||||
'/objects/companies?view=viewId',
|
||||
'/objects/companies?viewId=viewId',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -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 };
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||
import { lastVisitedObjectMetadataItemIdStateSelector } from '@/navigation/states/selectors/lastVisitedObjectMetadataItemIdStateSelector';
|
||||
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
||||
import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
|
||||
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-ui';
|
||||
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||
|
||||
export const useLastVisitedObjectMetadataItem = () => {
|
||||
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
||||
@ -44,7 +46,9 @@ export const useLastVisitedObjectMetadataItem = () => {
|
||||
if (isDeactivateDefault) {
|
||||
setLastVisitedObjectMetadataItemId(newFallbackObjectMetadataItem.id);
|
||||
setNavigationMemorizedUrl(
|
||||
`/objects/${newFallbackObjectMetadataItem.namePlural}`,
|
||||
getAppPath(AppPath.RecordIndexPage, {
|
||||
objectNamePlural: newFallbackObjectMetadataItem.namePlural,
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user