Discount
{([["percent", "Percentage", "e.g. 20% off"], ["fixed", "Amount off", "e.g. R50 off"], ["comp", "Free", "100% off"]] as [CouponType, string, string][]).map(([t, name, hint]) => (
set("type", t)} aria-pressed={d.type === t}
className={`text-left rounded-lg border p-2.5 transition-colors ${d.type === t ? "border-brand-500 bg-brand-50 ring-1 ring-brand-500" : "hover:bg-gray-50"}`}>
{name}
{hint}
))}
{d.type !== "comp" && (
{d.type === "percent" ? "Percent off" : "Amount off (R)"}
set("value", e.target.value)} required />
)}
set("stackEarlyBird", e.target.checked)} />
Also apply on top of early-bird prices Off: the better of the two prices wins.
Events
{d.eventIds.length === 0 ? "None picked: the code works for every event." : `${d.eventIds.length} picked. The code only works for ${d.eventIds.length === 1 ? "this event" : "these events"}.`}
{eventChoices.map(ev => (
toggleEvent(ev.id)} />
{ev.title}
{fmtDate(ev.startDate)}{isPast(ev) ? " · past" : ""}
))}
{eventChoices.length === 0 &&
{eventQuery ? "No events match." : "No upcoming events."}
}
Who can use it
set("restrictTo", e.target.value as Draft["restrictTo"])}>
Anyone with the code
People with certain roles
Specific people
An email domain
{d.restrictTo !== "anyone" && (
Restricted codes need the person to be logged in (or registered by staff), so they can't be shared in group chats.
)}
{d.restrictTo === "roles" && (
{(["user", "staff", "supervisor", "admin"] as Role[]).map(r => (
set("restrictRoles", d.restrictRoles.includes(r) ? d.restrictRoles.filter(x => x !== r) : [...d.restrictRoles, r])} />
{r === "user" ? "Member" : r}
))}
)}
{d.restrictTo === "domain" && (
set("restrictDomain", e.target.value)} placeholder="church.org" required />
)}
{d.restrictTo === "users" && (
{d.users.map(u => (
{u.name}
set("users", d.users.filter(x => x.id !== u.id))} aria-label={`Remove ${u.name}`}>
))}
setUserQuery(e.target.value)} placeholder="Search by name, email or phone" />
{userResults.length > 0 && (
{userResults.filter(r => !d.users.some(u => u.id === r.id)).map(r => (
{ set("users", [...d.users, r]); setUserQuery(""); }}>
{r.name} {r.email}
))}
)}
)}