From 36e98ca0369e1bc44ee0607aa541d83ade622b8c Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Mon, 10 Jun 2024 04:21:49 +0530 Subject: [PATCH] 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 02ddcc85ffdc..9840e29ff347 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 f8425cd0c40c..99ce116d1361 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')}, }, },