import React, { useEffect, useMemo } from "react"; import { Controller, useForm } from "react-hook-form"; import { ContinueButton, FormItem, PlanRadioPanel, RadioPanel } from "../components/atoms"; import { StagerComponent } from "../components/stager"; import { Summary } from "../components/summary"; import { FormSchema } from "../schema"; import { get as getEnv, getStr as getEnvStr } from "../env"; const membershipTiersHeading = getEnvStr("MEMBERSHIP_TIERS_HEADING"); const membershipTiersCopy = getEnvStr("MEMBERSHIP_TIERS_COPY") || "You can change or cancel whenever you want."; const currencySelectionCopy = getEnvStr("CURRENCY_SELECTION_COPY"); export const PlanPage: StagerComponent = ({ data, onCompleted }) => { const form = useForm({ defaultValues: data as {} }); const membershipPlans = getEnv("MEMBERSHIP_PLANS") as any[]; const groupedPlans: Record = {}; for (const plan of membershipPlans) { const group = groupedPlans[plan.label] || []; group.push(plan); groupedPlans[plan.label] = group; } // A currency selector is only rendered for plans available in more than one currency. const hasCurrencyChoice = Object.values(groupedPlans).some( (group) => group.length > 1 ); return (

{membershipTiersHeading}

{hasCurrencyChoice && currencySelectionCopy && (
)} {Object.keys(groupedPlans).map((label) => ( ))}
); };