From ee5feaf3989c2dcd9c66f070b2fd74749b93b738 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Mon, 3 Jun 2024 03:20:43 +0530 Subject: [PATCH 1/2] fix: Taxes - Edited tax is not grayed out in Tax list in submit manual flow. Signed-off-by: Krishna Gupta --- src/libs/OptionsListUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index f321c10c686eb..141d611debe09 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1020,7 +1020,7 @@ function getCategoryOptionTree(options: Record | Category[], i tooltipText: option.name, isDisabled: !option.enabled || option.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, isSelected: !!option.isSelected, - pendingAction: option.pendingAction, + pendingAction: option.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? option.pendingAction : undefined, }); return; @@ -1042,7 +1042,7 @@ function getCategoryOptionTree(options: Record | Category[], i tooltipText: optionName, isDisabled: isChild ? !option.enabled || option.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE : true, isSelected: isChild ? !!option.isSelected : selectedOptionsName.includes(searchText), - pendingAction: option.pendingAction, + pendingAction: option.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? option.pendingAction : undefined, }); }); }); @@ -1192,7 +1192,7 @@ function getTagsOptions(tags: Array selectedTag.name === tag.name), - pendingAction: tag.pendingAction, + pendingAction: tag.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? tag.pendingAction : undefined, }; }); } From 36e98ca0369e1bc44ee0607aa541d83ade622b8c Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Mon, 10 Jun 2024 04:21:49 +0530 Subject: [PATCH 2/2] fix: grey out tax rate with pending action. Signed-off-by: Krishna Gupta --- src/libs/OptionsListUtils.ts | 6 +++--- src/libs/actions/TaxRate.ts | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 02ddcc85ffdc9..9840e29ff3472 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1039,7 +1039,7 @@ function getCategoryOptionTree(options: Record | Category[], i tooltipText: option.name, isDisabled: !option.enabled || option.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, isSelected: !!option.isSelected, - pendingAction: option.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? option.pendingAction : undefined, + pendingAction: option.pendingAction, }); return; @@ -1061,7 +1061,7 @@ function getCategoryOptionTree(options: Record | Category[], i tooltipText: optionName, isDisabled: isChild ? !option.enabled || option.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE : true, isSelected: isChild ? !!option.isSelected : selectedOptionsName.includes(searchText), - pendingAction: option.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? option.pendingAction : undefined, + pendingAction: option.pendingAction, }); }); }); @@ -1211,7 +1211,7 @@ function getTagsOptions(tags: Array selectedTag.name === tag.name), - pendingAction: tag.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? tag.pendingAction : undefined, + pendingAction: tag.pendingAction, }; }); } diff --git a/src/libs/actions/TaxRate.ts b/src/libs/actions/TaxRate.ts index f8425cd0c40cd..99ce116d13613 100644 --- a/src/libs/actions/TaxRate.ts +++ b/src/libs/actions/TaxRate.ts @@ -199,6 +199,7 @@ function setPolicyTaxesEnabled(policyID: string, taxesIDsToUpdate: string[], isE acc[taxID] = { isDisabled: !isEnabled, pendingFields: {isDisabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, + pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, errorFields: {isDisabled: null}, }; return acc; @@ -214,7 +215,7 @@ function setPolicyTaxesEnabled(policyID: string, taxesIDsToUpdate: string[], isE value: { taxRates: { taxes: taxesIDsToUpdate.reduce((acc, taxID) => { - acc[taxID] = {pendingFields: {isDisabled: null}, errorFields: {isDisabled: null}}; + acc[taxID] = {pendingFields: {isDisabled: null}, errorFields: {isDisabled: null}, pendingAction: null}; return acc; }, {}), }, @@ -231,6 +232,7 @@ function setPolicyTaxesEnabled(policyID: string, taxesIDsToUpdate: string[], isE acc[taxID] = { isDisabled: !!originalTaxes[taxID].isDisabled, pendingFields: {isDisabled: null}, + pendingAction: null, errorFields: {isDisabled: ErrorUtils.getMicroSecondOnyxError('workspace.taxes.error.updateFailureMessage')}, }; return acc; @@ -346,6 +348,7 @@ function updatePolicyTaxValue(policyID: string, taxID: string, taxValue: number) [taxID]: { value: stringTaxValue, pendingFields: {value: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, + pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, errorFields: {value: null}, }, }, @@ -360,7 +363,7 @@ function updatePolicyTaxValue(policyID: string, taxID: string, taxValue: number) value: { taxRates: { taxes: { - [taxID]: {pendingFields: {value: null}, errorFields: {value: null}}, + [taxID]: {pendingFields: {value: null}, pendingAction: null, errorFields: {value: null}}, }, }, }, @@ -376,6 +379,7 @@ function updatePolicyTaxValue(policyID: string, taxID: string, taxValue: number) [taxID]: { value: originalTaxRate.value, pendingFields: {value: null}, + pendingAction: null, errorFields: {value: ErrorUtils.getMicroSecondOnyxError('workspace.taxes.error.updateFailureMessage')}, }, }, @@ -408,6 +412,7 @@ function renamePolicyTax(policyID: string, taxID: string, newName: string) { [taxID]: { name: newName, pendingFields: {name: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, + pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, errorFields: {name: null}, }, }, @@ -422,7 +427,7 @@ function renamePolicyTax(policyID: string, taxID: string, newName: string) { value: { taxRates: { taxes: { - [taxID]: {pendingFields: {name: null}, errorFields: {name: null}}, + [taxID]: {pendingFields: {name: null}, pendingAction: null, errorFields: {name: null}}, }, }, }, @@ -438,6 +443,7 @@ function renamePolicyTax(policyID: string, taxID: string, newName: string) { [taxID]: { name: originalTaxRate.name, pendingFields: {name: null}, + pendingAction: null, errorFields: {name: ErrorUtils.getMicroSecondOnyxError('workspace.taxes.error.updateFailureMessage')}, }, },