diff --git a/build/index.asset.php b/build/index.asset.php index efba3b15..4d78b6bd 100644 --- a/build/index.asset.php +++ b/build/index.asset.php @@ -1 +1 @@ - array('lodash', 'moment', 'react', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '2594edd0d7eff5838e6c'); + array('lodash', 'moment', 'react', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '64d8ebf708a365ec7d39'); diff --git a/src/components/Paypal.js b/src/components/Paypal.js index d4e4ea4d..c948e7bc 100644 --- a/src/components/Paypal.js +++ b/src/components/Paypal.js @@ -15,137 +15,150 @@ import { ThirdPartyIntegration } from "./ThirdPartyIntegration"; const Paypal = ({ notify }) => { useEffect(() => { - const ppButton = document.querySelector(".yith-btn-paypal"); - window?.PAYPAL?.apps?.Signup?.loadScripts(document, "script"); - window?.PAYPAL?.apps?.Signup?.render(); + const ppButton = document.querySelector( ".yith-btn-paypal" ); + if( ppButton ){ + (function( d, s, id ) { + var js, ref = d.getElementsByTagName( s )[0]; + if ( !d.getElementById( id ) ) { + js = d.createElement( s ); + js.id = id; + js.async = true; + js.src = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js"; + ref.parentNode.insertBefore( js, ref ); + } + }( document, "script", "paypal-js" )); + window?.PAYPAL?.apps?.Signup?.loadScripts( document, "script" ); + window?.PAYPAL?.apps?.Signup?.render(); + } + return ()=>{ - const panel = document.querySelector('#payment-details'); + const panel = document.querySelector( '#payment-details' ); if( !panel && ppButton ){ ppButton.remove(); } }; }); return ( - - {({ integrationStatus, onConnect, isInstalling }) => { - const isSetupComplete = integrationStatus?.complete; - const environment = integrationStatus?.details?.environment; - return ( -
-
- - {isInstalling ? ( - - ) : isSetupComplete ? ( - - ) : typeof yith_ppwc_login !== "undefined" && - !parseInt(yith_ppwc_login?.liveConnected) ? ( - - {__("Connect", "wp-module-ecommerce")} - - ) : ( - - )} -
- {isSetupComplete && environment && ( -
- {__("Environment:", "wp-module-ecommerce")} - - {environment} - -
- )} - {!isSetupComplete && ( -
- - {__("Provides flexible checkout options", "wp-module-ecommerce")} - -
    -
  • {__("PayPal Buy Now Pay Later", "wp-module-ecommerce")}
  • -
  • {__("White-Labeling", "wp-module-ecommerce")}
  • -
  • - {__( - "Country-specific payment methods", - "wp-module-ecommerce" + + {({ integrationStatus, onConnect, isInstalling }) => { + const isSetupComplete = integrationStatus?.complete; + const environment = integrationStatus?.details?.environment; + return ( +
    +
    -
- - {__( - " Supports many popular payment methods", - "wp-module-ecommerce" + > + <PaypalBrand /> + {isInstalling ? ( + <Button + variant="secondary" + isLoading + className={classNames( + "max-[359px]:nfd-my-2", + "min-[360px]:nfd-m-0" + )} + > + {__("Installing...", "wp-module-ecommerce")} + </Button> + ) : isSetupComplete ? ( + <Button + variant="secondary" + as="a" + href={integrationStatus?.integration?.plugin?.url} + className={classNames( + "max-[359px]:nfd-my-2", + "min-[360px]:nfd-m-0" + )} + > + {__("Manage", "wp-module-ecommerce")} + </Button> + ) : typeof yith_ppwc_login !== "undefined" && + !parseInt(yith_ppwc_login?.liveConnected) ? ( + <Link + href={yith_ppwc_login.loginURL} + variant="primary" + className="nfd-button nfd-button--primary yith-btn-paypal nfd-text-white" + target="_blank" + data-paypal-onboard-complete="onboardedCallback" + data-paypal-button="PPLtBlue" + > + {__("Connect", "wp-module-ecommerce")} + </Link> + ) : ( + <Button + onClick={onConnect} + className={classNames( + "max-[359px]:nfd-my-2", + "min-[360px]:nfd-m-0" + )} + > + {__("Connect", "wp-module-ecommerce")} + </Button> )} - -
- - - - - - - -
+ {isSetupComplete && environment && ( +
+ {__("Environment:", "wp-module-ecommerce")} + + {environment} + +
+ )} + {!isSetupComplete && ( +
+ + {__("Provides flexible checkout options", "wp-module-ecommerce")} + +
    +
  • {__("PayPal Buy Now Pay Later", "wp-module-ecommerce")}
  • +
  • {__("White-Labeling", "wp-module-ecommerce")}
  • +
  • + {__( + "Country-specific payment methods", + "wp-module-ecommerce" + )} +
  • +
+ + {__( + " Supports many popular payment methods", + "wp-module-ecommerce" + )} + +
+ + + + + + + + +
+
+ )}
- )} -
- ); - }} -
+ ); + }} + ); }; export default Paypal; diff --git a/src/components/YITHPlugins.js b/src/components/YITHPlugins.js index 0d12ce9b..c482d387 100644 --- a/src/components/YITHPlugins.js +++ b/src/components/YITHPlugins.js @@ -88,17 +88,20 @@ export function YITHPlugins({ woo, wpModules }) { { refreshInterval: 10 * 1000, isPaused: () => !woo.isActive } ); const [yithProducts, setYithProducts] = useState([]); - useEffect(async () => { - const data = await apiFetch({ - url: NewfoldRuntime.createApiUrl("/newfold-marketplace/v1/marketplace"), - }); - setYithProducts( - data?.products?.data.filter( - (product) => - product.categories?.includes("eCommerce") && - product.categories?.length === 1 - ) - ); + useEffect( () => { + const fecthApi = async () => { + const data = await apiFetch({ + url: NewfoldRuntime.createApiUrl("/newfold-marketplace/v1/marketplace"), + }); + setYithProducts( + data?.products?.data.filter( + (product) => + product.categories?.includes("eCommerce") && + product.categories?.length === 1 + ) + ); + } + fecthApi() }, []); if (!woo.isActive) { return null;