Skip to content

Commit

Permalink
Make edit accoridng to the review
Browse files Browse the repository at this point in the history
  • Loading branch information
etCoderDysto committed Aug 5, 2024
1 parent ca6cc1a commit f96a4ed
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/libs/actions/Policy/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ function createPolicyCategory(policyID: string, categoryName: string) {
}

function renamePolicyCategory(policyID: string, policyCategory: {oldName: string; newName: string}) {
const policyCategoryToUpdate = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`]?.[policyCategory.oldName] ?? {};
const pendingFields = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`]?.[policyCategory.oldName]?.pendingFields ?? {};
const policyCategoryToUpdate = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`]?.[policyCategory.oldName];

const onyxData: OnyxData = {
optimisticData: [
Expand All @@ -282,7 +281,7 @@ function renamePolicyCategory(policyID: string, policyCategory: {oldName: string
name: policyCategory.newName,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
pendingFields: {
...pendingFields,
...(policyCategoryToUpdate?.pendingFields ?? {}),
name: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
previousCategoryName: policyCategory.oldName,
Expand All @@ -302,7 +301,7 @@ function renamePolicyCategory(policyID: string, policyCategory: {oldName: string
errors: null,
pendingAction: null,
pendingFields: {
...pendingFields,
...(policyCategoryToUpdate?.pendingFields ?? {}),
name: null,
},
},
Expand Down

0 comments on commit f96a4ed

Please sign in to comment.