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: manage modal closing #54279

Merged
Merged
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
37 changes: 19 additions & 18 deletions src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import * as PaymentUtils from '@libs/PaymentUtils';
import PaymentMethodList from '@pages/settings/Wallet/PaymentMethodList';
import variables from '@styles/variables';
import * as BankAccounts from '@userActions/BankAccounts';
import * as Modal from '@userActions/Modal';
import * as PaymentMethods from '@userActions/PaymentMethods';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -117,7 +118,7 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
selectedPaymentMethod: account ?? {},
selectedPaymentMethodType: accountType,
formattedSelectedPaymentMethod,
methodID: methodID ?? '-1',
methodID: methodID ?? CONST.DEFAULT_NUMBER_ID,
});
setShouldShowDefaultDeleteMenu(true);
setMenuPosition();
Expand Down Expand Up @@ -155,7 +156,7 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
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.setInvoicingTransferBankAccount(currentPaymentMethod?.methodID ?? -1, policyID, previousPaymentMethod?.methodID ?? -1);
PaymentMethods.setInvoicingTransferBankAccount(currentPaymentMethod?.methodID ?? CONST.DEFAULT_NUMBER_ID, policyID, previousPaymentMethod?.methodID ?? CONST.DEFAULT_NUMBER_ID);
}
}, [bankAccountList, styles, paymentMethod.selectedPaymentMethodType, paymentMethod.methodID, policyID]);

Expand Down Expand Up @@ -231,27 +232,27 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
<MenuItem
title={translate('common.delete')}
icon={Expensicons.Trashcan}
onPress={() => setShowConfirmDeleteModal(true)}
onPress={() => Modal.close(() => setShowConfirmDeleteModal(true))}
wrapperStyle={[styles.pv3, styles.ph5, !shouldUseNarrowLayout ? styles.sidebarPopover : {}]}
/>
</View>
)}
<ConfirmModal
isVisible={showConfirmDeleteModal}
onConfirm={() => {
deletePaymentMethod();
hideDefaultDeleteMenu();
}}
onCancel={hideDefaultDeleteMenu}
title={translate('walletPage.deleteAccount')}
prompt={translate('walletPage.deleteConfirmation')}
confirmText={translate('common.delete')}
cancelText={translate('common.cancel')}
shouldShowCancelButton
danger
onModalHide={resetSelectedPaymentMethodData}
/>
</Popover>
<ConfirmModal
isVisible={showConfirmDeleteModal}
onConfirm={() => {
deletePaymentMethod();
hideDefaultDeleteMenu();
}}
onCancel={hideDefaultDeleteMenu}
title={translate('walletPage.deleteAccount')}
prompt={translate('walletPage.deleteConfirmation')}
confirmText={translate('common.delete')}
cancelText={translate('common.cancel')}
shouldShowCancelButton
danger
onModalHide={resetSelectedPaymentMethodData}
/>
<AddPaymentMethodMenu
isVisible={shouldShowAddPaymentMenu}
onClose={hideAddPaymentMenu}
Expand Down
Loading