"use client"; import { memo } from "react"; import Alert from "../../modals/Alert"; import Button from "../../buttons/Button"; import { useMessages } from "../../../contexts/MessagesContext"; import { WORKSHOP_HONEYPOT_FIELD, WORKSHOP_SIGNUP_ANCHOR_ID, WORKSHOP_STARTED_AT_FIELD, type WorkshopFieldErrors, } from "../../../../lib/workshopSignup"; import type { WorkshopSignupViewProps } from "./WorkshopSignup.types"; const fieldClass = "h-[52px] w-full rounded-[12px] border bg-[var(--color-surface-default-primary)] px-4 text-[16px] leading-6 text-[var(--color-content-default-primary)] outline-none focus-visible:border-white"; function borderClass(invalid: boolean): string { return invalid ? "border-[var(--color-border-default-utility-negative)]" : "border-[var(--color-border-default-tertiary)]"; } function errorText( errors: WorkshopFieldErrors, key: keyof WorkshopFieldErrors, messages: Record, ): string | undefined { const code = errors[key]; if (!code) return undefined; return messages[key]; } function WorkshopSignupView({ className, issuedAt, schedulingUrl, sourceUrl, status, largeOrganization, values, fieldErrors, onSubmit, }: WorkshopSignupViewProps) { const copy = useMessages().pages.workshops.signup; const sending = status === "sending"; const sent = status === "sent"; const showSummary = status === "invalid" && Object.keys(fieldErrors).length > 0; const banner = status === "failed" ? copy.errors.failed : status === "rate_limited" ? copy.errors.rateLimited : showSummary ? copy.errors.summary : null; return (

{copy.title}

{copy.intro}

{sent ? (

{largeOrganization ? copy.sent.largeTitle : copy.sent.standardTitle}

{largeOrganization ? copy.sent.largeBody : copy.sent.standardBody}

{largeOrganization ? ( schedulingUrl ? ( ) : (

{copy.sent.largeButton}

) ) : ( )}
) : (
{banner ? ( ) : null}
{copy.sections.takeOn}

{copy.challenges.label}

{copy.challenges.hint}

{copy.challenges.options.map((option) => option.id === "something-else" ? (
{errorText(fieldErrors, "challengeOther", copy.errors) ? (

{errorText(fieldErrors, "challengeOther", copy.errors)}

) : null}
) : ( ), )}
{errorText(fieldErrors, "challenges", copy.errors) ? (

{errorText(fieldErrors, "challenges", copy.errors)}

) : null}

{copy.question.label}{" "} {copy.optional}

{copy.question.hint}