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:
20
packages/twenty-front/src/hooks/useNavigateApp.ts
Normal file
20
packages/twenty-front/src/hooks/useNavigateApp.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||
|
||||
export const useNavigateApp = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
return <T extends AppPath>(
|
||||
to: T,
|
||||
params?: Parameters<typeof getAppPath<T>>[1],
|
||||
queryParams?: Record<string, any>,
|
||||
options?: {
|
||||
replace?: boolean;
|
||||
state?: any;
|
||||
},
|
||||
) => {
|
||||
const path = getAppPath(to, params, queryParams);
|
||||
return navigate(path, options);
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user