Files
twenty/packages/twenty-front/src/hooks/useNavigateSettings.ts
Félix Malfait 152902d1be New useNavigateApp (#9729)
Todo : 
- replace all instances of useNavigate(
- remove getSettingsPagePath
- add eslint rule to enfore usage of useNavigateApp instead of
useNavigate
2025-01-18 13:58:12 +01:00

21 lines
569 B
TypeScript

import { SettingsPath } from '@/types/SettingsPath';
import { useNavigate } from 'react-router-dom';
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
export const useNavigateSettings = () => {
const navigate = useNavigate();
return <T extends SettingsPath>(
to: T,
params?: Parameters<typeof getSettingsPath<T>>[1],
queryParams?: Record<string, any>,
options?: {
replace?: boolean;
state?: any;
},
) => {
const path = getSettingsPath(to, params, queryParams);
return navigate(path, options);
};
};