@funnelsgrove/cli 0.1.14 → 0.1.18
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/contracts/step-contract-v2.json +733 -0
- package/dist/analyticsOutput.d.ts +30 -15
- package/dist/analyticsOutput.js +45 -28
- package/dist/apiClient.d.ts +85 -0
- package/dist/apiClient.js +225 -8
- package/dist/cli.d.ts +149 -1
- package/dist/cli.js +1232 -71
- package/dist/diagnosticOutput.d.ts +42 -0
- package/dist/diagnosticOutput.js +83 -0
- package/dist/docsOutput.d.ts +19 -0
- package/dist/docsOutput.js +73 -0
- package/dist/docsTransaction.d.ts +81 -0
- package/dist/docsTransaction.js +1755 -0
- package/dist/funnelValidation.d.ts +14 -0
- package/dist/funnelValidation.js +297 -0
- package/dist/localSync.d.ts +79 -0
- package/dist/localSync.js +428 -53
- package/dist/projectValidator.d.ts +27 -0
- package/dist/projectValidator.js +208 -0
- package/dist/reskin.js +27 -1
- package/dist/stepContractMigration.d.ts +71 -0
- package/dist/stepContractMigration.js +1323 -0
- package/dist/templateDocs.js +8 -25
- package/docs-release-history.json +66 -0
- package/legacy-docs-catalog.json +1012 -0
- package/package.json +13 -4
- package/template_docs/.funnelsgrove-docs.json +144 -0
- package/template_docs/AGENTS.md +30 -58
- package/template_docs/CLAUDE.md +0 -2
- package/template_docs/docs/funnelsgrove/START-HERE.md +73 -0
- package/template_docs/docs/funnelsgrove/contracts/analytics-events.md +59 -0
- package/template_docs/docs/funnelsgrove/contracts/content-answers.md +44 -0
- package/template_docs/docs/funnelsgrove/contracts/flow-routing.md +41 -0
- package/template_docs/docs/funnelsgrove/contracts/payments.md +42 -0
- package/template_docs/docs/funnelsgrove/contracts/step-metadata.md +57 -0
- package/template_docs/docs/funnelsgrove/migrations/step-contract-v3.md +39 -0
- package/template_docs/docs/funnelsgrove/qa/analytics.md +43 -0
- package/template_docs/docs/funnelsgrove/qa/local.md +42 -0
- package/template_docs/docs/funnelsgrove/qa/paywall-checkout.md +55 -0
- package/template_docs/docs/funnelsgrove/qa/publish.md +32 -0
- package/template_docs/docs/funnelsgrove/recipes/add-experiment.md +34 -0
- package/template_docs/docs/funnelsgrove/recipes/add-step.md +33 -0
- package/template_docs/docs/funnelsgrove/recipes/edit-step.md +31 -0
- package/template_docs/docs/funnelsgrove/steps/INDEX.md +26 -0
- package/template_docs/docs/funnelsgrove/steps/cancellation_offer.md +112 -0
- package/template_docs/docs/funnelsgrove/steps/checkout.md +120 -0
- package/template_docs/docs/funnelsgrove/steps/form_input.md +115 -0
- package/template_docs/docs/funnelsgrove/steps/intro_hero.md +110 -0
- package/template_docs/docs/funnelsgrove/steps/multi_select_choice.md +123 -0
- package/template_docs/docs/funnelsgrove/steps/paywall_offer.md +115 -0
- package/template_docs/docs/funnelsgrove/steps/progress_interstitial.md +111 -0
- package/template_docs/docs/funnelsgrove/steps/purchase_completed.md +117 -0
- package/template_docs/docs/funnelsgrove/steps/single_step_choice.md +122 -0
- package/template_docs/docs/funnelsgrove/steps/single_step_choice_emoji.md +122 -0
- package/template_docs/docs/funnelsgrove/steps/social_proof.md +110 -0
- package/template_docs/docs/funnelsgrove/steps/subscription_handoff.md +113 -0
- package/template_docs/docs/funnelsgrove/steps/subscription_management.md +112 -0
- package/template_docs/docs/funnelsgrove/steps/summary_confirmation.md +110 -0
- package/template_docs/docs/funnelsgrove/steps/upsell_offer.md +112 -0
- package/template_docs/docs/funnelsgrove/steps/value_prop_story.md +110 -0
- package/template_docs/funnel-docs.config.json +43 -0
- package/template_scaffold/.env.example +41 -0
- package/template_scaffold/.funnelsgrove-contract-tools.json +19 -0
- package/template_scaffold/.funnelsgrove-docs.json +144 -0
- package/template_scaffold/.funnelsgrove-scaffold.json +1078 -0
- package/template_scaffold/AGENTS.md +42 -0
- package/template_scaffold/CLAUDE.md +1 -0
- package/template_scaffold/PLAN.md +81 -0
- package/template_scaffold/PRODUCT_SENSE.md +28 -0
- package/template_scaffold/context/build-context.md +34 -0
- package/template_scaffold/docs/AGENT_FUNNEL_IMPLEMENTATION_SPEC.md +5 -0
- package/template_scaffold/docs/ARCHITECTURE.md +5 -0
- package/template_scaffold/docs/FLOW_CONFIG_AND_ROUTING.md +5 -0
- package/template_scaffold/docs/PAYWALL_AND_PAYMENTS.md +5 -0
- package/template_scaffold/docs/README.md +5 -0
- package/template_scaffold/docs/funnelsgrove/START-HERE.md +73 -0
- package/template_scaffold/docs/funnelsgrove/contracts/analytics-events.md +59 -0
- package/template_scaffold/docs/funnelsgrove/contracts/content-answers.md +44 -0
- package/template_scaffold/docs/funnelsgrove/contracts/flow-routing.md +41 -0
- package/template_scaffold/docs/funnelsgrove/contracts/payments.md +42 -0
- package/template_scaffold/docs/funnelsgrove/contracts/step-metadata.md +57 -0
- package/template_scaffold/docs/funnelsgrove/migrations/step-contract-v3.md +39 -0
- package/template_scaffold/docs/funnelsgrove/qa/analytics.md +43 -0
- package/template_scaffold/docs/funnelsgrove/qa/local.md +42 -0
- package/template_scaffold/docs/funnelsgrove/qa/paywall-checkout.md +55 -0
- package/template_scaffold/docs/funnelsgrove/qa/publish.md +32 -0
- package/template_scaffold/docs/funnelsgrove/recipes/add-experiment.md +34 -0
- package/template_scaffold/docs/funnelsgrove/recipes/add-step.md +33 -0
- package/template_scaffold/docs/funnelsgrove/recipes/edit-step.md +31 -0
- package/template_scaffold/docs/funnelsgrove/steps/INDEX.md +26 -0
- package/template_scaffold/docs/funnelsgrove/steps/cancellation_offer.md +112 -0
- package/template_scaffold/docs/funnelsgrove/steps/checkout.md +120 -0
- package/template_scaffold/docs/funnelsgrove/steps/form_input.md +115 -0
- package/template_scaffold/docs/funnelsgrove/steps/intro_hero.md +110 -0
- package/template_scaffold/docs/funnelsgrove/steps/multi_select_choice.md +123 -0
- package/template_scaffold/docs/funnelsgrove/steps/paywall_offer.md +115 -0
- package/template_scaffold/docs/funnelsgrove/steps/progress_interstitial.md +111 -0
- package/template_scaffold/docs/funnelsgrove/steps/purchase_completed.md +117 -0
- package/template_scaffold/docs/funnelsgrove/steps/single_step_choice.md +122 -0
- package/template_scaffold/docs/funnelsgrove/steps/single_step_choice_emoji.md +122 -0
- package/template_scaffold/docs/funnelsgrove/steps/social_proof.md +110 -0
- package/template_scaffold/docs/funnelsgrove/steps/subscription_handoff.md +113 -0
- package/template_scaffold/docs/funnelsgrove/steps/subscription_management.md +112 -0
- package/template_scaffold/docs/funnelsgrove/steps/summary_confirmation.md +110 -0
- package/template_scaffold/docs/funnelsgrove/steps/upsell_offer.md +112 -0
- package/template_scaffold/docs/funnelsgrove/steps/value_prop_story.md +110 -0
- package/template_scaffold/docs/references/funnel-sdk-user-answers.md +5 -0
- package/template_scaffold/eslint.config.mjs +16 -0
- package/template_scaffold/funnel-agent-docs.test.ts +699 -0
- package/template_scaffold/funnel-docs.config.json +43 -0
- package/template_scaffold/funnel.config.json +5 -0
- package/template_scaffold/gitignore.template +5 -0
- package/template_scaffold/next-env.d.ts +6 -0
- package/template_scaffold/next.config.ts +53 -0
- package/template_scaffold/package-lock.json +7737 -0
- package/template_scaffold/package.json +37 -0
- package/template_scaffold/package.test.ts +23 -0
- package/template_scaffold/public/claimbee/bee.png +0 -0
- package/template_scaffold/public/claimbee/device-iphone.png +0 -0
- package/template_scaffold/public/claimbee/device-macbook.png +0 -0
- package/template_scaffold/public/claimbee/device-none.png +0 -0
- package/template_scaffold/public/claimbee/device-watch.png +0 -0
- package/template_scaffold/public/claimbee/glow.svg +3 -0
- package/template_scaffold/public/claimbee/steps-sprite-alt.png +0 -0
- package/template_scaffold/public/claimbee/steps-sprite-default.png +0 -0
- package/template_scaffold/public/claimbee/testimonial-avatar.png +0 -0
- package/template_scaffold/public/claimbee/testimonial-star.svg +3 -0
- package/template_scaffold/public/paywall/ai-claim-assistant.png +0 -0
- package/template_scaffold/public/paywall/claim-history.png +0 -0
- package/template_scaffold/public/paywall/clear-progress.png +0 -0
- package/template_scaffold/public/paywall/hero.png +0 -0
- package/template_scaffold/public/paywall/money-alerts.png +0 -0
- package/template_scaffold/public/paywall/money-back-badge.png +0 -0
- package/template_scaffold/public/paywall/paywall-image.png +0 -0
- package/template_scaffold/public/paywall/r1.png +0 -0
- package/template_scaffold/public/paywall/r2.png +0 -0
- package/template_scaffold/public/paywall/r3.png +0 -0
- package/template_scaffold/public/paywall/r4.png +0 -0
- package/template_scaffold/public/paywall/r5.png +0 -0
- package/template_scaffold/public/paywall/r6.png +0 -0
- package/template_scaffold/public/paywall/special-offer-gift.png +0 -0
- package/template_scaffold/public/please/bee.png +0 -0
- package/template_scaffold/public/please/device-iphone.png +0 -0
- package/template_scaffold/public/please/device-macbook.png +0 -0
- package/template_scaffold/public/please/device-none.png +0 -0
- package/template_scaffold/public/please/device-watch.png +0 -0
- package/template_scaffold/public/please/glow.svg +3 -0
- package/template_scaffold/public/please/steps-sprite-alt.png +0 -0
- package/template_scaffold/public/please/steps-sprite-default.png +0 -0
- package/template_scaffold/public/please/testimonial-avatar.png +0 -0
- package/template_scaffold/public/please/testimonial-star.svg +3 -0
- package/template_scaffold/public/upsell/upgrade-hero.png +0 -0
- package/template_scaffold/src/app/[stepId]/page.test.tsx +59 -0
- package/template_scaffold/src/app/[stepId]/page.tsx +62 -0
- package/template_scaffold/src/app/globals.css +49 -0
- package/template_scaffold/src/app/layout.test.ts +26 -0
- package/template_scaffold/src/app/layout.tsx +61 -0
- package/template_scaffold/src/app/page.tsx +8 -0
- package/template_scaffold/src/app/sdk/page.tsx +673 -0
- package/template_scaffold/src/app/subscription-dashboard/page.tsx +274 -0
- package/template_scaffold/src/assets/claimbee/bee.png +0 -0
- package/template_scaffold/src/assets/claimbee/device-iphone.png +0 -0
- package/template_scaffold/src/assets/claimbee/device-macbook.png +0 -0
- package/template_scaffold/src/assets/claimbee/device-none.png +0 -0
- package/template_scaffold/src/assets/claimbee/device-watch.png +0 -0
- package/template_scaffold/src/assets/claimbee/glow.svg +3 -0
- package/template_scaffold/src/assets/claimbee/steps-sprite-alt.png +0 -0
- package/template_scaffold/src/assets/claimbee/steps-sprite-default.png +0 -0
- package/template_scaffold/src/assets/claimbee/testimonial-avatar.png +0 -0
- package/template_scaffold/src/assets/claimbee/testimonial-star.svg +3 -0
- package/template_scaffold/src/components/FunnelEditorPanel.tsx +194 -0
- package/template_scaffold/src/components/FunnelFlow.test.tsx +17 -0
- package/template_scaffold/src/components/FunnelFlow.tsx +114 -0
- package/template_scaffold/src/components/FunnelStepImage.test.ts +15 -0
- package/template_scaffold/src/components/FunnelStepImage.tsx +28 -0
- package/template_scaffold/src/components/step/FunnelStepHeader.tsx +35 -0
- package/template_scaffold/src/config/billing.plans.test.ts +143 -0
- package/template_scaffold/src/config/billing.plans.ts +69 -0
- package/template_scaffold/src/config/billing.test.plans.ts +32 -0
- package/template_scaffold/src/config/experiments.generated.ts +4 -0
- package/template_scaffold/src/config/experiments.test.ts +12 -0
- package/template_scaffold/src/config/experiments.ts +9 -0
- package/template_scaffold/src/config/funnel.config.ts +12 -0
- package/template_scaffold/src/config/funnel.manifest.test.ts +166 -0
- package/template_scaffold/src/config/funnel.manifest.ts +139 -0
- package/template_scaffold/src/config/offer-sets.generated.ts +4 -0
- package/template_scaffold/src/contract/funnel-project.validation.test.ts +80 -0
- package/template_scaffold/src/contract/funnel-project.validation.ts +44 -0
- package/template_scaffold/src/contract/funnel-validator.vite.config.ts +11 -0
- package/template_scaffold/src/contract/golden/cancellation_offer.fixture.ts +29 -0
- package/template_scaffold/src/contract/golden/checkout.fixture.ts +37 -0
- package/template_scaffold/src/contract/golden/form_input.fixture.ts +28 -0
- package/template_scaffold/src/contract/golden/golden-fixtures.test.ts +190 -0
- package/template_scaffold/src/contract/golden/intro_hero.fixture.ts +27 -0
- package/template_scaffold/src/contract/golden/multi_select_choice.fixture.ts +37 -0
- package/template_scaffold/src/contract/golden/paywall_offer.fixture.ts +30 -0
- package/template_scaffold/src/contract/golden/progress_interstitial.fixture.ts +28 -0
- package/template_scaffold/src/contract/golden/purchase_completed.fixture.ts +33 -0
- package/template_scaffold/src/contract/golden/single_step_choice.fixture.ts +36 -0
- package/template_scaffold/src/contract/golden/single_step_choice_emoji.fixture.ts +36 -0
- package/template_scaffold/src/contract/golden/social_proof.fixture.ts +27 -0
- package/template_scaffold/src/contract/golden/subscription_handoff.fixture.ts +30 -0
- package/template_scaffold/src/contract/golden/subscription_management.fixture.ts +29 -0
- package/template_scaffold/src/contract/golden/summary_confirmation.fixture.ts +27 -0
- package/template_scaffold/src/contract/golden/upsell_offer.fixture.ts +29 -0
- package/template_scaffold/src/contract/golden/value_prop_story.fixture.ts +27 -0
- package/template_scaffold/src/contract/validate-funnel.cli.test.ts +180 -0
- package/template_scaffold/src/contract/validate-funnel.cli.ts +199 -0
- package/template_scaffold/src/runtime/checkout-runtime-config.test.ts +60 -0
- package/template_scaffold/src/runtime/checkout-runtime-config.ts +26 -0
- package/template_scaffold/src/runtime/funnel-runtime.test.ts +25 -0
- package/template_scaffold/src/runtime/funnel-runtime.ts +118 -0
- package/template_scaffold/src/runtime/step-content-context.test.ts +38 -0
- package/template_scaffold/src/runtime/step-content-context.ts +65 -0
- package/template_scaffold/src/runtime/step-registry.ts +66 -0
- package/template_scaffold/src/runtime/step-variable-values.ts +31 -0
- package/template_scaffold/src/runtime/use-funnel-flow-controller.integration.test.ts +203 -0
- package/template_scaffold/src/runtime/use-funnel-flow-controller.test.ts +76 -0
- package/template_scaffold/src/runtime/use-funnel-flow-controller.ts +53 -0
- package/template_scaffold/src/steps/content/email-capture.content.ts +29 -0
- package/template_scaffold/src/steps/content/manage-subscription.content.ts +62 -0
- package/template_scaffold/src/steps/content/paywall.content.ts +191 -0
- package/template_scaffold/src/steps/content/step-01.content.ts +23 -0
- package/template_scaffold/src/steps/content/step-02.content.ts +77 -0
- package/template_scaffold/src/steps/content/step-03.content.ts +40 -0
- package/template_scaffold/src/steps/content/step-04.content.ts +49 -0
- package/template_scaffold/src/steps/content/step-32-paywall.content.ts +352 -0
- package/template_scaffold/src/steps/content/subscription-started.content.ts +68 -0
- package/template_scaffold/src/steps/editor/email-capture.editor.ts +58 -0
- package/template_scaffold/src/steps/editor/manage-subscription.editor.ts +179 -0
- package/template_scaffold/src/steps/editor/paywall.editor.ts +232 -0
- package/template_scaffold/src/steps/editor/step-01.editor.ts +22 -0
- package/template_scaffold/src/steps/editor/step-02.editor.ts +41 -0
- package/template_scaffold/src/steps/editor/step-03.editor.ts +58 -0
- package/template_scaffold/src/steps/editor/step-04.editor.ts +98 -0
- package/template_scaffold/src/steps/editor/step-32-paywall.editor.ts +478 -0
- package/template_scaffold/src/steps/editor/subscription-started.editor.ts +131 -0
- package/template_scaffold/src/steps/index.ts +25 -0
- package/template_scaffold/src/steps/paywall-checkout-options.test.ts +104 -0
- package/template_scaffold/src/steps/paywall-checkout-options.ts +130 -0
- package/template_scaffold/src/steps/pricing/paywall-b.pricing.ts +12 -0
- package/template_scaffold/src/steps/pricing/paywall.pricing.ts +12 -0
- package/template_scaffold/src/steps/pricing/shared-plan-order.ts +17 -0
- package/template_scaffold/src/steps/pricing/upsell-form.pricing.ts +16 -0
- package/template_scaffold/src/steps/shared-header-contract.test.ts +27 -0
- package/template_scaffold/src/steps/step-01.test.ts +38 -0
- package/template_scaffold/src/steps/step-01.tsx +108 -0
- package/template_scaffold/src/steps/step-02.test.ts +43 -0
- package/template_scaffold/src/steps/step-02.tsx +140 -0
- package/template_scaffold/src/steps/step-03.test.ts +15 -0
- package/template_scaffold/src/steps/step-03.tsx +262 -0
- package/template_scaffold/src/steps/step-04.test.ts +32 -0
- package/template_scaffold/src/steps/step-04.tsx +673 -0
- package/template_scaffold/src/steps/step-31-email-capture.test.ts +22 -0
- package/template_scaffold/src/steps/step-31-email-capture.tsx +195 -0
- package/template_scaffold/src/steps/step-32-paywall.test.ts +770 -0
- package/template_scaffold/src/steps/step-32-paywall.tsx +2253 -0
- package/template_scaffold/src/steps/step-32b-paywall-b.tsx +35 -0
- package/template_scaffold/src/steps/step-33-subscription-started.test.ts +26 -0
- package/template_scaffold/src/steps/step-33-subscription-started.tsx +86 -0
- package/template_scaffold/src/steps/step-34-upsell-form.test.ts +27 -0
- package/template_scaffold/src/steps/step-35-manage-subscription.tsx +46 -0
- package/template_scaffold/src/steps/step-content.registry.ts +45 -0
- package/template_scaffold/src/steps/step-image-migration.test.ts +20 -0
- package/template_scaffold/src/steps/styles/index.css +2 -0
- package/template_scaffold/src/steps/styles/shared/final-flow-shared.css +55 -0
- package/template_scaffold/src/steps/styles/shared/funnel-base.css +543 -0
- package/template_scaffold/src/steps/styles/shared/info-shared.css +139 -0
- package/template_scaffold/src/steps/styles/shared/progress-shared.css +117 -0
- package/template_scaffold/src/steps/styles/shared/question-shared.css +76 -0
- package/template_scaffold/src/steps/styles/shared/responsive-container.css +176 -0
- package/template_scaffold/src/steps/types.ts +7 -0
- package/template_scaffold/src/steps/use-claimbee-step-content.ts +15 -0
- package/template_scaffold/src/theme/theme.ts +81 -0
- package/template_scaffold/tsconfig.json +38 -0
- package/template_scaffold/vitest.config.ts +32 -0
- package/template_validation/.funnelsgrove-contract-tools.json +19 -0
- package/template_validation/src/contract/funnel-project.validation.ts +44 -0
- package/template_validation/src/contract/funnel-validator.vite.config.ts +11 -0
- package/template_validation/src/contract/validate-funnel.cli.ts +199 -0
- package/template_docs/docs/ab-experiments.md +0 -55
- package/template_docs/docs/analytics.md +0 -65
- package/template_docs/docs/editing-flow.md +0 -125
- package/template_docs/docs/editing-step.md +0 -125
- package/template_docs/docs/editor-and-content.md +0 -58
- package/template_docs/docs/funnel-runtime-architecture.md +0 -125
- package/template_docs/docs/meta-pixel-conversions-api.md +0 -50
- package/template_docs/docs/payment-plans-and-discounts.md +0 -106
- package/template_docs/docs/publishing-and-versioning.md +0 -117
- package/template_docs/docs/qa-checklist.md +0 -80
- package/template_docs/docs/sdk-api-endpoints.md +0 -78
- package/template_docs/docs/step-ui-guidelines.md +0 -110
- package/template_docs/docs/theme.md +0 -35
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { apiService, type ManageSubscriptionsResponse } from '@funnelsgrove/runtime';
|
|
5
|
+
|
|
6
|
+
export default function ManageSubscriptionPage() {
|
|
7
|
+
const [data, setData] = useState<ManageSubscriptionsResponse | null>(null);
|
|
8
|
+
const [loading, setLoading] = useState(true);
|
|
9
|
+
const [error, setError] = useState<string | null>(null);
|
|
10
|
+
const [updatingSubscriptionId, setUpdatingSubscriptionId] = useState<string | null>(null);
|
|
11
|
+
|
|
12
|
+
const load = useCallback(async () => {
|
|
13
|
+
setLoading(true);
|
|
14
|
+
setError(null);
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const payload = await apiService.getManageSubscriptions();
|
|
18
|
+
setData(payload);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
setError(err instanceof Error ? err.message : 'Failed to load subscriptions');
|
|
21
|
+
} finally {
|
|
22
|
+
setLoading(false);
|
|
23
|
+
}
|
|
24
|
+
}, []);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
void load();
|
|
28
|
+
}, [load]);
|
|
29
|
+
|
|
30
|
+
const mutate = async (subscriptionId: string, action: 'cancel' | 'renew') => {
|
|
31
|
+
setUpdatingSubscriptionId(subscriptionId);
|
|
32
|
+
setError(null);
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const payload = await apiService.updateSubscription({
|
|
36
|
+
subscriptionId,
|
|
37
|
+
action,
|
|
38
|
+
});
|
|
39
|
+
setData(payload);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
setError(err instanceof Error ? err.message : `Failed to ${action} subscription`);
|
|
42
|
+
} finally {
|
|
43
|
+
setUpdatingSubscriptionId(null);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<main className="manage-subscription-page">
|
|
49
|
+
<section className="manage-subscription-card">
|
|
50
|
+
<header>
|
|
51
|
+
<p className="manage-subscription-tag">App Deals</p>
|
|
52
|
+
<h1 className="manage-subscription-title">Manage Subscription</h1>
|
|
53
|
+
<p className="manage-subscription-description">
|
|
54
|
+
View active plans and manage cancellation or renewal.
|
|
55
|
+
</p>
|
|
56
|
+
</header>
|
|
57
|
+
|
|
58
|
+
{loading ? <p className="manage-subscription-muted">Loading subscription data...</p> : null}
|
|
59
|
+
{error ? <p className="manage-subscription-error">{error}</p> : null}
|
|
60
|
+
|
|
61
|
+
{!loading && data?.user ? (
|
|
62
|
+
<section className="manage-subscription-user">
|
|
63
|
+
<p>
|
|
64
|
+
<strong>User ID:</strong> {data.user.user_id}
|
|
65
|
+
</p>
|
|
66
|
+
<p>
|
|
67
|
+
<strong>Email:</strong> {data.user.email || 'Not provided'}
|
|
68
|
+
</p>
|
|
69
|
+
<p>
|
|
70
|
+
<strong>Status:</strong> {data.user.subscriptionStatus || 'unknown'}
|
|
71
|
+
</p>
|
|
72
|
+
<p>
|
|
73
|
+
<strong>Tracked events:</strong> {data.eventsCount}
|
|
74
|
+
</p>
|
|
75
|
+
</section>
|
|
76
|
+
) : null}
|
|
77
|
+
|
|
78
|
+
{!loading && (!data || data.subscriptions.length === 0) ? (
|
|
79
|
+
<p className="manage-subscription-muted">No subscriptions found for this user.</p>
|
|
80
|
+
) : null}
|
|
81
|
+
|
|
82
|
+
{!loading && data?.subscriptions.length ? (
|
|
83
|
+
<ul className="manage-subscription-list">
|
|
84
|
+
{data.subscriptions.map((subscription) => (
|
|
85
|
+
<li key={subscription.id} className="manage-subscription-item">
|
|
86
|
+
<div>
|
|
87
|
+
<p className="manage-subscription-item-title">
|
|
88
|
+
{subscription.providerSubscriptionId}
|
|
89
|
+
</p>
|
|
90
|
+
<p className="manage-subscription-item-meta">
|
|
91
|
+
{subscription.environment.toUpperCase()} · {subscription.status}
|
|
92
|
+
</p>
|
|
93
|
+
<p className="manage-subscription-item-meta">
|
|
94
|
+
{subscription.cancelAtPeriodEnd
|
|
95
|
+
? 'Will cancel at period end'
|
|
96
|
+
: 'Auto-renew is active'}
|
|
97
|
+
</p>
|
|
98
|
+
{subscription.currentPeriodEnd ? (
|
|
99
|
+
<p className="manage-subscription-item-meta">
|
|
100
|
+
Current period ends:{' '}
|
|
101
|
+
{new Date(subscription.currentPeriodEnd).toLocaleString()}
|
|
102
|
+
</p>
|
|
103
|
+
) : null}
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<div className="manage-subscription-actions">
|
|
107
|
+
{subscription.cancelAtPeriodEnd ? (
|
|
108
|
+
<button
|
|
109
|
+
type="button"
|
|
110
|
+
className="manage-subscription-button is-secondary"
|
|
111
|
+
disabled={updatingSubscriptionId === subscription.id}
|
|
112
|
+
onClick={() => mutate(subscription.id, 'renew')}
|
|
113
|
+
>
|
|
114
|
+
{updatingSubscriptionId === subscription.id ? 'Updating...' : 'Renew'}
|
|
115
|
+
</button>
|
|
116
|
+
) : (
|
|
117
|
+
<button
|
|
118
|
+
type="button"
|
|
119
|
+
className="manage-subscription-button"
|
|
120
|
+
disabled={updatingSubscriptionId === subscription.id}
|
|
121
|
+
onClick={() => mutate(subscription.id, 'cancel')}
|
|
122
|
+
>
|
|
123
|
+
{updatingSubscriptionId === subscription.id ? 'Updating...' : 'Cancel'}
|
|
124
|
+
</button>
|
|
125
|
+
)}
|
|
126
|
+
</div>
|
|
127
|
+
</li>
|
|
128
|
+
))}
|
|
129
|
+
</ul>
|
|
130
|
+
) : null}
|
|
131
|
+
|
|
132
|
+
<button type="button" className="manage-subscription-refresh" onClick={() => void load()}>
|
|
133
|
+
Refresh
|
|
134
|
+
</button>
|
|
135
|
+
</section>
|
|
136
|
+
|
|
137
|
+
{manageSubscriptionStyles ? <style>{manageSubscriptionStyles}</style> : null}
|
|
138
|
+
</main>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const manageSubscriptionStyles = `
|
|
143
|
+
.manage-subscription-page {
|
|
144
|
+
min-height: 100svh;
|
|
145
|
+
display: flex;
|
|
146
|
+
justify-content: center;
|
|
147
|
+
padding: 24px;
|
|
148
|
+
background: var(--color-bg);
|
|
149
|
+
font-family: var(--font-family-base);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.manage-subscription-card {
|
|
153
|
+
width: min(760px, 100%);
|
|
154
|
+
border-radius: 20px;
|
|
155
|
+
background: var(--color-surface);
|
|
156
|
+
box-shadow: 0 12px 40px rgb(21 39 113 / 10%);
|
|
157
|
+
padding: 24px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.manage-subscription-tag {
|
|
161
|
+
margin: 0;
|
|
162
|
+
color: var(--color-accent);
|
|
163
|
+
font-size: 13px;
|
|
164
|
+
font-weight: 700;
|
|
165
|
+
line-height: 1.2;
|
|
166
|
+
text-transform: uppercase;
|
|
167
|
+
letter-spacing: 0.06em;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.manage-subscription-title {
|
|
171
|
+
margin: 8px 0 0;
|
|
172
|
+
color: var(--color-text);
|
|
173
|
+
font-size: 32px;
|
|
174
|
+
line-height: 1.15;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.manage-subscription-description {
|
|
178
|
+
margin: 10px 0 0;
|
|
179
|
+
color: var(--color-text-muted);
|
|
180
|
+
font-size: 16px;
|
|
181
|
+
line-height: 1.45;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.manage-subscription-muted {
|
|
185
|
+
margin-top: 20px;
|
|
186
|
+
color: var(--color-text-muted);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.manage-subscription-error {
|
|
190
|
+
margin-top: 20px;
|
|
191
|
+
border-radius: 12px;
|
|
192
|
+
background: #ffecec;
|
|
193
|
+
color: var(--color-danger);
|
|
194
|
+
padding: 12px;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.manage-subscription-user {
|
|
198
|
+
margin-top: 20px;
|
|
199
|
+
border-radius: 12px;
|
|
200
|
+
border: 1px solid var(--color-border);
|
|
201
|
+
padding: 14px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.manage-subscription-user p {
|
|
205
|
+
margin: 6px 0;
|
|
206
|
+
color: var(--color-text);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.manage-subscription-list {
|
|
210
|
+
list-style: none;
|
|
211
|
+
margin: 20px 0 0;
|
|
212
|
+
padding: 0;
|
|
213
|
+
display: flex;
|
|
214
|
+
flex-direction: column;
|
|
215
|
+
gap: 12px;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.manage-subscription-item {
|
|
219
|
+
border: 1px solid var(--color-border);
|
|
220
|
+
border-radius: 14px;
|
|
221
|
+
padding: 14px;
|
|
222
|
+
display: flex;
|
|
223
|
+
justify-content: space-between;
|
|
224
|
+
gap: 14px;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.manage-subscription-item-title {
|
|
228
|
+
margin: 0;
|
|
229
|
+
color: var(--color-text);
|
|
230
|
+
font-size: 15px;
|
|
231
|
+
font-weight: 700;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.manage-subscription-item-meta {
|
|
235
|
+
margin: 6px 0 0;
|
|
236
|
+
color: var(--color-text-muted);
|
|
237
|
+
font-size: 13px;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.manage-subscription-actions {
|
|
241
|
+
display: flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.manage-subscription-button {
|
|
246
|
+
border: none;
|
|
247
|
+
border-radius: 999px;
|
|
248
|
+
background: var(--color-button);
|
|
249
|
+
color: var(--color-button-text);
|
|
250
|
+
font-weight: 700;
|
|
251
|
+
padding: 10px 16px;
|
|
252
|
+
cursor: pointer;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.manage-subscription-button.is-secondary {
|
|
256
|
+
background: var(--color-accent);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.manage-subscription-button:disabled {
|
|
260
|
+
opacity: 0.6;
|
|
261
|
+
cursor: default;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.manage-subscription-refresh {
|
|
265
|
+
margin-top: 20px;
|
|
266
|
+
border: 1px solid var(--color-border);
|
|
267
|
+
border-radius: 999px;
|
|
268
|
+
background: transparent;
|
|
269
|
+
color: var(--color-accent);
|
|
270
|
+
font-weight: 700;
|
|
271
|
+
padding: 10px 16px;
|
|
272
|
+
cursor: pointer;
|
|
273
|
+
}
|
|
274
|
+
`;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg preserveAspectRatio="none" width="100%" height="100%" overflow="visible" style="display: block;" viewBox="0 0 116 109.5" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path id="Vector 11" d="M0 22.5L51 0H85L116 22.5V54.5V89L74.5 109.5L42 103L9 89L0 61.5V22.5Z" fill="var(--fill-0, #FEFDF5)"/>
|
|
3
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg preserveAspectRatio="none" width="100%" height="100%" overflow="visible" style="display: block;" viewBox="0 0 16.1222 15.4039" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path id="Star 1" d="M7.37895 0.495601C7.59366 -0.165201 8.52852 -0.1652 8.74323 0.495602L10.1545 4.83902C10.2505 5.13454 10.5259 5.33462 10.8366 5.33462H15.4036C16.0984 5.33462 16.3873 6.22372 15.8251 6.63212L12.1304 9.3165C11.879 9.49914 11.7738 9.82288 11.8699 10.1184L13.2811 14.4618C13.4958 15.1226 12.7395 15.6721 12.1774 15.2637L8.48267 12.5793C8.23129 12.3967 7.89089 12.3967 7.63951 12.5793L3.94477 15.2637C3.38266 15.6721 2.62635 15.1226 2.84105 14.4618L4.25232 10.1184C4.34834 9.82288 4.24315 9.49914 3.99176 9.3165L0.297032 6.63212C-0.26508 6.22372 0.0238078 5.33462 0.718616 5.33462H5.28555C5.59628 5.33462 5.87167 5.13454 5.96769 4.83902L7.37895 0.495601Z" fill="var(--fill-0, #F28100)"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { FunnelExperimentConfig } from '@/runtime/funnel-runtime';
|
|
4
|
+
import type { RuntimeMode } from '@funnelsgrove/runtime';
|
|
5
|
+
|
|
6
|
+
type FunnelEditorPanelProps = {
|
|
7
|
+
editorModeEnabled: boolean;
|
|
8
|
+
editorPanelExpanded: boolean;
|
|
9
|
+
experimentAssignmentForEditor: (experiment: FunnelExperimentConfig) => string;
|
|
10
|
+
funnelExperiments: readonly FunnelExperimentConfig[];
|
|
11
|
+
onRuntimeModeChange: (mode: RuntimeMode) => void;
|
|
12
|
+
onSelectVariant: (experiment: FunnelExperimentConfig, variantKey: string) => void;
|
|
13
|
+
onToggleExpanded: () => void;
|
|
14
|
+
runtimeMode: RuntimeMode;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function FunnelEditorPanel({
|
|
18
|
+
editorModeEnabled,
|
|
19
|
+
editorPanelExpanded,
|
|
20
|
+
experimentAssignmentForEditor,
|
|
21
|
+
funnelExperiments,
|
|
22
|
+
onRuntimeModeChange,
|
|
23
|
+
onSelectVariant,
|
|
24
|
+
onToggleExpanded,
|
|
25
|
+
runtimeMode,
|
|
26
|
+
}: FunnelEditorPanelProps) {
|
|
27
|
+
if (!editorModeEnabled) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<aside className={`funnel-editor-panel ${editorPanelExpanded ? 'is-expanded' : 'is-collapsed'}`}>
|
|
33
|
+
<button type="button" className="funnel-editor-panel-toggle" onClick={onToggleExpanded}>
|
|
34
|
+
{editorPanelExpanded ? 'Hide editor' : 'Editor'}
|
|
35
|
+
</button>
|
|
36
|
+
|
|
37
|
+
{editorPanelExpanded ? (
|
|
38
|
+
<div className="funnel-editor-panel-content">
|
|
39
|
+
<p className="funnel-editor-panel-label">MODE</p>
|
|
40
|
+
<div className="funnel-editor-panel-options">
|
|
41
|
+
<button
|
|
42
|
+
type="button"
|
|
43
|
+
className={runtimeMode === 'test' ? 'is-active' : ''}
|
|
44
|
+
onClick={() => onRuntimeModeChange('test')}
|
|
45
|
+
>
|
|
46
|
+
Test
|
|
47
|
+
</button>
|
|
48
|
+
<button
|
|
49
|
+
type="button"
|
|
50
|
+
className={runtimeMode === 'live' ? 'is-active' : ''}
|
|
51
|
+
onClick={() => onRuntimeModeChange('live')}
|
|
52
|
+
>
|
|
53
|
+
Live
|
|
54
|
+
</button>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<div className="funnel-editor-panel-tests">
|
|
58
|
+
<p className="funnel-editor-panel-label">A/B TESTS</p>
|
|
59
|
+
{funnelExperiments.length === 0 ? (
|
|
60
|
+
<p className="funnel-editor-panel-helper">No configured tests.</p>
|
|
61
|
+
) : (
|
|
62
|
+
<div className="funnel-editor-panel-test-list">
|
|
63
|
+
{funnelExperiments.map((experiment) => {
|
|
64
|
+
const assignedVariantKey = experimentAssignmentForEditor(experiment);
|
|
65
|
+
return (
|
|
66
|
+
<label key={experiment.experimentId} className="funnel-editor-panel-test-item">
|
|
67
|
+
<span>{experiment.experimentId}</span>
|
|
68
|
+
<select
|
|
69
|
+
value={assignedVariantKey}
|
|
70
|
+
onChange={(event) => {
|
|
71
|
+
onSelectVariant(experiment, event.target.value);
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
{experiment.variants.map((variant) => (
|
|
75
|
+
<option key={variant.variantKey} value={variant.variantKey}>
|
|
76
|
+
{variant.variantKey}
|
|
77
|
+
</option>
|
|
78
|
+
))}
|
|
79
|
+
</select>
|
|
80
|
+
</label>
|
|
81
|
+
);
|
|
82
|
+
})}
|
|
83
|
+
</div>
|
|
84
|
+
)}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
) : null}
|
|
88
|
+
</aside>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const FunnelEditorPanelStyles = `
|
|
93
|
+
.funnel-editor-panel {
|
|
94
|
+
position: fixed;
|
|
95
|
+
top: 12px;
|
|
96
|
+
right: 12px;
|
|
97
|
+
z-index: 1200;
|
|
98
|
+
border-radius: 12px;
|
|
99
|
+
border: 1px solid rgba(33, 41, 82, 0.25);
|
|
100
|
+
background: rgba(255, 255, 255, 0.98);
|
|
101
|
+
color: #202538;
|
|
102
|
+
box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.funnel-editor-panel.is-collapsed {
|
|
106
|
+
width: auto;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.funnel-editor-panel.is-expanded {
|
|
110
|
+
width: 184px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.funnel-editor-panel-toggle {
|
|
114
|
+
width: 100%;
|
|
115
|
+
border: 0;
|
|
116
|
+
background: transparent;
|
|
117
|
+
color: inherit;
|
|
118
|
+
font-size: 13px;
|
|
119
|
+
font-weight: 700;
|
|
120
|
+
line-height: 1;
|
|
121
|
+
padding: 10px 12px;
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
text-align: left;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.funnel-editor-panel-content {
|
|
127
|
+
border-top: 1px solid rgba(33, 41, 82, 0.15);
|
|
128
|
+
padding: 10px 12px 12px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.funnel-editor-panel-label {
|
|
132
|
+
margin: 0 0 8px;
|
|
133
|
+
font-size: 11px;
|
|
134
|
+
font-weight: 700;
|
|
135
|
+
letter-spacing: 0.08em;
|
|
136
|
+
color: #53608a;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.funnel-editor-panel-options {
|
|
140
|
+
display: grid;
|
|
141
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
142
|
+
gap: 8px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.funnel-editor-panel-options button {
|
|
146
|
+
border: 1px solid color-mix(in srgb, var(--color-primary) 30%, transparent);
|
|
147
|
+
border-radius: 8px;
|
|
148
|
+
background: color-mix(in srgb, var(--color-primary) 10%, var(--color-surface) 90%);
|
|
149
|
+
color: var(--color-primary);
|
|
150
|
+
font-size: 12px;
|
|
151
|
+
font-weight: 700;
|
|
152
|
+
line-height: 1;
|
|
153
|
+
padding: 10px 0;
|
|
154
|
+
cursor: pointer;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.funnel-editor-panel-options button.is-active {
|
|
158
|
+
border-color: var(--color-primary);
|
|
159
|
+
background: var(--color-primary);
|
|
160
|
+
color: var(--color-primary-text);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.funnel-editor-panel-tests {
|
|
164
|
+
margin-top: 10px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.funnel-editor-panel-helper {
|
|
168
|
+
margin: 0;
|
|
169
|
+
font-size: 11px;
|
|
170
|
+
color: #5a6387;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.funnel-editor-panel-test-list {
|
|
174
|
+
display: grid;
|
|
175
|
+
gap: 8px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.funnel-editor-panel-test-item {
|
|
179
|
+
display: grid;
|
|
180
|
+
gap: 6px;
|
|
181
|
+
font-size: 11px;
|
|
182
|
+
color: #445073;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.funnel-editor-panel-test-item select {
|
|
186
|
+
height: 28px;
|
|
187
|
+
border: 1px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
|
|
188
|
+
border-radius: 8px;
|
|
189
|
+
background: #f5f7ff;
|
|
190
|
+
color: #26315a;
|
|
191
|
+
font-size: 12px;
|
|
192
|
+
padding: 0 8px;
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
describe('FunnelFlow lifecycle wiring', () => {
|
|
5
|
+
it('delegates one analytics adapter and the authoritative manifest version to the shared controller', () => {
|
|
6
|
+
const flowSource = readFileSync(new URL('./FunnelFlow.tsx', import.meta.url), 'utf8');
|
|
7
|
+
const adapterSource = readFileSync(
|
|
8
|
+
new URL('../runtime/use-funnel-flow-controller.ts', import.meta.url),
|
|
9
|
+
'utf8',
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
expect(flowSource).toContain('const controller = useFunnelFlowController({');
|
|
13
|
+
expect(flowSource).not.toContain('publicAnalyticsSdk');
|
|
14
|
+
expect(adapterSource.match(/analytics: publicAnalyticsSdk/g)).toHaveLength(1);
|
|
15
|
+
expect(adapterSource.match(/stepContractVersion: funnelManifest\.stepContractVersion/g)).toHaveLength(1);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createElement, useMemo, useSyncExternalStore, type ComponentType } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
FunnelProvider,
|
|
6
|
+
PrimaryButton,
|
|
7
|
+
isPreviewFrameRuntime,
|
|
8
|
+
usePreviewDefinitionOverrideRevision,
|
|
9
|
+
} from '@funnelsgrove/runtime';
|
|
10
|
+
import { FunnelEditorPanel, FunnelEditorPanelStyles } from './FunnelEditorPanel';
|
|
11
|
+
import type { FunnelStepId } from '@/runtime/funnel-runtime';
|
|
12
|
+
import { useFunnelFlowController } from '@/runtime/use-funnel-flow-controller';
|
|
13
|
+
|
|
14
|
+
type FunnelFlowProps = {
|
|
15
|
+
initialStepId?: FunnelStepId;
|
|
16
|
+
lockToInitialStep?: boolean;
|
|
17
|
+
isPreviewFrame?: boolean;
|
|
18
|
+
isPreviewThumbnail?: boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function FunnelFlow({
|
|
22
|
+
initialStepId,
|
|
23
|
+
lockToInitialStep,
|
|
24
|
+
isPreviewFrame,
|
|
25
|
+
isPreviewThumbnail,
|
|
26
|
+
}: FunnelFlowProps = {}) {
|
|
27
|
+
const isPreviewRuntime = useMemo(() => {
|
|
28
|
+
if (typeof isPreviewFrame === 'boolean') {
|
|
29
|
+
return isPreviewFrame;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return isPreviewFrameRuntime();
|
|
33
|
+
}, [isPreviewFrame]);
|
|
34
|
+
const previewFrameMounted = useSyncExternalStore(
|
|
35
|
+
() => () => undefined,
|
|
36
|
+
() => isPreviewRuntime,
|
|
37
|
+
() => false,
|
|
38
|
+
);
|
|
39
|
+
const previewDefinitionRevision = usePreviewDefinitionOverrideRevision();
|
|
40
|
+
const controller = useFunnelFlowController({
|
|
41
|
+
initialStepId,
|
|
42
|
+
lockToInitialStep,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (!controller.activeStepComponent || !controller.activeStepMeta || !controller.renderedStepMeta) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const ActiveStep = controller.activeStepComponent as ComponentType<Record<string, never>>;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<FunnelProvider value={controller.contextValue}>
|
|
53
|
+
<section
|
|
54
|
+
className="funnel-shell"
|
|
55
|
+
suppressHydrationWarning
|
|
56
|
+
data-preview-frame={previewFrameMounted ? 'true' : undefined}
|
|
57
|
+
data-preview-thumbnail={isPreviewThumbnail ? 'true' : undefined}
|
|
58
|
+
data-step-kind={controller.renderedStepMeta.kind}
|
|
59
|
+
>
|
|
60
|
+
<div className="funnel-content">
|
|
61
|
+
<div
|
|
62
|
+
className="step-stage"
|
|
63
|
+
data-step-id={controller.activeStepId}
|
|
64
|
+
data-render-step-id={controller.renderedStepId}
|
|
65
|
+
data-figma-node-id={controller.renderedStepMeta.figmaNodeId}
|
|
66
|
+
data-render-suspended={controller.renderSuspended ? 'true' : undefined}
|
|
67
|
+
>
|
|
68
|
+
{controller.renderSuspended ? (
|
|
69
|
+
<div
|
|
70
|
+
className="step-stage-suspended"
|
|
71
|
+
aria-busy="true"
|
|
72
|
+
aria-live="polite"
|
|
73
|
+
style={{ minHeight: '100vh' }}
|
|
74
|
+
/>
|
|
75
|
+
) : (
|
|
76
|
+
<div
|
|
77
|
+
key={`${controller.activeStepId}:${controller.renderedStepId}:${previewDefinitionRevision}`}
|
|
78
|
+
className="step-stage-transition"
|
|
79
|
+
>
|
|
80
|
+
{createElement(ActiveStep)}
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
{controller.showShellContinue && !controller.renderSuspended ? (
|
|
86
|
+
<footer className="action-bar" key={`action-bar-${controller.activeStepId}`}>
|
|
87
|
+
<PrimaryButton
|
|
88
|
+
onClick={controller.handleContinue}
|
|
89
|
+
className={controller.buttonVariant === 'muted' ? 'is-muted' : undefined}
|
|
90
|
+
>
|
|
91
|
+
{controller.buttonText}
|
|
92
|
+
</PrimaryButton>
|
|
93
|
+
</footer>
|
|
94
|
+
) : null}
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<FunnelEditorPanel
|
|
98
|
+
editorModeEnabled={controller.editorModeEnabled}
|
|
99
|
+
editorPanelExpanded={controller.editorPanelExpanded}
|
|
100
|
+
experimentAssignmentForEditor={controller.experimentAssignmentForEditor}
|
|
101
|
+
funnelExperiments={controller.funnelExperiments}
|
|
102
|
+
onRuntimeModeChange={controller.setRuntimeMode}
|
|
103
|
+
onSelectVariant={controller.setEditorVariantSelection}
|
|
104
|
+
onToggleExpanded={() => {
|
|
105
|
+
controller.setEditorPanelExpanded((currentValue) => !currentValue);
|
|
106
|
+
}}
|
|
107
|
+
runtimeMode={controller.runtimeMode}
|
|
108
|
+
/>
|
|
109
|
+
</section>
|
|
110
|
+
|
|
111
|
+
<style>{FunnelEditorPanelStyles}</style>
|
|
112
|
+
</FunnelProvider>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { createFunnelStepImageLoader } from '@/components/FunnelStepImage';
|
|
3
|
+
|
|
4
|
+
describe('FunnelStepImage', () => {
|
|
5
|
+
it('keeps builder-friendly local and remote image src values unchanged', () => {
|
|
6
|
+
const loader = createFunnelStepImageLoader();
|
|
7
|
+
|
|
8
|
+
expect(loader({ src: '/claimbee/steps-sprite-default.png', width: 430, quality: 75 })).toBe(
|
|
9
|
+
'/claimbee/steps-sprite-default.png',
|
|
10
|
+
);
|
|
11
|
+
expect(loader({ src: 'https://example.com/remote-step-image.png', width: 430, quality: 75 })).toBe(
|
|
12
|
+
'https://example.com/remote-step-image.png',
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import Image, { type ImageLoaderProps, type ImageProps } from 'next/image';
|
|
4
|
+
|
|
5
|
+
export const createFunnelStepImageLoader = () => {
|
|
6
|
+
return ({ src }: ImageLoaderProps): string => src;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const funnelStepImageLoader = createFunnelStepImageLoader();
|
|
10
|
+
|
|
11
|
+
type FunnelStepImageProps = Omit<ImageProps, 'loader' | 'alt'> & {
|
|
12
|
+
alt: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function FunnelStepImage({
|
|
16
|
+
alt,
|
|
17
|
+
unoptimized,
|
|
18
|
+
...props
|
|
19
|
+
}: FunnelStepImageProps) {
|
|
20
|
+
return (
|
|
21
|
+
<Image
|
|
22
|
+
{...props}
|
|
23
|
+
alt={alt}
|
|
24
|
+
loader={funnelStepImageLoader}
|
|
25
|
+
unoptimized={unoptimized ?? true}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|