Files
co-lite/solvway-admin-portal/app/components/pages/LandingForm.tsx
T
ngqileandClaude Opus 5.5 3446f261be feat(pages): a footer section with contact links, and a thank-you text on landing forms
Landing pages gain a Footer section (1 to 4 columns of title and text, a legal
line under a divider) whose phone numbers, emails and web addresses show as
links. The Form block and a hero with a form may carry a thank-you text shown
after sign-up, with the same links. Full-width heroes get a lighter shade.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 11:45:25 +08:00

41 lines
2.4 KiB
TypeScript

"use client";
import { useState } from "react";
import { AlertCircle, CheckCircle2 } from "lucide-react";
import { Button } from "@/app/components/ui/button";
import { VisitorState } from "@/app/components/registration/VisitorCard";
import { RegistrationForm } from "@/app/components/registration/RegistrationForm";
import { publicCall, type RegistrationBody, type RegistrationInfo } from "@/app/lib/services/publicRegistration";
import { useT } from "@/app/lib/i18n/MessagesProvider";
import { contactLinks } from "@/app/lib/contactLinks";
const UTM = ["utm_source", "utm_medium", "utm_campaign"] as const;
/** The page address's UTM tags, as the submit body names them. */
export function utmTags(search: string): { utmSource?: string; utmMedium?: string; utmCampaign?: string } {
const q = new URLSearchParams(search);
const [utmSource, utmMedium, utmCampaign] = UTM.map((k) => q.get(k)?.slice(0, 100) || undefined);
return { utmSource, utmMedium, utmCampaign };
}
// A landing page's FORM block: the QR sign-up form, posting to the page's block, with the visitor's UTM tags.
// add-landing-thanks-and-footer: `thanks` is the page's own text under the thank-you, with contact links.
export function LandingForm({ companyCode, slug, index, info, preview, thanks }: { companyCode: string; slug: string; index: number; info?: RegistrationInfo; preview?: boolean; thanks?: string }) {
const t = useT();
const [phase, setPhase] = useState<"form" | "done" | "closed">(info ? "form" : "closed");
if (preview) return <VisitorState icon={AlertCircle} heading={t("PagesFormPreview")} role="status" />;
if (phase === "closed" || !info) return <VisitorState icon={AlertCircle} heading={t("PagesFormClosed")} role="status" />;
if (phase === "done") {
return <VisitorState icon={CheckCircle2} heading={t("RegThanks", { event: info.eventName })} role="status"
text={thanks ? contactLinks(thanks) : undefined}
action={<Button className="h-11" onClick={() => setPhase("form")}>{t("RegAnother")}</Button>} />;
}
const submit = (body: RegistrationBody) =>
publicCall(`/api/public/pages/${encodeURIComponent(companyCode)}/${encodeURIComponent(slug)}/form/${index}`, {
method: "POST",
body: JSON.stringify({ ...body, ...utmTags(window.location.search) }),
});
return <RegistrationForm info={info} submit={submit} onDone={() => setPhase("done")} onInactive={() => setPhase("closed")} compact />;
}