import {PaymentDetails} from "../typings/wc-types";
import StitchExpressLabel from "./StitchExpressLabel";
import StitchExpressPaymentMethod from "./StitchExpressPaymentMethod";

const {registerPaymentMethod} = window.wc.wcBlocksRegistry;

registerPaymentMethod({
    // @ts-expect-error Props are passed at a separate time
    label: <StitchExpressLabel />,
    ariaLabel: 'Pay with Stitch Express',
    // @ts-expect-error Props are passed at a separate time
    content: <StitchExpressPaymentMethod />,
    // @ts-expect-error Props are passed at a separate time
    edit: <StitchExpressPaymentMethod />,
    name: 'stitch-express',
    canMakePayment(paymentDetails: PaymentDetails) {
        const {currency_code, total_price} = paymentDetails.cartTotals;
        return currency_code === 'ZAR' && parseInt(total_price, 10) >= 500;
    },
    supports: {
        features: ['products', 'refunds'],
    },
    placeOrderButtonLabel: 'Pay'
})
