Skip to content

Commit

Permalink
fix: grey out tax rate with pending action.
Browse files Browse the repository at this point in the history
Signed-off-by: Krishna Gupta <[email protected]>
  • Loading branch information
Krishna2323 committed Jun 9, 2024
1 parent 229d761 commit 36e98ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ function getCategoryOptionTree(options: Record<string, Category> | 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;
Expand All @@ -1061,7 +1061,7 @@ function getCategoryOptionTree(options: Record<string, Category> | 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,
});
});
});
Expand Down Expand Up @@ -1211,7 +1211,7 @@ function getTagsOptions(tags: Array<Pick<PolicyTag, 'name' | 'enabled' | 'pendin
tooltipText: cleanedName,
isDisabled: !tag.enabled || tag.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
isSelected: selectedOptions?.some((selectedTag) => selectedTag.name === tag.name),
pendingAction: tag.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? tag.pendingAction : undefined,
pendingAction: tag.pendingAction,
};
});
}
Expand Down
12 changes: 9 additions & 3 deletions src/libs/actions/TaxRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -214,7 +215,7 @@ function setPolicyTaxesEnabled(policyID: string, taxesIDsToUpdate: string[], isE
value: {
taxRates: {
taxes: taxesIDsToUpdate.reduce<TaxRateEnabledMap>((acc, taxID) => {
acc[taxID] = {pendingFields: {isDisabled: null}, errorFields: {isDisabled: null}};
acc[taxID] = {pendingFields: {isDisabled: null}, errorFields: {isDisabled: null}, pendingAction: null};
return acc;
}, {}),
},
Expand All @@ -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;
Expand Down Expand Up @@ -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},
},
},
Expand All @@ -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}},
},
},
},
Expand All @@ -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')},
},
},
Expand Down Expand Up @@ -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},
},
},
Expand All @@ -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}},
},
},
},
Expand All @@ -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')},
},
},
Expand Down

0 comments on commit 36e98ca

Please sign in to comment.