Skip to content

Commit

Permalink
Merge pull request #38412 from Expensify/cmartins-fixCategoryBehavior
Browse files Browse the repository at this point in the history
[CP Staging] Fix edit category

(cherry picked from commit 4acd981)
  • Loading branch information
cristipaval authored and OSBotify committed Mar 15, 2024
1 parent 0b6b396 commit 397f3d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ const ROUTES = {
},
WORKSPACE_CATEGORY_EDIT: {
route: 'workspace/:policyID/categories/:categoryName/edit',
getRoute: (policyID: string, categoryName: string) => `workspace/${policyID}/categories/${encodeURI(categoryName)}/edit` as const,
getRoute: (policyID: string, categoryName: string) => `workspace/${policyID}/categories/${encodeURIComponent(categoryName)}/edit` as const,
},
WORKSPACE_TAGS: {
route: 'settings/workspaces/:policyID/tags',
Expand Down
7 changes: 4 additions & 3 deletions src/pages/workspace/categories/EditCategoryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ type EditCategoryPageProps = WorkspaceEditCategoryPageOnyxProps & StackScreenPro
function EditCategoryPage({route, policyCategories}: EditCategoryPageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const currentCategoryName = decodeURIComponent(route.params.categoryName);

const editCategory = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_CATEGORY_FORM>) => {
Policy.renamePolicyCategory(route.params.policyID, {oldName: route.params.categoryName, newName: values.categoryName});
Policy.renamePolicyCategory(route.params.policyID, {oldName: currentCategoryName, newName: values.categoryName});
},
[route.params.categoryName, route.params.policyID],
[currentCategoryName, route.params.policyID],
);

return (
Expand All @@ -50,7 +51,7 @@ function EditCategoryPage({route, policyCategories}: EditCategoryPageProps) {
/>
<CategoryForm
onSubmit={editCategory}
categoryName={route.params.categoryName}
categoryName={currentCategoryName}
policyCategories={policyCategories}
/>
</ScreenWrapper>
Expand Down

0 comments on commit 397f3d2

Please sign in to comment.