Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make taxes read-only when connected to accounting integration #42192

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function WorkspaceEditTaxPage({
<HeaderWithBackButton
title={currentTaxRate?.name}
threeDotsMenuItems={threeDotsMenuItems}
shouldShowThreeDotsButton={!!canEdit}
shouldShowThreeDotsButton={!!canEdit && !PolicyUtils.hasAccountingConnections(policy)}
threeDotsAnchorPosition={styles.threeDotsPopoverOffsetNoCloseButton(windowWidth)}
/>
<OfflineWithFeedback
Expand Down
29 changes: 16 additions & 13 deletions src/pages/workspace/taxes/WorkspaceTaxesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,15 @@ function WorkspaceTaxesPage({

const dropdownMenuOptions = useMemo(() => {
const isMultiple = selectedTaxesIDs.length > 1;
const options: Array<DropdownOption<WorkspaceTaxRatesBulkActionType>> = [
{
const options: Array<DropdownOption<WorkspaceTaxRatesBulkActionType>> = [];
if (!PolicyUtils.hasAccountingConnections(policy)) {
options.push({
icon: Expensicons.Trashcan,
text: isMultiple ? translate('workspace.taxes.actions.deleteMultiple') : translate('workspace.taxes.actions.delete'),
value: CONST.POLICY.TAX_RATES_BULK_ACTION_TYPES.DELETE,
onSelected: () => setIsDeleteModalVisible(true),
},
];
});
}

// `Disable rates` when at least one enabled rate is selected.
if (selectedTaxesIDs.some((taxID) => !policy?.taxRates?.taxes[taxID]?.isDisabled)) {
Expand All @@ -201,18 +202,20 @@ function WorkspaceTaxesPage({
});
}
return options;
}, [policy?.taxRates?.taxes, selectedTaxesIDs, toggleTaxes, translate]);
}, [policy, selectedTaxesIDs, toggleTaxes, translate]);

const headerButtons = !selectedTaxesIDs.length ? (
<View style={[styles.w100, styles.flexRow, isSmallScreenWidth && styles.mb3]}>
<Button
medium
success
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_TAX_CREATE.getRoute(policyID))}
icon={Expensicons.Plus}
text={translate('workspace.taxes.addRate')}
style={[styles.mr3, isSmallScreenWidth && styles.w50]}
/>
{!PolicyUtils.hasAccountingConnections(policy) && (
<Button
medium
success
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_TAX_CREATE.getRoute(policyID))}
icon={Expensicons.Plus}
text={translate('workspace.taxes.addRate')}
style={[styles.mr3, isSmallScreenWidth && styles.w50]}
/>
)}
<Button
medium
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_TAXES_SETTINGS.getRoute(policyID))}
Expand Down
Loading