Skip to content

Commit

Permalink
call 'setShowPromotionalBanner' on mount
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayisha committed Nov 5, 2024
1 parent 1add408 commit e5a72d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions client/settings/payment-settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const PaymentSettingsPanel = () => {
setShowPromotionalBanner={
setShowPromotionalBanner
}
setPromotionalBannerType={ () => {} }
isUpeEnabled={ isUpeEnabled }
setIsUpeEnabled={ setIsUpeEnabled }
isConnectedViaOAuth={ oauthConnected }
Expand Down
13 changes: 9 additions & 4 deletions client/settings/payment-settings/promotional-banner-section.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global wc_stripe_settings_params */
import { __ } from '@wordpress/i18n';
import { useDispatch } from '@wordpress/data';
import { React } from 'react';
import { React, useEffect } from 'react';
import { Card, Button, ExternalLink } from '@wordpress/components';
import styled from '@emotion/styled';
import interpolateComponents from 'interpolate-components';
Expand Down Expand Up @@ -74,6 +74,14 @@ const PromotionalBannerSection = ( {
const hasAPMEnabled =
enabledPaymentMethodIds.filter( ( e ) => e !== 'card' ).length > 0;

useEffect( () => {
if ( isConnectedViaOAuth === false ) {
setPromotionalBannerType( RECONNECT_BANNER );
} else if ( ! isUpeEnabled ) {
setPromotionalBannerType( NEW_CHECKOUT_EXPERIENCE_BANNER );
}
}, [ isUpeEnabled, isConnectedViaOAuth, setPromotionalBannerType ] );

const handleButtonClick = () => {
const callback = async () => {
try {
Expand Down Expand Up @@ -290,14 +298,11 @@ const PromotionalBannerSection = ( {

let BannerContent = null;
if ( isConnectedViaOAuth === false ) {
setPromotionalBannerType?.( RECONNECT_BANNER );
BannerContent = <ReConnectAccountBanner />;
} else if ( ! isUpeEnabled ) {
if ( hasAPMEnabled ) {
setPromotionalBannerType?.( NEW_CHECKOUT_EXPERIENCE_BANNER );
BannerContent = <NewCheckoutExperienceAPMsBanner />;
} else {
setPromotionalBannerType?.( NEW_CHECKOUT_EXPERIENCE_BANNER );
BannerContent = <NewCheckoutExperienceBanner />;
}
}
Expand Down

0 comments on commit e5a72d0

Please sign in to comment.