mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 06:56:59 +00:00
36 lines
939 B
TypeScript
36 lines
939 B
TypeScript
import React from 'react'
|
|
import { Rally, RallyCheckoutButtonConfig } from '@rallycommerce/checkout-button';
|
|
|
|
declare global {
|
|
namespace JSX {
|
|
interface IntrinsicElements {
|
|
'rally-checkout-button': any;
|
|
}
|
|
}
|
|
}
|
|
interface RallyCheckoutButtonProps {
|
|
customText?: string | undefined;
|
|
customClass?: string | undefined;
|
|
cart?: any;
|
|
}
|
|
|
|
const RallyCheckoutButton = (props: RallyCheckoutButtonProps) => {
|
|
const customClass = props.customClass || "rally-custom-button-class";
|
|
const cart = props?.cart;
|
|
|
|
if (cart) {
|
|
const configuration: RallyCheckoutButtonConfig = {
|
|
cartData: { content: cart, id: cart.id, currency: cart.currency }
|
|
};
|
|
|
|
Rally.init('clientId', configuration);
|
|
}
|
|
|
|
return (<>
|
|
{<rally-checkout-button suppressHydrationWarning={true} custom-class={customClass} custom-text={props.customText} loader="true">
|
|
</rally-checkout-button>}
|
|
</>)
|
|
}
|
|
|
|
export default RallyCheckoutButton;
|