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 #41785

Closed
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
18 changes: 10 additions & 8 deletions src/pages/workspace/tags/WorkspaceTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,16 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) {

return (
<View style={[styles.w100, styles.flexRow, isSmallScreenWidth && styles.mb3]}>
<Button
medium
success
onPress={navigateToCreateTagPage}
icon={Expensicons.Plus}
text={translate('workspace.tags.addTag')}
style={[styles.mr3, isSmallScreenWidth && styles.w50]}
/>
{!PolicyUtils.hasAccountingConnections(policy) && (
<Button
medium
success
onPress={navigateToCreateTagPage}
icon={Expensicons.Plus}
text={translate('workspace.tags.addTag')}
style={[styles.mr3, isSmallScreenWidth && styles.w50]}
/>
)}
{policyTags && (
<Button
medium
Expand Down
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
30 changes: 17 additions & 13 deletions src/pages/workspace/taxes/WorkspaceTaxesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,16 @@ function WorkspaceTaxesPage({

const dropdownMenuOptions = useMemo(() => {
const isMultiple = selectedTaxesIDs.length > 1;
const options: Array<DropdownOption<WorkspaceTaxRatesBulkActionType>> = [
{
const options: Array<DropdownOption<WorkspaceTaxRatesBulkActionType>> = [];
const isThereAnyAccountingConnection = PolicyUtils.hasAccountingConnections(policy);
if (!isThereAnyAccountingConnection) {
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 +203,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