UNPKG

@shopgate/engage

Version:
54 lines (53 loc) 1.29 kB
import React, { useEffect } from 'react'; import { css } from 'glamor'; import PropTypes from 'prop-types'; import { PayPalRiskCheck } from '@shopgate/native-modules'; import { useCheckoutContext } from "../../hooks/common"; import Button from "../../components/PaymentMethodButton"; import paypalLogoUrl from "./paypal_logo.png"; import { jsx as _jsx } from "react/jsx-runtime"; const styles = { logo: css({ width: '60%' }).toString() }; /** * @param {Object} props The component props * @returns {JSX} */ const PaypalButtonApp = props => { const { settings } = props; const { setLocked } = useCheckoutContext(); useEffect(() => { if (!settings) return; /** Async handler */ const handler = async () => { if (PayPalRiskCheck?.setup) { setLocked(true); try { await PayPalRiskCheck.setup(settings.env === 'sandbox'); } catch (e) { // } setLocked(false); } }; handler(); }, [setLocked, settings]); return /*#__PURE__*/_jsx(Button, { ...props, children: /*#__PURE__*/_jsx("img", { className: styles.logo, src: paypalLogoUrl, alt: "PayPal" }) }); }; PaypalButtonApp.defaultProps = { settings: null }; export default PaypalButtonApp;