Skip to content
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
54 changes: 22 additions & 32 deletions src/pages/settings/Wallet/WalletPage/WalletPage.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import lodashGet from 'lodash/get';
import React, {useCallback, useEffect, useRef, useState} from 'react';
import {ActivityIndicator, InteractionManager, ScrollView, View} from 'react-native';
import {ActivityIndicator, ScrollView, View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import AddPaymentMethodMenu from '@components/AddPaymentMethodMenu';
import Button from '@components/Button';
import ConfirmContent from '@components/ConfirmContent';
import ConfirmModal from '@components/ConfirmModal';
import CurrentWalletBalance from '@components/CurrentWalletBalance';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Icon from '@components/Icon';
Expand Down Expand Up @@ -62,7 +62,7 @@ function WalletPage({bankAccountList, cardList, fundList, isLoadingPaymentMethod
anchorPositionTop: 0,
anchorPositionRight: 0,
});
const [showConfirmDeleteContent, setShowConfirmDeleteContent] = useState(false);
const [showConfirmDeleteModal, setShowConfirmDeleteModal] = useState(false);

const hasBankAccount = !_.isEmpty(bankAccountList) || !_.isEmpty(fundList);
const hasWallet = !_.isEmpty(userWallet);
Expand Down Expand Up @@ -215,10 +215,8 @@ function WalletPage({bankAccountList, cardList, fundList, isLoadingPaymentMethod
*/
const hideDefaultDeleteMenu = useCallback(() => {
setShouldShowDefaultDeleteMenu(false);
InteractionManager.runAfterInteractions(() => {
setShowConfirmDeleteContent(false);
});
}, [setShouldShowDefaultDeleteMenu, setShowConfirmDeleteContent]);
setShowConfirmDeleteModal(false);
}, [setShouldShowDefaultDeleteMenu, setShowConfirmDeleteModal]);

const makeDefaultPaymentMethod = useCallback(() => {
const paymentCardList = fundList || {};
Expand Down Expand Up @@ -487,11 +485,9 @@ function WalletPage({bankAccountList, cardList, fundList, isLoadingPaymentMethod
top: anchorPosition.anchorPositionTop,
right: anchorPosition.anchorPositionRight,
}}
withoutOverlay
anchorRef={paymentMethodButtonRef}
onModalHide={resetSelectedPaymentMethodData}
>
{!showConfirmDeleteContent ? (
{!showConfirmDeleteModal && (
<View style={[styles.m5, !isSmallScreenWidth ? styles.sidebarPopover : '']}>
{isPopoverBottomMount && (
<MenuItem
Expand All @@ -512,34 +508,28 @@ function WalletPage({bankAccountList, cardList, fundList, isLoadingPaymentMethod
/>
)}
<Button
onPress={() => {
setShowConfirmDeleteContent(true);
}}
onPress={() => setShowConfirmDeleteModal(true)}
style={[shouldShowMakeDefaultButton ? styles.mt4 : {}]}
text={translate('common.delete')}
danger
/>
</View>
) : (
<ConfirmContent
onConfirm={() => {
deletePaymentMethod();
hideDefaultDeleteMenu();
}}
onCancel={hideDefaultDeleteMenu}
contentStyles={!isSmallScreenWidth ? [styles.sidebarPopover, styles.willChangeTransform] : undefined}
title={translate('walletPage.deleteAccount')}
prompt={translate('walletPage.deleteConfirmation')}
confirmText={translate('common.delete')}
cancelText={translate('common.cancel')}
anchorPosition={{
top: anchorPosition.anchorPositionTop,
right: anchorPosition.anchorPositionRight,
}}
shouldShowCancelButton
danger
/>
)}
<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>
</ScreenWrapper>
)}
Expand Down