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:
@ -1,12 +1,14 @@
|
||||
import { useCallback } from 'react';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
|
||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||
import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { viewObjectMetadataIdComponentState } from '@/views/states/viewObjectMetadataIdComponentState';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const useGetAvailableFieldsForKanban = () => {
|
||||
@ -28,19 +30,23 @@ export const useGetAvailableFieldsForKanban = () => {
|
||||
(field) => field.type === FieldMetadataType.Select,
|
||||
) ?? [];
|
||||
|
||||
const navigate = useNavigate();
|
||||
const navigate = useNavigateSettings();
|
||||
|
||||
const navigateToSelectSettings = useCallback(() => {
|
||||
setNavigationMemorizedUrl(location.pathname + location.search);
|
||||
|
||||
if (isDefined(objectMetadataItem?.namePlural)) {
|
||||
navigate(
|
||||
`/settings/objects/${
|
||||
objectMetadataItem.namePlural
|
||||
}/new-field/configure?fieldType=${FieldMetadataType.Select}`,
|
||||
SettingsPath.ObjectNewFieldConfigure,
|
||||
{
|
||||
objectNamePlural: objectMetadataItem.namePlural,
|
||||
},
|
||||
{
|
||||
fieldType: FieldMetadataType.Select,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
navigate(`/settings/objects`);
|
||||
navigate(SettingsPath.Objects);
|
||||
}
|
||||
}, [
|
||||
setNavigationMemorizedUrl,
|
||||
|
||||
Reference in New Issue
Block a user