mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
# Conflicts: # modules/ppcp-settings/resources/js/Components/App.js # modules/ppcp-settings/resources/js/Components/Screens/tabs.js
64 lines
1.6 KiB
JavaScript
64 lines
1.6 KiB
JavaScript
import { useEffect, useMemo } from '@wordpress/element';
|
|
import { __ } from '@wordpress/i18n';
|
|
import classNames from 'classnames';
|
|
|
|
import { OnboardingHooks, CommonHooks } from '../data';
|
|
import SpinnerOverlay from './ReusableComponents/SpinnerOverlay';
|
|
import SendOnlyMessage from './Screens/SendOnlyMessage';
|
|
import OnboardingScreen from './Screens/Onboarding';
|
|
import SettingsScreen from './Screens/Settings';
|
|
|
|
const SettingsApp = () => {
|
|
const onboardingProgress = OnboardingHooks.useSteps();
|
|
const {
|
|
isReady: merchantIsReady,
|
|
merchant: { isSendOnlyCountry },
|
|
} = CommonHooks.useMerchantInfo();
|
|
|
|
// Disable the "Changes you made might not be saved" browser warning.
|
|
useEffect( () => {
|
|
const suppressBeforeUnload = ( event ) => {
|
|
event.stopImmediatePropagation();
|
|
return undefined;
|
|
};
|
|
|
|
window.addEventListener( 'beforeunload', suppressBeforeUnload );
|
|
|
|
return () => {
|
|
window.removeEventListener( 'beforeunload', suppressBeforeUnload );
|
|
};
|
|
}, [] );
|
|
|
|
const wrapperClass = classNames( 'ppcp-r-app', {
|
|
loading: ! onboardingProgress.isReady,
|
|
} );
|
|
|
|
const Content = useMemo( () => {
|
|
if ( ! onboardingProgress.isReady || ! merchantIsReady ) {
|
|
return (
|
|
<SpinnerOverlay
|
|
message={ __( 'Loading…', 'woocommerce-paypal-payments' ) }
|
|
/>
|
|
);
|
|
}
|
|
|
|
if ( isSendOnlyCountry ) {
|
|
return <SendOnlyMessage />;
|
|
}
|
|
|
|
if ( ! onboardingProgress.completed ) {
|
|
return <OnboardingScreen />;
|
|
}
|
|
|
|
return <SettingsScreen />;
|
|
}, [
|
|
isSendOnlyCountry,
|
|
merchantIsReady,
|
|
onboardingProgress.completed,
|
|
onboardingProgress.isReady,
|
|
] );
|
|
|
|
return <div className={ wrapperClass }>{ Content }</div>;
|
|
};
|
|
|
|
export default SettingsApp;
|