feat(events): promo codes — organizer editor and server-validated checkout discount #153

Merged
padreug merged 6 commits from feat/events-promo-codes into dev 2026-09-13 16:55:15 +00:00
Showing only changes of commit 262e674f9f - Show all commits

fix(events): let the organizer's own record win when merging My Events

The authenticated fetch returns the full Event (incl. extra.promo_codes,
which public responses omit as of events ext v1.6.1-aio.12) and is what
the edit dialog must prefill from. Public records still win for events the
user does not own.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByAwHU4pRnyE58YocQvAas
Padreug 2026-09-10 12:22:13 +02:00

View file

@ -13,9 +13,10 @@ export function useMyEvents() {
// and merge them into the feed. Otherwise an event that drops to
// `proposed` after a non-admin edit disappears from the user's view
// entirely — they'd be unable to find it to make a follow-up edit or
// monitor its approval status. Public approved events from other
// users take precedence on dedup (server is the source of truth for
// the public view).
// monitor its approval status. For the user's OWN events the
// authenticated record wins on dedup: it is the full `Event` (incl.
// `extra.promo_codes`, which public responses omit), and it is what
// the edit dialog must prefill from.
const fetchAll = async (): Promise<TicketedEvent[]> => {
const publicEvents = (await ticketApi.fetchTicketedEvents()) as TicketedEvent[]
@ -26,9 +27,11 @@ export function useMyEvents() {
try {
const myEvents = (await ticketApi.fetchMyEvents(invoiceKey)) as TicketedEvent[]
const seen = new Set(publicEvents.map((e) => e.id))
const own = myEvents.filter((e) => !seen.has(e.id))
return [...publicEvents, ...own]
const own = new Map(myEvents.map((e) => [e.id, e]))
const merged = publicEvents.map((e) => own.get(e.id) ?? e)
const publicIds = new Set(publicEvents.map((e) => e.id))
const ownOnly = myEvents.filter((e) => !publicIds.has(e.id))
return [...merged, ...ownOnly]
} catch (err) {
// Falling back to just the public feed is acceptable — the user
// can still browse, they just won't see their own pending events.