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

fix: show correct message when disconnecting quickbooks desktop #49834

Merged
merged 14 commits into from
Oct 1, 2024
1 change: 0 additions & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,6 @@ export {
getRenamedAction,
isCardIssuedAction,
getCardIssuedMessage,
hasSameActorForAllTransactions,
getRemovedConnectionMessage,
};

Expand Down
118 changes: 118 additions & 0 deletions src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,44 @@
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import getClickedTargetLocation from '@libs/getClickedTargetLocation';
<<<<<<< HEAD

Check failure on line 19 in src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Merge conflict marker encountered.
import * as PaymentUtils from '@libs/PaymentUtils';
import PaymentMethodList from '@pages/settings/Wallet/PaymentMethodList';
=======

Check failure on line 22 in src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Merge conflict marker encountered.
import Navigation from '@libs/Navigation/Navigation';
import * as PaymentUtils from '@libs/PaymentUtils';
import PaymentMethodList from '@pages/settings/Wallet/PaymentMethodList';
import type {FormattedSelectedPaymentMethodIcon} from '@pages/settings/Wallet/WalletPage/types';
>>>>>>> be90481835 (integrate bank accounts logic)

Check failure on line 27 in src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Merge conflict marker encountered.
import variables from '@styles/variables';
import * as BankAccounts from '@userActions/BankAccounts';
import * as PaymentMethods from '@userActions/PaymentMethods';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
<<<<<<< HEAD

Check failure on line 33 in src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Merge conflict marker encountered.
import type {AccountData} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
=======

Check failure on line 36 in src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Merge conflict marker encountered.
import ROUTES from '@src/ROUTES';
import type {AccountData} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';

type FormattedSelectedPaymentMethod = {
title: string;
icon?: FormattedSelectedPaymentMethodIcon;
description?: string;
type?: string;
};

type PaymentMethodState = {
isSelectedPaymentMethodDefault: boolean;
selectedPaymentMethod: AccountData;
formattedSelectedPaymentMethod: FormattedSelectedPaymentMethod;
methodID: string | number;
selectedPaymentMethodType: string;
};
>>>>>>> be90481835 (integrate bank accounts logic)

Check failure on line 55 in src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Merge conflict marker encountered.

type WorkspaceInvoiceVBASectionProps = {
/** The policy ID currently being configured */
policyID: string;
Expand All @@ -38,24 +66,54 @@
const {translate} = useLocalize();
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
<<<<<<< HEAD

Check failure on line 69 in src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Merge conflict marker encountered.
const {paymentMethod, setPaymentMethod, resetSelectedPaymentMethodData} = usePaymentMethodState();
=======

Check failure on line 71 in src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Merge conflict marker encountered.
const [cardList] = useOnyx(ONYXKEYS.CARD_LIST);
const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET);
const [fundList] = useOnyx(ONYXKEYS.FUND_LIST);
>>>>>>> be90481835 (integrate bank accounts logic)

Check failure on line 75 in src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Merge conflict marker encountered.
const addPaymentMethodAnchorRef = useRef(null);
const paymentMethodButtonRef = useRef<HTMLDivElement | null>(null);
const [shouldShowAddPaymentMenu, setShouldShowAddPaymentMenu] = useState(false);
const [showConfirmDeleteModal, setShowConfirmDeleteModal] = useState(false);
const [shouldShowDefaultDeleteMenu, setShouldShowDefaultDeleteMenu] = useState(false);
<<<<<<< HEAD

Check failure on line 81 in src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Merge conflict marker encountered.
=======
const [paymentMethod, setPaymentMethod] = useState<PaymentMethodState>({
isSelectedPaymentMethodDefault: false,
selectedPaymentMethod: {},
formattedSelectedPaymentMethod: {
title: '',
},
methodID: '',
selectedPaymentMethodType: '',
});
>>>>>>> be90481835 (integrate bank accounts logic)
const [anchorPosition, setAnchorPosition] = useState({
anchorPositionHorizontal: 0,
anchorPositionVertical: 0,
anchorPositionTop: 0,
anchorPositionRight: 0,
});
<<<<<<< HEAD
const hasBankAccount = !isEmptyObject(bankAccountList);
const shouldShowEmptyState = !hasBankAccount;
// Determines whether or not the modal popup is mounted from the bottom of the screen instead of the side mount on Web or Desktop screens
const isPopoverBottomMount = anchorPosition.anchorPositionTop === 0 || shouldUseNarrowLayout;
const shouldShowMakeDefaultButton = !paymentMethod.isSelectedPaymentMethodDefault;
const transferBankAccountID = policy?.invoice?.bankAccount?.transferBankAccountID;
=======
const hasBankAccount = !isEmptyObject(bankAccountList) || !isEmptyObject(fundList);
const hasWallet = !isEmptyObject(userWallet);
const hasAssignedCard = !isEmptyObject(cardList);
const shouldShowEmptyState = !hasBankAccount && !hasWallet && !hasAssignedCard;
// Determines whether or not the modal popup is mounted from the bottom of the screen instead of the side mount on Web or Desktop screens
const isPopoverBottomMount = anchorPosition.anchorPositionTop === 0 || shouldUseNarrowLayout;
const shouldShowMakeDefaultButton =
!paymentMethod.isSelectedPaymentMethodDefault &&
!(paymentMethod.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && paymentMethod.selectedPaymentMethod.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS);
>>>>>>> be90481835 (integrate bank accounts logic)

/**
* Set position of the payment menu
Expand Down Expand Up @@ -112,7 +170,11 @@
};
}
setPaymentMethod({
<<<<<<< HEAD
isSelectedPaymentMethodDefault: transferBankAccountID === methodID,
=======
isSelectedPaymentMethodDefault: !!isDefault,
>>>>>>> be90481835 (integrate bank accounts logic)
selectedPaymentMethod: account ?? {},
selectedPaymentMethodType: accountType,
formattedSelectedPaymentMethod,
Expand Down Expand Up @@ -149,6 +211,7 @@
}, [paymentMethod.selectedPaymentMethod.bankAccountID, paymentMethod.selectedPaymentMethodType]);

const makeDefaultPaymentMethod = useCallback(() => {
<<<<<<< HEAD
// Find the previous default payment method so we can revert if the MakeDefaultPaymentMethod command errors
const paymentMethods = PaymentUtils.formatPaymentMethods(bankAccountList ?? {}, {}, styles);
const previousPaymentMethod = paymentMethods.find((method) => !!method.isDefault);
Expand All @@ -157,12 +220,55 @@
PaymentMethods.setInvoicingTransferBankAccount(currentPaymentMethod?.methodID ?? -1, policyID, previousPaymentMethod?.methodID ?? -1);
}
}, [bankAccountList, styles, paymentMethod.selectedPaymentMethodType, paymentMethod.methodID, policyID]);
=======
const paymentCardList = fundList ?? {};
// Find the previous default payment method so we can revert if the MakeDefaultPaymentMethod command errors
const paymentMethods = PaymentUtils.formatPaymentMethods(bankAccountList ?? {}, paymentCardList, styles);

const previousPaymentMethod = paymentMethods.find((method) => !!method.isDefault);
const currentPaymentMethod = paymentMethods.find((method) => method.methodID === paymentMethod.methodID);
if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT) {
PaymentMethods.makeDefaultPaymentMethod(paymentMethod.selectedPaymentMethod.bankAccountID ?? -1, 0, previousPaymentMethod, currentPaymentMethod);
} else if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.DEBIT_CARD) {
PaymentMethods.makeDefaultPaymentMethod(0, paymentMethod.selectedPaymentMethod.fundID ?? -1, previousPaymentMethod, currentPaymentMethod);
}
}, [
paymentMethod.methodID,
paymentMethod.selectedPaymentMethod.bankAccountID,
paymentMethod.selectedPaymentMethod.fundID,
paymentMethod.selectedPaymentMethodType,
bankAccountList,
fundList,
styles,
]);

const resetSelectedPaymentMethodData = useCallback(() => {
// Reset to same values as in the constructor
setPaymentMethod({
isSelectedPaymentMethodDefault: false,
selectedPaymentMethod: {},
formattedSelectedPaymentMethod: {
title: '',
},
methodID: '',
selectedPaymentMethodType: '',
});
}, [setPaymentMethod]);
>>>>>>> be90481835 (integrate bank accounts logic)

/**
* Navigate to the appropriate payment type addition screen
*/
const addPaymentMethodTypePressed = (paymentType: string) => {
hideAddPaymentMenu();
<<<<<<< HEAD
=======

if (paymentType === CONST.PAYMENT_METHODS.DEBIT_CARD) {
Navigation.navigate(ROUTES.SETTINGS_ADD_DEBIT_CARD);
return;
}
>>>>>>> be90481835 (integrate bank accounts logic)
if (paymentType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT || paymentType === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT) {
BankAccounts.openPersonalBankAccountSetupView();
return;
Expand All @@ -183,14 +289,22 @@
shouldShowAddPaymentMethodButton={false}
shouldShowEmptyListMessage={false}
onPress={paymentMethodPressed}
<<<<<<< HEAD
invoiceTransferBankAccountID={transferBankAccountID}
activePaymentMethodID={transferBankAccountID}
=======
activePaymentMethodID={policy?.invoice?.bankAccount?.transferBankAccountID ?? ''}
>>>>>>> be90481835 (integrate bank accounts logic)
actionPaymentMethodType={shouldShowDefaultDeleteMenu ? paymentMethod.selectedPaymentMethodType : ''}
buttonRef={addPaymentMethodAnchorRef}
shouldEnableScroll={false}
style={[styles.mt5, hasBankAccount && [shouldUseNarrowLayout ? styles.mhn5 : styles.mhn8]]}
listItemStyle={shouldUseNarrowLayout ? styles.ph5 : styles.ph8}
/>
<<<<<<< HEAD
=======

>>>>>>> be90481835 (integrate bank accounts logic)
<Popover
isVisible={shouldShowDefaultDeleteMenu}
onClose={hideDefaultDeleteMenu}
Expand Down Expand Up @@ -250,6 +364,10 @@
onModalHide={resetSelectedPaymentMethodData}
/>
</Popover>
<<<<<<< HEAD
=======

>>>>>>> be90481835 (integrate bank accounts logic)
<AddPaymentMethodMenu
isVisible={shouldShowAddPaymentMenu}
onClose={hideAddPaymentMenu}
Expand Down
Loading