Files
co-lite/solvway-admin-portal/app/components/registration/VisitorCard.tsx
T

59 lines
2.6 KiB
TypeScript

import type { ReactNode } from "react";
import { CalendarDays, MapPin, type LucideIcon } from "lucide-react";
import PoweredBy from "@/app/components/app/PoweredBy";
import type { RegistrationInfo } from "@/app/lib/services/publicRegistration";
type EventHeader = Pick<RegistrationInfo, "companyName" | "eventName" | "startDate" | "endDate" | "location">;
// The public visitor page frame: one card on the page ground, event header first, PoweredBy under it.
export function VisitorCard({ event, title, children }: { event?: EventHeader; title?: string; children?: ReactNode }) {
return (
<div className="flex min-h-screen flex-col items-center bg-background px-4 py-8">
<main className="w-full max-w-md space-y-6 rounded-lg border bg-card p-6 shadow-card">
{event && (
<header className="space-y-2">
<p className="text-xs font-semibold tracking-wide text-primary uppercase">{event.companyName}</p>
<h1 className="text-2xl font-semibold">{title ?? event.eventName}</h1>
<p className="flex items-center gap-2 text-sm text-muted-foreground">
<CalendarDays className="size-4 shrink-0" aria-hidden="true" />
<span>{event.startDate} - {event.endDate}</span>
</p>
<p className="flex items-center gap-2 text-sm text-muted-foreground">
<MapPin className="size-4 shrink-0" aria-hidden="true" />
<span>{event.location}</span>
</p>
</header>
)}
{children}
</main>
<div className="mt-4"><PoweredBy /></div>
</div>
);
}
interface StateProps {
icon: LucideIcon;
heading: string;
text?: string;
action?: ReactNode;
role?: "status" | "alert";
tone?: "default" | "error";
/** The heading is the page's h1: for states shown without the card's event header. */
h1?: boolean;
}
// A message inside the card (thanks, inactive, closed). h2 under the event header's h1; h1 when the card has no event header.
export function VisitorState({ icon: Icon, heading, text, action, role, tone = "default", h1 }: StateProps) {
const Heading = h1 ? "h1" : "h2";
return (
<div role={role} className="flex flex-col items-center gap-3 text-center">
<span className={`flex size-12 items-center justify-center rounded-full ${tone === "error" ? "bg-destructive/10 text-destructive" : "bg-accent text-accent-foreground"}`}>
<Icon className="size-6" aria-hidden="true" />
</span>
<Heading className="text-lg font-semibold text-balance">{heading}</Heading>
{text && <p className="text-sm text-muted-foreground">{text}</p>}
{action}
</div>
);
}