diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 2bc04c4a99ea..d36412f9622f 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -672,12 +672,12 @@ const ROUTES = { getRoute: (policyID: string, orderWeight: number) => `settings/workspaces/${policyID}/tags/${orderWeight}/edit` as const, }, WORKSPACE_TAG_EDIT: { - route: 'settings/workspace/:policyID/tag/:tagName/edit', - getRoute: (policyID: string, tagName: string) => `settings/workspace/${policyID}/tag/${encodeURIComponent(tagName)}/edit` as const, + route: 'settings/workspaces/:policyID/tag/:orderWeight/:tagName/edit', + getRoute: (policyID: string, orderWeight: number, tagName: string) => `settings/workspaces/${policyID}/tag/${orderWeight}/${encodeURIComponent(tagName)}/edit` as const, }, WORKSPACE_TAG_SETTINGS: { - route: 'settings/workspaces/:policyID/tag/:tagName', - getRoute: (policyID: string, tagName: string) => `settings/workspaces/${policyID}/tag/${encodeURIComponent(tagName)}` as const, + route: 'settings/workspaces/:policyID/tag/:orderWeight/:tagName', + getRoute: (policyID: string, orderWeight: number, tagName: string) => `settings/workspaces/${policyID}/tag/${orderWeight}/${encodeURIComponent(tagName)}` as const, }, WORKSPACE_TAG_LIST_VIEW: { route: 'settings/workspaces/:policyID/tag-list/:orderWeight', diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index a093b778360e..f5fd8dc2236c 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -427,12 +427,14 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.TAG_EDIT]: { path: ROUTES.WORKSPACE_TAG_EDIT.route, parse: { + orderWeight: Number, tagName: (tagName: string) => decodeURIComponent(tagName), }, }, [SCREENS.WORKSPACE.TAG_SETTINGS]: { path: ROUTES.WORKSPACE_TAG_SETTINGS.route, parse: { + orderWeight: Number, tagName: (tagName: string) => decodeURIComponent(tagName), }, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index e4820df10df9..c1c7d6434ef9 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -211,6 +211,7 @@ type SettingsNavigatorParamList = { }; [SCREENS.WORKSPACE.TAG_SETTINGS]: { policyID: string; + orderWeight: number; tagName: string; }; [SCREENS.WORKSPACE.TAG_LIST_VIEW]: { @@ -223,6 +224,7 @@ type SettingsNavigatorParamList = { }; [SCREENS.WORKSPACE.TAG_EDIT]: { policyID: string; + orderWeight: number; tagName: string; }; [SCREENS.WORKSPACE.TAXES_SETTINGS]: { @@ -791,7 +793,6 @@ type FullScreenNavigatorParamList = { }; [SCREENS.WORKSPACE.TAGS]: { policyID: string; - tagName: string; }; [SCREENS.WORKSPACE.TAXES]: { policyID: string; diff --git a/src/pages/workspace/tags/EditTagPage.tsx b/src/pages/workspace/tags/EditTagPage.tsx index 663cbd4f37be..1f60e9eb6567 100644 --- a/src/pages/workspace/tags/EditTagPage.tsx +++ b/src/pages/workspace/tags/EditTagPage.tsx @@ -41,7 +41,7 @@ function EditTagPage({route, policyTags}: EditTagPageProps) { (values: FormOnyxValues) => { const errors: FormInputErrors = {}; const tagName = values.tagName.trim(); - const {tags} = PolicyUtils.getTagList(policyTags, 0); + const {tags} = PolicyUtils.getTagList(policyTags, route.params.orderWeight); if (!ValidationUtils.isRequiredFulfilled(tagName)) { errors.tagName = 'workspace.tags.tagRequiredError'; } else if (tags?.[tagName] && currentTagName !== tagName) { @@ -50,7 +50,7 @@ function EditTagPage({route, policyTags}: EditTagPageProps) { return errors; }, - [currentTagName, policyTags], + [route.params.orderWeight, currentTagName, policyTags], ); const editTag = useCallback( diff --git a/src/pages/workspace/tags/TagSettingsPage.tsx b/src/pages/workspace/tags/TagSettingsPage.tsx index 1f9d440108ae..2b9f5d3d527b 100644 --- a/src/pages/workspace/tags/TagSettingsPage.tsx +++ b/src/pages/workspace/tags/TagSettingsPage.tsx @@ -38,7 +38,7 @@ type TagSettingsPageProps = TagSettingsPageOnyxProps & StackScreenProps PolicyUtils.getTagList(policyTags, 0), [policyTags]); + const policyTag = useMemo(() => PolicyUtils.getTagList(policyTags, route.params.orderWeight), [policyTags, route.params.orderWeight]); const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${route.params.policyID}`); const {windowWidth} = useWindowDimensions(); @@ -70,7 +70,7 @@ function TagSettingsPage({route, policyTags, navigation}: TagSettingsPageProps) }; const navigateToEditTag = () => { - Navigation.navigate(ROUTES.WORKSPACE_TAG_EDIT.getRoute(route.params.policyID, currentPolicyTag.name)); + Navigation.navigate(ROUTES.WORKSPACE_TAG_EDIT.getRoute(route.params.policyID, route.params.orderWeight, currentPolicyTag.name)); }; const isThereAnyAccountingConnection = Object.keys(policy?.connections ?? {}).length !== 0; diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index eca339be0fc4..1c2a2b345083 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -154,11 +154,11 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) { }; const navigateToTagSettings = (tag: TagListItem) => { - if (tag.orderWeight != null) { + if (tag.orderWeight !== undefined) { Navigation.navigate(ROUTES.WORKSPACE_TAG_LIST_VIEW.getRoute(policyID, tag.orderWeight)); return; } - Navigation.navigate(ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(policyID, tag.value)); + Navigation.navigate(ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(policyID, 0, tag.value)); }; const selectedTagsArray = Object.keys(selectedTags).filter((key) => selectedTags[key]); diff --git a/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx b/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx index 09ba086e3a14..0ae4c04c9242 100644 --- a/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceViewTagsPage.tsx @@ -117,7 +117,7 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) { ); const navigateToTagSettings = (tag: TagListItem) => { - Navigation.navigate(ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(policyID, tag.value)); + Navigation.navigate(ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(policyID, route.params.orderWeight, tag.value)); }; const selectedTagsArray = Object.keys(selectedTags).filter((key) => selectedTags[key]);