Skip to content

Commit

Permalink
Merge pull request #30882 from neonbhai/popover-changes
Browse files Browse the repository at this point in the history
Popover Fixes
  • Loading branch information
jasperhuangg authored Dec 14, 2023
2 parents fe2d0d1 + 0ab3991 commit b950c1e
Showing 1 changed file with 22 additions and 32 deletions.
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

0 comments on commit b950c1e

Please sign in to comment.