Show an early-bird ribbon on event cards
Event cards on the home page and events list get a diagonal "Early bird" ribbon in the top-right corner while an early-bird tier is running and registration is open. GET /api/events returns earlyBirdEndsAt per event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,8 @@ import { ContactButton } from "@/components/events/ContactButton";
|
||||
contactPhone?: string | null;
|
||||
contactEmail?: string | null;
|
||||
location?: string | null;
|
||||
// Set by GET /api/events while an early-bird tier is still running.
|
||||
earlyBirdEndsAt?: string | null;
|
||||
};
|
||||
|
||||
import { formatDateTimeRange } from "@/lib/date";
|
||||
@@ -26,9 +28,30 @@ import { formatDateTimeRange } from "@/lib/date";
|
||||
export const EventCard = ({ event }: { event: Event }) => {
|
||||
const dateRange = formatDateTimeRange(event.startDate, event.endDate);
|
||||
|
||||
const now = new Date();
|
||||
const deadline = event.registrationDeadline ? new Date(event.registrationDeadline) : null;
|
||||
const goLive = event.goLiveAt ? new Date(event.goLiveAt) : null;
|
||||
const registrationOpen = event.requiresRegistration !== false
|
||||
&& !(goLive && now < goLive)
|
||||
&& !(deadline && now >= deadline)
|
||||
&& now < new Date(event.endDate);
|
||||
const showEarlyBird = !!event.earlyBirdEndsAt && registrationOpen && !event.isSoldOut;
|
||||
|
||||
return (
|
||||
<div className="border rounded-xl overflow-hidden shadow-sm hover:shadow-md hover:border-brand-200 transition">
|
||||
<div className="relative border rounded-xl overflow-hidden shadow-sm hover:shadow-md hover:border-brand-200 transition">
|
||||
{showEarlyBird && (
|
||||
<div className="pointer-events-none absolute top-0 right-0 z-10 h-32 w-32 overflow-hidden" aria-hidden="true">
|
||||
<div className="absolute top-[26px] -right-[38px] w-[150px] rotate-45 bg-amber-400 py-1 text-center text-xs font-bold uppercase tracking-wide text-amber-950 shadow-md">
|
||||
Early bird
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<a href={`/events/${event.id}`} className="block">
|
||||
{showEarlyBird && (
|
||||
<span className="sr-only">
|
||||
Early bird pricing until {new Date(event.earlyBirdEndsAt!).toLocaleDateString("en-GB", { day: "numeric", month: "long" })}.
|
||||
</span>
|
||||
)}
|
||||
{event.picture ? (
|
||||
<ApiImage src={event.picture} alt={event.title} className="h-48 w-full object-cover" />
|
||||
) : (
|
||||
|
||||
@@ -20,7 +20,7 @@ export const supervisorEventOptionsHelpContent: HelpContent = {
|
||||
<p>Pick an event, then edit each option's name, price, and "Main ticket" flag directly in the list — changes save when you click away from the field. Use the form below the list to add a new option.</p>
|
||||
<div className="space-y-4">
|
||||
<GuideItem icon={Tag} title="Early-bird tiers" tone="amber">
|
||||
Expand "Manage early-bird tiers" on an option to add deadline-and-price rows that apply automatically before the cutoff.
|
||||
Expand "Manage early-bird tiers" on an option to add deadline-and-price rows that apply automatically before the cutoff. While a tier is running (before its deadline, with places left), the event's card on the home page and events list shows an "Early bird" ribbon in the top-right corner.
|
||||
</GuideItem>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user