@moveflow/widget
Version:
> ⚠️ **This is a testnet version** of the MoveFlow Checkout Widget. It is intended for development and testing purposes only. Do not use for mainnet payments.
35 lines (34 loc) • 1.88 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useEffect } from "react";
import { useSubscription } from "../hooks/useSubscription";
const LightLinkSubscriptionButton = (props) => {
const LightLinkContractAddress = "0x35A7B4067b2A652E19202264Cd9977451ab3a7dC";
const coinAddress = "0x1de55504baD55557728Dc914f35792278e0d9623";
const decimal = 18;
const { payment, primaryColor, fontFamily, borderRadius, chainName } = props;
const { state, resetState, handleCreateSubscription } = useSubscription(LightLinkContractAddress, coinAddress, decimal);
useEffect(() => {
resetState();
}, [payment]);
return (_jsxs("div", { children: [state.networkError && (_jsx("div", { style: { color: "red", marginBottom: "10px" }, children: state.networkError })), _jsx("button", { onClick: () => handleCreateSubscription(payment, chainName), disabled: state.isCreatingSubscription ||
state.tokensApproved ||
state.subscriptionCreated, style: {
width: "100%",
borderRadius: `${borderRadius}px`,
background: primaryColor,
color: "white",
fontFamily: fontFamily,
padding: "10px",
cursor: state.isCreatingSubscription ||
state.tokensApproved ||
state.subscriptionCreated
? "not-allowed"
: "pointer",
marginTop: "10px",
}, children: state.isCreatingSubscription
? "Creating Subscription..."
: state.subscriptionCreated
? "Subscription Created Successfully"
: "Create Subscription" })] }));
};
export default LightLinkSubscriptionButton;