From 2df92a167fbe821ee53303aa39cd123f6c14ec97 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 7 Feb 2024 20:30:09 +0100 Subject: [PATCH 1/4] Fix bug with The close button linked to "Request money. Get $250" is not functioning --- .../OptionsSelector/BaseOptionsSelector.js | 12 +----------- src/components/ReferralProgramCTA.tsx | 2 +- src/pages/NewChatPage.js | 6 ------ ...poraryForRefactorRequestParticipantsSelector.js | 14 ++------------ .../MoneyRequestParticipantsSelector.js | 14 ++------------ 5 files changed, 6 insertions(+), 42 deletions(-) diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index 345680e809f3..fee83d4f8230 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -41,9 +41,6 @@ const propTypes = { /** Whether referral CTA should be displayed */ shouldShowReferralCTA: PropTypes.bool, - /** A method triggered when the user closes the call to action banner */ - onCallToActionClosed: PropTypes.func, - /** Referral content type */ referralContentType: PropTypes.string, @@ -95,7 +92,6 @@ class BaseOptionsSelector extends Component { allOptions, focusedIndex, shouldDisableRowSelection: false, - shouldShowReferralModal: this.props.shouldShowReferralCTA, errorMessage: '', paginationPage: 1, disableEnterShortCut: false, @@ -266,11 +262,6 @@ class BaseOptionsSelector extends Component { this.props.onChangeText(value); } - closeReferralModal() { - this.setState((prevState) => ({shouldShowReferralModal: !prevState.shouldShowReferralModal})); - this.props.onCallToActionClosed(this.props.referralContentType); - } - handleFocusIn() { const activeElement = document.activeElement; this.setState({ @@ -653,11 +644,10 @@ class BaseOptionsSelector extends Component { )} - {this.props.shouldShowReferralCTA && this.state.shouldShowReferralModal && ( + {this.props.shouldShowReferralCTA && ( )} diff --git a/src/components/ReferralProgramCTA.tsx b/src/components/ReferralProgramCTA.tsx index 4e0ed1f573f9..83bdfd67fef1 100644 --- a/src/components/ReferralProgramCTA.tsx +++ b/src/components/ReferralProgramCTA.tsx @@ -33,7 +33,7 @@ function ReferralProgramCTA({referralContentType, dismissedReferralBanners}: Ref const theme = useTheme(); const handleDismissCallToAction = () => { - User.dismissReferralBanner(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND); + User.dismissReferralBanner(referralContentType); }; if (!referralContentType || dismissedReferralBanners[referralContentType]) { diff --git a/src/pages/NewChatPage.js b/src/pages/NewChatPage.js index 44131de01fa6..71f8797f1a34 100755 --- a/src/pages/NewChatPage.js +++ b/src/pages/NewChatPage.js @@ -21,7 +21,6 @@ import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as ReportUtils from '@libs/ReportUtils'; import variables from '@styles/variables'; import * as Report from '@userActions/Report'; -import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import personalDetailsPropType from './personalDetailsPropType'; @@ -235,10 +234,6 @@ function NewChatPage({betas, isGroupChat, personalDetails, reports, translate, i updateOptions(); }, [didScreenTransitionEnd, updateOptions]); - const dismissCallToAction = (referralContentType) => { - User.dismissReferralBanner(referralContentType); - }; - const {inputCallbackRef} = useAutoFocusInput(); return ( @@ -276,7 +271,6 @@ function NewChatPage({betas, isGroupChat, personalDetails, reports, translate, i shouldShowConfirmButton shouldShowReferralCTA={!dismissedReferralBanners[CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT]} referralContentType={CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT} - onCallToActionClosed={dismissCallToAction} confirmButtonText={selectedOptions.length > 1 ? translate('newChatPage.createGroup') : translate('newChatPage.createChat')} textInputAlert={isOffline ? `${translate('common.youAppearToBeOffline')} ${translate('search.resultsAreLimited')}` : ''} onConfirmSelection={createGroup} diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index fe1f425a6d62..fd447ba377b1 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -19,7 +19,6 @@ import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as ReportUtils from '@libs/ReportUtils'; import reportPropTypes from '@pages/reportPropTypes'; -import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -88,7 +87,6 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({ const styles = useThemeStyles(); const [searchTerm, setSearchTerm] = useState(''); const referralContentType = iouType === CONST.IOU.TYPE.SEND ? CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY : CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST; - const [shouldShowReferralCTA, setShouldShowReferralCTA] = useState(!dismissedReferralBanners[referralContentType]); const {isOffline} = useNetwork(); const personalDetails = usePersonalDetails(); @@ -267,20 +265,12 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({ onFinish(); }, [shouldShowSplitBillErrorMessage, onFinish]); - const closeCallToActionBanner = useCallback(() => { - setShouldShowReferralCTA(false); - User.dismissReferralBanner(referralContentType); - }, [referralContentType]); - const footerContent = useMemo( () => ( - {shouldShowReferralCTA && ( + {!dismissedReferralBanners[referralContentType] && ( - + )} diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js index 944bad76c96b..2e21cae5ff10 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js @@ -18,7 +18,6 @@ import useThemeStyles from '@hooks/useThemeStyles'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import reportPropTypes from '@pages/reportPropTypes'; -import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -92,7 +91,6 @@ function MoneyRequestParticipantsSelector({ const styles = useThemeStyles(); const [searchTerm, setSearchTerm] = useState(''); const referralContentType = iouType === CONST.IOU.TYPE.SEND ? CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY : CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST; - const [shouldShowReferralCTA, setShouldShowReferralCTA] = useState(!dismissedReferralBanners[referralContentType]); const {isOffline} = useNetwork(); const personalDetails = usePersonalDetails(); @@ -283,20 +281,12 @@ function MoneyRequestParticipantsSelector({ navigateToSplit(); }, [shouldShowSplitBillErrorMessage, navigateToSplit]); - const closeCallToActionBanner = useCallback(() => { - setShouldShowReferralCTA(false); - User.dismissReferralBanner(referralContentType); - }, [referralContentType]); - const footerContent = useMemo( () => ( - {shouldShowReferralCTA && ( + {!dismissedReferralBanners[referralContentType] && ( - + )} From a2a2c85bf5dd0ee6ae19447de2465c62ccdff303 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 7 Feb 2024 20:36:45 +0100 Subject: [PATCH 2/4] Update useMemo dependencies --- .../MoneyTemporaryForRefactorRequestParticipantsSelector.js | 2 +- .../MoneyRequestParticipantsSelector.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index fd447ba377b1..f4377500721c 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -293,7 +293,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({ )} ), - [handleConfirmSelection, participants.length, referralContentType, shouldShowSplitBillErrorMessage, shouldShowReferralCTA, styles, translate, closeCallToActionBanner], + [handleConfirmSelection, participants.length, dismissedReferralBanners, referralContentType, shouldShowSplitBillErrorMessage, styles, translate], ); const itemRightSideComponent = useCallback( diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js index 2e21cae5ff10..7349b0c9fc84 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js @@ -309,7 +309,7 @@ function MoneyRequestParticipantsSelector({ )} ), - [handleConfirmSelection, participants.length, referralContentType, shouldShowSplitBillErrorMessage, shouldShowReferralCTA, styles, translate, closeCallToActionBanner], + [handleConfirmSelection, participants.length, dismissedReferralBanners, referralContentType, shouldShowSplitBillErrorMessage, styles, translate], ); const itemRightSideComponent = useCallback( From b65b3a8c89a27fdc473c1fd2b8a91b1ffc3c6abc Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 7 Feb 2024 20:44:43 +0100 Subject: [PATCH 3/4] Fix prettier issue --- src/components/OptionsSelector/BaseOptionsSelector.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index fee83d4f8230..e6806ea5c13e 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -646,9 +646,7 @@ class BaseOptionsSelector extends Component { {this.props.shouldShowReferralCTA && ( - + )} From 42db1fc89ef1e3be31ba4b6e670025334f55e91c Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 7 Feb 2024 21:20:25 +0100 Subject: [PATCH 4/4] Fix comments --- src/components/OptionsSelector/BaseOptionsSelector.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index e6806ea5c13e..bb1732ceb2f8 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -53,7 +53,6 @@ const propTypes = { const defaultProps = { shouldDelayFocus: false, shouldShowReferralCTA: false, - onCallToActionClosed: () => {}, referralContentType: CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND, safeAreaPaddingBottomStyle: {}, contentContainerStyles: [], @@ -69,7 +68,6 @@ class BaseOptionsSelector extends Component { this.updateFocusedIndex = this.updateFocusedIndex.bind(this); this.scrollToIndex = this.scrollToIndex.bind(this); this.selectRow = this.selectRow.bind(this); - this.closeReferralModal = this.closeReferralModal.bind(this); this.selectFocusedOption = this.selectFocusedOption.bind(this); this.addToSelection = this.addToSelection.bind(this); this.updateSearchValue = this.updateSearchValue.bind(this);