@bowlos/reservations 0.35.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +300 -0
- package/HEADLESS.md +716 -11
- package/README.md +363 -2
- package/dist/{data-qw8P3JW3.d.cts → account-DEX2Lr78.d.cts} +218 -3
- package/dist/{data-qw8P3JW3.d.ts → account-DEX2Lr78.d.ts} +218 -3
- package/dist/booking-change-4DGu-B08.d.ts +1282 -0
- package/dist/booking-change-aK6P37FZ.d.cts +1282 -0
- package/dist/{chunk-UN5E6UEZ.js → chunk-44WKP6MW.js} +38 -7
- package/dist/chunk-44WKP6MW.js.map +1 -0
- package/dist/{chunk-MMSVM3QS.js → chunk-BWJHRJN6.js} +75 -187
- package/dist/chunk-BWJHRJN6.js.map +1 -0
- package/dist/{chunk-Y3YSDO3H.js → chunk-FMFHNBDH.js} +56 -5
- package/dist/chunk-FMFHNBDH.js.map +1 -0
- package/dist/chunk-I37IJNYU.js +139 -0
- package/dist/chunk-I37IJNYU.js.map +1 -0
- package/dist/chunk-VJIS56OO.js +717 -0
- package/dist/chunk-VJIS56OO.js.map +1 -0
- package/dist/{chunk-SMPDCDMB.js → chunk-YAXBZJMI.js} +3 -3
- package/dist/chunk-YAXBZJMI.js.map +1 -0
- package/dist/cli.cjs +34 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/components.cjs +1596 -4
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +208 -7
- package/dist/components.d.ts +208 -7
- package/dist/components.js +1046 -8
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +299 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -5
- package/dist/index.d.ts +56 -5
- package/dist/index.js +77 -5
- package/dist/index.js.map +1 -1
- package/dist/payments.cjs +203 -0
- package/dist/payments.cjs.map +1 -1
- package/dist/payments.d.cts +16 -2
- package/dist/payments.d.ts +16 -2
- package/dist/payments.js +78 -2
- package/dist/payments.js.map +1 -1
- package/dist/{react-C2V1kXnO.d.ts → react-CrRciA7I.d.ts} +2 -2
- package/dist/{react-DtncBQ3b.d.cts → react-QJrsaOnN.d.cts} +2 -2
- package/dist/react.cjs +801 -30
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +150 -7
- package/dist/react.d.ts +150 -7
- package/dist/react.js +72 -4
- package/dist/react.js.map +1 -1
- package/package.json +10 -3
- package/templates/center-site/README.md +5 -0
- package/templates/center-site/app/account/game-cards/page.tsx +17 -0
- package/templates/center-site/app/account/layout.tsx +16 -0
- package/templates/center-site/app/account/memberships/[id]/page.tsx +23 -0
- package/templates/center-site/app/account/memberships/page.tsx +33 -0
- package/templates/center-site/app/account/orders/page.tsx +17 -0
- package/templates/center-site/app/account/page.tsx +14 -0
- package/templates/center-site/app/account/payment-methods/page.tsx +23 -0
- package/templates/center-site/app/account/privacy/page.tsx +17 -0
- package/templates/center-site/app/account/profile/page.tsx +45 -0
- package/templates/center-site/app/account/reservations/[displayId]/change/page.tsx +46 -0
- package/templates/center-site/app/account/reservations/[displayId]/page.tsx +41 -0
- package/templates/center-site/app/account/reservations/page.tsx +35 -0
- package/templates/center-site/app/account/security/page.tsx +17 -0
- package/templates/center-site/app/book/page.tsx +11 -23
- package/templates/center-site/app/catalog/page.tsx +21 -12
- package/templates/center-site/app/events/[slug]/page.tsx +130 -0
- package/templates/center-site/app/events/page.tsx +57 -0
- package/templates/center-site/app/pay/[token]/page.tsx +53 -0
- package/templates/center-site/app/site-header.tsx +1 -0
- package/templates/center-site/lib/reservation.ts +14 -0
- package/templates/center-site/package.json +1 -1
- package/templates/center-site/tsconfig.json +7 -9
- package/dist/account-BJ5UjC0r.d.ts +0 -165
- package/dist/account-QoFg8-i1.d.cts +0 -165
- package/dist/catalog-CGitz1PG.d.ts +0 -221
- package/dist/catalog-p9cwB6Qv.d.cts +0 -221
- package/dist/chunk-MMSVM3QS.js.map +0 -1
- package/dist/chunk-SMPDCDMB.js.map +0 -1
- package/dist/chunk-UN5E6UEZ.js.map +0 -1
- package/dist/chunk-Y3YSDO3H.js.map +0 -1
package/dist/payments.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/payment-form.tsx"],"names":[],"mappings":";;;;;;AAuCA,IAAM,cAAA,GAA0C;AAAA,EAC9C,GAAA,EAAK,cAAA;AAAA,EACL,MAAA,EAAQ,cAAA;AAAA,EACR,YAAA,EAAc;AAChB,CAAA;AA2CO,SAAS,iBAAA,CAAkB;AAAA,EAChC,aAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA,GAAW,IAAA;AAAA,EACX,UAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,EAA2B;AAKzB,EAAA,MAAM,EAAA,GACJ,aAAA,CAAc,UAAA,KAAe,MAAA,IAAU,qBACnC,kBAAA,GACA,cAAA;AAGN,EAAA,MAAM,aAAA,GAAgB,OAAA;AAAA,IACpB,MAAM,UAAA,CAAW,EAAA,EAAI,EAAE,aAAA,EAAe,aAAA,CAAc,oBAAoB,CAAA;AAAA,IACxE,CAAC,EAAA,EAAI,aAAA,CAAc,kBAAkB;AAAA,GACvC;AAIA,EAAA,MAAM,2BAAA,GACJ,QAAA,IAAY,aAAA,CAAc,2BAAA,GACtB,cAAc,2BAAA,GACd,MAAA;AAEN,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,MAAA,EAAQ,aAAA;AAAA,MACR,SAAS,EAAE,YAAA,EAAc,aAAA,CAAc,YAAA,EAAc,6BAA6B,UAAA,EAAW;AAAA,MAE7F,QAAA,kBAAA,GAAA;AAAA,QAAC,OAAA;AAAA,QAAA;AAAA,UACC,MAAA;AAAA,UACA,OAAA;AAAA,UACA,WAAA;AAAA,UACA,MAAA;AAAA,UACA;AAAA;AAAA;AACF;AAAA,GACF;AAEJ;AAEA,S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AAU,cAAc,SAAA,EAAsB,KAAA,EAAO,EAAE,KAAA,EAC3D,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,cAAA,EAAA,EAAe,CAAA;AAAA,oBAIhB,GAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACC,IAAA,EAAK,QAAA;AAAA,QACL,OAAO,CAAA,CAAE,UAAA;AAAA,QACT,QAAA,EAAU,CAAC,MAAA,IAAU,CAAC,QAAA,IAAY,UAAA;AAAA,QAEjC,QAAA,EAAA,UAAA,GAAa,EAAE,MAAA,GAAS;AAAA;AAAA,KAC3B;AAAA,IACC,OAAA,wBACE,GAAA,EAAA,EAAE,IAAA,EAAK,SAAQ,KAAA,EAAO,CAAA,CAAE,OACtB,QAAA,EAAA,OAAA,EACH;AAAA,GAAA,EAEJ,CAAA;AAEJ","file":"payments.js","sourcesContent":["\"use client\";\n/**\n * `<BowlosPaymentForm>` — the drop-in Stripe Connect checkout for `<BookingFlow>`.\n *\n * This is the ONE part of the SDK that loads Stripe.js, so it lives in its own\n * entry (`@bowlos/reservations/payments`) and Stripe is an OPTIONAL peer — the\n * core + components bundles never pull it. Wire it into `<BookingFlow>`'s\n * `renderPayment` slot and you never hand-build a Stripe Elements form per site:\n *\n * ```tsx\n * import { BowlosPaymentForm } from \"@bowlos/reservations/payments\";\n *\n * <BookingFlow\n * renderPayment={(ctx) => (\n * <BowlosPaymentForm {...ctx} publishableKey={process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY!} />\n * )}\n * />\n * ```\n *\n * It initializes Stripe.js with the PLATFORM publishable key scoped to the\n * operator's CONNECTED account (`stripeAccount: connectedAccountId`), so the\n * charge lands directly on the operator's Stripe account (their name on the\n * statement/receipt — the white-label requirement). Saved cards + \"save for\n * future\" are enabled by default via the booking's customer session.\n */\nimport { useMemo, useState, type FormEvent } from \"react\";\nimport { loadStripe, type Appearance } from \"@stripe/stripe-js\";\nimport { Elements, PaymentElement, useElements, useStripe } from \"@stripe/react-stripe-js\";\nimport type { ConnectedPaymentInput } from \"../data\";\nimport { formatCents, styles } from \"./shared\";\n\n/** Visible strings — override any subset for copy/i18n. */\nexport interface BowlosPaymentFormLabels {\n /** Button when idle. `{amount}` (if present) is replaced with the formatted total. */\n pay: string;\n paying: string;\n genericError: string;\n}\n\nconst DEFAULT_LABELS: BowlosPaymentFormLabels = {\n pay: \"Pay {amount}\",\n paying: \"Paying…\",\n genericError: \"Payment failed — please try again.\",\n};\n\nexport interface BowlosPaymentFormProps {\n /** The Connect payment to confirm — a booking's `PaymentIntentInfo`, a buy\n * flow's intent, or a subscription's first-invoice client secret. Any value\n * with `{ clientSecret, connectedAccountId, customerSessionClientSecret? }`. */\n paymentIntent: ConnectedPaymentInput;\n /** Your PLATFORM publishable key (browser-safe; e.g. `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY`).\n * Used for live PaymentIntents (and as the sole key when `testPublishableKey`\n * is omitted — fully back-compatible with one-key sites). */\n publishableKey: string;\n /** Full Test Mode (2026-06-23): your platform TEST publishable key\n * (`pk_test_…`). When the PaymentIntent's `stripeMode` is \"test\" (an admin\n * Test-Account customer, or a Center in Full Test Mode), the form loads THIS\n * key instead of `publishableKey` — so a live site can confirm test PIs\n * concurrently. Omit it and the form always uses `publishableKey`. */\n testPublishableKey?: string;\n /** Called once the PaymentIntent confirms — start polling for the reservation. */\n onPaid: () => void;\n /** Called with a human-readable message when confirmation fails. */\n onError?: (message: string) => void;\n /** Total, for the button label (\"Pay $45.00\"). Omit to show a plain \"Pay\". */\n amountCents?: number;\n /**\n * Enable saved cards + a \"save for future\" option via the booking's customer\n * session (when the gateway provided one). Default `true`. Set `false` for a\n * one-off charge with no card on file.\n */\n saveCard?: boolean;\n /**\n * Stripe Elements appearance — theme the Payment Element to match your site\n * (e.g. `{ theme: \"night\", variables: { colorPrimary: \"#FFD500\" } }`). Without\n * it Stripe renders its default light theme, which looks off on a dark site.\n */\n appearance?: Appearance;\n labels?: Partial<BowlosPaymentFormLabels>;\n className?: string;\n}\n\n/**\n * The Stripe Connect payment form. Renders the Payment Element scoped to the\n * operator's connected account and confirms the PaymentIntent on submit.\n */\nexport function BowlosPaymentForm({\n paymentIntent,\n publishableKey,\n testPublishableKey,\n onPaid,\n onError,\n amountCents,\n saveCard = true,\n appearance,\n labels,\n className,\n}: BowlosPaymentFormProps) {\n // Pick the publishable key matching the PaymentIntent's Stripe environment: a\n // test PI (Full Test Mode / Test-Account customer) confirms only with the test\n // key, a live PI only with the live key. Falls back to `publishableKey` when no\n // test key is supplied (one-key sites — unchanged behavior).\n const pk =\n paymentIntent.stripeMode === \"test\" && testPublishableKey\n ? testPublishableKey\n : publishableKey;\n // Platform key, scoped to the operator's connected account → the charge is\n // created directly on their Stripe account (white-label receipt/statement).\n const stripePromise = useMemo(\n () => loadStripe(pk, { stripeAccount: paymentIntent.connectedAccountId }),\n [pk, paymentIntent.connectedAccountId],\n );\n\n // Pass the customer session only when present + opted-in, so the Payment\n // Element can offer saved cards / \"save for future\" for this operator.\n const customerSessionClientSecret =\n saveCard && paymentIntent.customerSessionClientSecret\n ? paymentIntent.customerSessionClientSecret\n : undefined;\n\n return (\n <Elements\n stripe={stripePromise}\n options={{ clientSecret: paymentIntent.clientSecret, customerSessionClientSecret, appearance }}\n >\n <PayForm\n onPaid={onPaid}\n onError={onError}\n amountCents={amountCents}\n labels={labels}\n className={className}\n />\n </Elements>\n );\n}\n\nfunction PayForm({\n onPaid,\n onError,\n amountCents,\n labels,\n className,\n}: {\n onPaid: () => void;\n onError?: (message: string) => void;\n amountCents?: number;\n labels?: Partial<BowlosPaymentFormLabels>;\n className?: string;\n}) {\n const t = { ...DEFAULT_LABELS, ...labels };\n const stripe = useStripe();\n const elements = useElements();\n const [submitting, setSubmitting] = useState(false);\n const [message, setMessage] = useState<string | null>(null);\n const s = styles();\n\n async function handleSubmit(e: FormEvent) {\n e.preventDefault();\n if (!stripe || !elements) return;\n setSubmitting(true);\n setMessage(null);\n\n // `redirect: \"if_required\"` keeps card payments on-page; wallets that need\n // a redirect still work.\n const { error } = await stripe.confirmPayment({ elements, redirect: \"if_required\" });\n\n if (error) {\n const m = error.message ?? t.genericError;\n setMessage(m);\n onError?.(m);\n setSubmitting(false);\n return;\n }\n\n // Paid. The gateway's Stripe webhook materializes the reservation\n // asynchronously, so hand control back so the flow can poll for it.\n onPaid();\n }\n\n const payLabel = t.pay.replace(\"{amount}\", amountCents != null ? formatCents(amountCents) : \"\").trim();\n\n return (\n <form onSubmit={handleSubmit} className={className} style={s.stack}>\n <PaymentElement />\n {/* v0.22.1: include !elements — the submit handler bails on a not-yet-\n mounted PaymentElement, so a click during mount was a silent no-op\n (the \"first click does nothing\" race a center site reproduced). */}\n <button\n type=\"submit\"\n style={s.primaryBtn}\n disabled={!stripe || !elements || submitting}\n >\n {submitting ? t.paying : payLabel}\n </button>\n {message && (\n <p role=\"alert\" style={s.error}>\n {message}\n </p>\n )}\n </form>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/payment-form.tsx","../src/components/add-card-form.tsx"],"names":["useState","useMemo","loadStripe","jsxs","jsx","Elements","useStripe","useElements","PaymentElement"],"mappings":";;;;;;;;AAuCA,IAAM,cAAA,GAA0C;AAAA,EAC9C,GAAA,EAAK,cAAA;AAAA,EACL,MAAA,EAAQ,cAAA;AAAA,EACR,YAAA,EAAc;AAChB,CAAA;AA2CO,SAAS,iBAAA,CAAkB;AAAA,EAChC,aAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA,GAAW,IAAA;AAAA,EACX,UAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,EAA2B;AAKzB,EAAA,MAAM,EAAA,GACJ,aAAA,CAAc,UAAA,KAAe,MAAA,IAAU,qBACnC,kBAAA,GACA,cAAA;AAGN,EAAA,MAAM,aAAA,GAAgB,OAAA;AAAA,IACpB,MAAM,UAAA,CAAW,EAAA,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,CAAO;AAAA;AAAA;AAAA,GACV;AAEJ","file":"payments.js","sourcesContent":["\"use client\";\n/**\n * `<BowlosPaymentForm>` — the drop-in Stripe Connect checkout for `<BookingFlow>`.\n *\n * This is the ONE part of the SDK that loads Stripe.js, so it lives in its own\n * entry (`@bowlos/reservations/payments`) and Stripe is an OPTIONAL peer — the\n * core + components bundles never pull it. Wire it into `<BookingFlow>`'s\n * `renderPayment` slot and you never hand-build a Stripe Elements form per site:\n *\n * ```tsx\n * import { BowlosPaymentForm } from \"@bowlos/reservations/payments\";\n *\n * <BookingFlow\n * renderPayment={(ctx) => (\n * <BowlosPaymentForm {...ctx} publishableKey={process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY!} />\n * )}\n * />\n * ```\n *\n * It initializes Stripe.js with the PLATFORM publishable key scoped to the\n * operator's CONNECTED account (`stripeAccount: connectedAccountId`), so the\n * charge lands directly on the operator's Stripe account (their name on the\n * statement/receipt — the white-label requirement). Saved cards + \"save for\n * future\" are enabled by default via the booking's customer session.\n */\nimport { useMemo, useState, type FormEvent } from \"react\";\nimport { loadStripe, type Appearance } from \"@stripe/stripe-js\";\nimport { Elements, PaymentElement, useElements, useStripe } from \"@stripe/react-stripe-js\";\nimport type { ConnectedPaymentInput } from \"../data\";\nimport { formatCents, styles } from \"./shared\";\n\n/** Visible strings — override any subset for copy/i18n. */\nexport interface BowlosPaymentFormLabels {\n /** Button when idle. `{amount}` (if present) is replaced with the formatted total. */\n pay: string;\n paying: string;\n genericError: string;\n}\n\nconst DEFAULT_LABELS: BowlosPaymentFormLabels = {\n pay: \"Pay {amount}\",\n paying: \"Paying…\",\n genericError: \"Payment failed — please try again.\",\n};\n\nexport interface BowlosPaymentFormProps {\n /** The Connect payment to confirm — a booking's `PaymentIntentInfo`, a buy\n * flow's intent, or a subscription's first-invoice client secret. Any value\n * with `{ clientSecret, connectedAccountId, customerSessionClientSecret? }`. */\n paymentIntent: ConnectedPaymentInput;\n /** Your PLATFORM publishable key (browser-safe; e.g. `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY`).\n * Used for live PaymentIntents (and as the sole key when `testPublishableKey`\n * is omitted — fully back-compatible with one-key sites). */\n publishableKey: string;\n /** Full Test Mode (2026-06-23): your platform TEST publishable key\n * (`pk_test_…`). When the PaymentIntent's `stripeMode` is \"test\" (an admin\n * Test-Account customer, or a Center in Full Test Mode), the form loads THIS\n * key instead of `publishableKey` — so a live site can confirm test PIs\n * concurrently. Omit it and the form always uses `publishableKey`. */\n testPublishableKey?: string;\n /** Called once the PaymentIntent confirms — start polling for the reservation. */\n onPaid: () => void;\n /** Called with a human-readable message when confirmation fails. */\n onError?: (message: string) => void;\n /** Total, for the button label (\"Pay $45.00\"). Omit to show a plain \"Pay\". */\n amountCents?: number;\n /**\n * Enable saved cards + a \"save for future\" option via the booking's customer\n * session (when the gateway provided one). Default `true`. Set `false` for a\n * one-off charge with no card on file.\n */\n saveCard?: boolean;\n /**\n * Stripe Elements appearance — theme the Payment Element to match your site\n * (e.g. `{ theme: \"night\", variables: { colorPrimary: \"#FFD500\" } }`). Without\n * it Stripe renders its default light theme, which looks off on a dark site.\n */\n appearance?: Appearance;\n labels?: Partial<BowlosPaymentFormLabels>;\n className?: string;\n}\n\n/**\n * The Stripe Connect payment form. Renders the Payment Element scoped to the\n * operator's connected account and confirms the PaymentIntent on submit.\n */\nexport function BowlosPaymentForm({\n paymentIntent,\n publishableKey,\n testPublishableKey,\n onPaid,\n onError,\n amountCents,\n saveCard = true,\n appearance,\n labels,\n className,\n}: BowlosPaymentFormProps) {\n // Pick the publishable key matching the PaymentIntent's Stripe environment: a\n // test PI (Full Test Mode / Test-Account customer) confirms only with the test\n // key, a live PI only with the live key. Falls back to `publishableKey` when no\n // test key is supplied (one-key sites — unchanged behavior).\n const pk =\n paymentIntent.stripeMode === \"test\" && testPublishableKey\n ? testPublishableKey\n : publishableKey;\n // Platform key, scoped to the operator's connected account → the charge is\n // created directly on their Stripe account (white-label receipt/statement).\n const stripePromise = useMemo(\n () => loadStripe(pk, { stripeAccount: paymentIntent.connectedAccountId }),\n [pk, paymentIntent.connectedAccountId],\n );\n\n // Pass the customer session only when present + opted-in, so the Payment\n // Element can offer saved cards / \"save for future\" for this operator.\n const customerSessionClientSecret =\n saveCard && paymentIntent.customerSessionClientSecret\n ? paymentIntent.customerSessionClientSecret\n : undefined;\n\n return (\n <Elements\n stripe={stripePromise}\n options={{ clientSecret: paymentIntent.clientSecret, customerSessionClientSecret, appearance }}\n >\n <PayForm\n onPaid={onPaid}\n onError={onError}\n amountCents={amountCents}\n labels={labels}\n className={className}\n />\n </Elements>\n );\n}\n\nfunction PayForm({\n onPaid,\n onError,\n amountCents,\n labels,\n className,\n}: {\n onPaid: () => void;\n onError?: (message: string) => void;\n amountCents?: number;\n labels?: Partial<BowlosPaymentFormLabels>;\n className?: string;\n}) {\n const t = { ...DEFAULT_LABELS, ...labels };\n const stripe = useStripe();\n const elements = useElements();\n const [submitting, setSubmitting] = useState(false);\n const [message, setMessage] = useState<string | null>(null);\n const s = styles();\n\n async function handleSubmit(e: FormEvent) {\n e.preventDefault();\n if (!stripe || !elements) return;\n setSubmitting(true);\n setMessage(null);\n\n // `redirect: \"if_required\"` keeps card payments on-page; wallets that need\n // a redirect still work.\n const { error } = await stripe.confirmPayment({ elements, redirect: \"if_required\" });\n\n if (error) {\n const m = error.message ?? t.genericError;\n setMessage(m);\n onError?.(m);\n setSubmitting(false);\n return;\n }\n\n // Paid. The gateway's Stripe webhook materializes the reservation\n // asynchronously, so hand control back so the flow can poll for it.\n onPaid();\n }\n\n const payLabel = t.pay.replace(\"{amount}\", amountCents != null ? formatCents(amountCents) : \"\").trim();\n\n return (\n <form onSubmit={handleSubmit} className={className} style={s.stack}>\n <PaymentElement />\n {/* v0.22.1: include !elements — the submit handler bails on a not-yet-\n mounted PaymentElement, so a click during mount was a silent no-op\n (the \"first click does nothing\" race a center site reproduced). */}\n <button\n type=\"submit\"\n style={s.primaryBtn}\n disabled={!stripe || !elements || submitting}\n >\n {submitting ? t.paying : payLabel}\n </button>\n {message && (\n <p role=\"alert\" style={s.error}>\n {message}\n </p>\n )}\n </form>\n );\n}\n","\"use client\";\nimport { useMemo, useState } from \"react\";\nimport { loadStripe, type Appearance } from \"@stripe/stripe-js\";\nimport { Elements, PaymentElement, useElements, useStripe } from \"@stripe/react-stripe-js\";\nimport { useCreateCardSetup } from \"../hooks\";\nimport type { CardSetupResult, SavedCardScope } from \"../account\";\nimport { AccountPanel, useAccountAction } from \"./account-shared\";\nimport { styles } from \"./shared\";\nexport interface AddCardFormProps extends SavedCardScope {\n onAdded?: () => void;\n appearance?: Appearance;\n labels?: Partial<{ title: string; start: string; save: string; saved: string; error: string }>;\n className?: string;\n}\nexport function AddCardForm({\n brandId,\n centerId,\n onAdded,\n appearance,\n labels,\n className,\n}: AddCardFormProps) {\n const t = {\n title: \"Add a card\",\n start: \"Add card\",\n save: \"Save card\",\n saved: \"Card saved.\",\n error: \"Unable to save this card.\",\n ...labels,\n };\n const setup = useCreateCardSetup();\n const action = useAccountAction();\n const [intent, setIntent] = useState<CardSetupResult>();\n const stripe = useMemo(\n () =>\n intent ? loadStripe(intent.publishableKey, { stripeAccount: intent.stripeAccount }) : null,\n [intent],\n );\n return (\n <AccountPanel title={t.title} className={className}>\n {!intent ? (\n <button\n style={styles().primaryBtn}\n disabled={action.busy}\n onClick={() =>\n void action.run(async () => setIntent(await setup.run({ brandId, centerId })))\n }\n >\n {t.start}\n </button>\n ) : (\n <Elements stripe={stripe} options={{ clientSecret: intent.clientSecret, appearance }}>\n <SetupForm\n labels={t}\n onAdded={() => {\n setIntent(undefined);\n onAdded?.();\n }}\n />\n </Elements>\n )}\n {action.feedback}\n </AccountPanel>\n );\n}\nfunction SetupForm({\n labels,\n onAdded,\n}: {\n labels: { save: string; saved: string; error: string };\n onAdded: () => void;\n}) {\n const stripe = useStripe();\n const elements = useElements();\n const action = useAccountAction();\n return (\n <form\n style={styles().stack}\n onSubmit={(e) => {\n e.preventDefault();\n if (!stripe || !elements) return;\n void action.run(async () => {\n const result = await stripe.confirmSetup({ elements, redirect: \"if_required\" });\n if (result.error) throw new Error(result.error.message ?? labels.error);\n if (result.setupIntent?.status !== \"succeeded\") throw new Error(labels.error);\n onAdded();\n }, labels.saved);\n }}\n >\n <PaymentElement />\n <button style={styles().primaryBtn} disabled={!stripe || !elements || action.busy}>\n {labels.save}\n </button>\n {action.feedback}\n </form>\n );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { A as AuthState,
|
|
4
|
-
import {
|
|
3
|
+
import { A as AuthState, B as BowlosClient, h as BowlosClientConfig, r as Customer, O as LinkProfile } from './account-DEX2Lr78.js';
|
|
4
|
+
import { as as BowlosApiError } from './booking-change-4DGu-B08.js';
|
|
5
5
|
|
|
6
6
|
interface BowlosProviderProps {
|
|
7
7
|
/** A prebuilt client, or pass `config` to have one created and memoized. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { A as AuthState,
|
|
4
|
-
import {
|
|
3
|
+
import { A as AuthState, B as BowlosClient, h as BowlosClientConfig, r as Customer, O as LinkProfile } from './account-DEX2Lr78.cjs';
|
|
4
|
+
import { as as BowlosApiError } from './booking-change-aK6P37FZ.cjs';
|
|
5
5
|
|
|
6
6
|
interface BowlosProviderProps {
|
|
7
7
|
/** A prebuilt client, or pass `config` to have one created and memoized. */
|