Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ type VendorListItem = ListItem & {
value: string;
};

// Certinia's vendorAccount field holds a raw vendor ID; sending this empty string clears the default.
const CLEAR_DEFAULT_VENDOR = '';

function CertiniaDefaultVendorPage({policy}: WithPolicyConnectionsProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
Expand Down Expand Up @@ -54,8 +57,9 @@ function CertiniaDefaultVendorPage({policy}: WithPolicyConnectionsProps) {
);

const selectVendor = (row: VendorListItem) => {
if (row.value !== exportConfig?.vendorAccount && policyID) {
updateFinancialForceDefaultVendor(policyID, row.value, exportConfig?.vendorAccount ?? null);
if (policyID) {
const newValue = row.value === exportConfig?.vendorAccount ? CLEAR_DEFAULT_VENDOR : row.value;
updateFinancialForceDefaultVendor(policyID, newValue, exportConfig?.vendorAccount ?? null);
}
Navigation.goBack(backPath);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import {useRoute} from '@react-navigation/native';
import React, {useCallback, useMemo} from 'react';
import {View} from 'react-native';

// Sage Intacct's default-vendor fields hold a raw vendor ID; sending this empty string clears the default.
const CLEAR_DEFAULT_VENDOR = '';

function DynamicSageIntacctDefaultVendorPage() {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -77,9 +80,8 @@ function DynamicSageIntacctDefaultVendorPage() {

const updateDefaultVendor = useCallback(
({value}: SelectorType) => {
if (value !== defaultVendor) {
updateSageIntacctDefaultVendor(policyID, settingName, value, defaultVendor);
}
const newValue = value === defaultVendor ? CLEAR_DEFAULT_VENDOR : value;
updateSageIntacctDefaultVendor(policyID, settingName, newValue, defaultVendor);
goBack();
},
[defaultVendor, policyID, settingName, goBack],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import type SCREENS from '@src/SCREENS';
import {useRoute} from '@react-navigation/native';
import React, {useCallback, useMemo} from 'react';

// NetSuite's defaultVendor field holds a raw vendor ID; sending this empty string clears the default.
const CLEAR_DEFAULT_VENDOR = '';

function DynamicNetSuiteExportExpensesVendorSelectPage({policy}: WithPolicyConnectionsProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand All @@ -51,8 +54,9 @@ function DynamicNetSuiteExportExpensesVendorSelectPage({policy}: WithPolicyConne

const updateDefaultVendor = useCallback(
({value}: SelectorType) => {
if (config?.defaultVendor !== value && policyID) {
updateNetSuiteDefaultVendor(policyID, value, config?.defaultVendor);
if (policyID) {
const newValue = value === config?.defaultVendor ? CLEAR_DEFAULT_VENDOR : value;
updateNetSuiteDefaultVendor(policyID, newValue, config?.defaultVendor);
}
goBack();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ function QuickbooksDesktopNonReimbursableDefaultVendorSelectPage({policy}: WithP

const selectVendor = useCallback(
(row: CardListItem) => {
if (row.value !== nonReimbursableBillDefaultVendor) {
updateQuickbooksDesktopNonReimbursableBillDefaultVendor(policyID, row.value, nonReimbursableBillDefaultVendor);
}
const newValue = row.value === nonReimbursableBillDefaultVendor ? (CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE as string) : row.value;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as string cast here looks unnecessary.

updateQuickbooksDesktopNonReimbursableBillDefaultVendor(policyID, newValue, nonReimbursableBillDefaultVendor);
Navigation.goBack();
},
[nonReimbursableBillDefaultVendor, policyID],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ function QuickbooksNonReimbursableVendorSelectPage({policy, configKey, updateVen
})) ?? [];

const selectVendor = (row: CardListItem) => {
if (row.value !== currentVendor) {
updateVendor(policyID, row.value, currentVendor);
}
const newValue = row.value === currentVendor ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : row.value;
updateVendor(policyID, newValue, currentVendor);
Navigation.goBack();
};

Expand Down
Loading