UNPKG

@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.

36 lines (35 loc) 1.91 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useEffect } from "react"; import { useSubscription } from "../hooks/useSubscription"; const PharosSubscription = (props) => { const pharosContractAddress = "0x8e5249a5C8d1a7107AABF7B03Ea2419aCB4d0197"; const pharCoinAddress = "0x8308135faA8E86B50Df94Aa54033d16784C1E98A"; const decimal = 6; const { payment, primaryColor, fontFamily, borderRadius, chainName } = props; const { state, resetState, handleCreateSubscription } = useSubscription(pharosContractAddress, pharCoinAddress, 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) && !state.networkError, 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 PharosSubscription;