From 7eb6f99e975160acad7e079d6e998474862cc17f Mon Sep 17 00:00:00 2001 From: joshua Date: Thu, 29 Oct 2026 13:04:31 +0200 Subject: [PATCH] WIP 1.51.10: registration management on v2 (routes, frontend) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Ls1vMdg2GYqbnKZmPaX1ot --- apps/events/backend/src/v2/deprecation.ts | 19 +- apps/events/backend/src/v2/index.ts | 1 + .../src/v2/resources/registrationsManage.ts | 214 ++ apps/events/backend/tests/v2.test.ts | 55 + .../dashboard/admin/registrations/page.tsx | 9 +- .../dashboard/supervisor/at-the-door/page.tsx | 52 +- .../supervisor/email-attendees/page.tsx | 3 +- .../app/dashboard/supervisor/forms/page.tsx | 12 +- .../supervisor/manual-registration/page.tsx | 14 +- .../app/dashboard/supervisor/manual/page.tsx | 16 +- .../dashboard/supervisor/payments/page.tsx | 8 +- .../supervisor/whatsapp-attendees/page.tsx | 3 +- .../src/app/dashboard/user/forms/page.tsx | 21 +- .../frontend/src/app/dashboard/user/page.tsx | 32 +- apps/events/frontend/src/app/forms/page.tsx | 23 +- .../src/app/registration/success/page.tsx | 5 +- .../frontend/src/app/self-service/page.tsx | 12 +- .../components/admin/RegistrationBulkBar.tsx | 3 +- .../src/components/reports/ReportsV2.tsx | 2 +- .../src/components/shared/AttendeesPanel.tsx | 7 +- .../frontend/src/lib/api-v2/openapi.json | 2336 +++++++++++++++++ .../frontend/src/lib/api-v2/schema.d.ts | 1440 +++++++++- apps/events/frontend/src/lib/api.ts | 19 +- 23 files changed, 4198 insertions(+), 108 deletions(-) create mode 100644 apps/events/backend/src/v2/resources/registrationsManage.ts diff --git a/apps/events/backend/src/v2/deprecation.ts b/apps/events/backend/src/v2/deprecation.ts index 2ce85ca..44121d6 100644 --- a/apps/events/backend/src/v2/deprecation.ts +++ b/apps/events/backend/src/v2/deprecation.ts @@ -46,6 +46,24 @@ const SUCCESSORS: Successor[] = [ { method: 'POST', v1: /^\/api\/events\/([^/]+)\/copy-from$/, v2: m => `/api/v2/events/${m[1]}/copy-from` }, { method: 'GET', v1: /^\/api\/events\/([^/]+)\/notify-recipients$/, v2: m => `/api/v2/events/${m[1]}/notify-recipients` }, { method: 'PUT', v1: /^\/api\/events\/([^/]+)\/notify-recipients$/, v2: m => `/api/v2/events/${m[1]}/notify-recipients` }, + // 1.51.10: managing registrations + { method: 'GET', v1: /^\/api\/registrations\/?$/, v2: () => '/api/v2/registrations' }, + { method: 'GET', v1: /^\/api\/registrations\/myregistrations$/, v2: () => '/api/v2/me/registrations/full' }, + { method: 'GET', v1: /^\/api\/registrations\/event\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/registrations` }, + { method: 'POST', v1: /^\/api\/registrations\/manual$/, v2: () => '/api/v2/registrations/manual' }, + { method: 'POST', v1: /^\/api\/registrations\/bulk$/, v2: () => '/api/v2/registrations/bulk' }, + { method: 'PUT', v1: /^\/api\/registrations\/([^/]+)\/options$/, v2: m => `/api/v2/registrations/${m[1]}/items` }, + { method: 'POST', v1: /^\/api\/registrations\/([^/]+)\/send-invoice$/, v2: m => `/api/v2/registrations/${m[1]}/invoice` }, + { method: 'POST', v1: /^\/api\/registrations\/([^/]+)\/coupon$/, v2: m => `/api/v2/registrations/${m[1]}/coupon` }, + { method: 'DELETE', v1: /^\/api\/registrations\/([^/]+)\/coupon$/, v2: m => `/api/v2/registrations/${m[1]}/coupon` }, + { method: 'PUT', v1: /^\/api\/registrations\/([^/]+)\/attendees$/, v2: m => `/api/v2/registrations/${m[1]}/attendees` }, + { method: 'POST', v1: /^\/api\/registrations\/([^/]+)\/attendees\/([^/]+)\/send-form-link$/, v2: m => `/api/v2/registrations/${m[1]}/attendees/${m[2]}/form-link` }, + { method: 'GET', v1: /^\/api\/registrations\/([^/]+)\/forms\/draft$/, v2: m => `/api/v2/registrations/${m[1]}/form-draft` }, + { method: 'PUT', v1: /^\/api\/registrations\/([^/]+)\/forms\/draft$/, v2: m => `/api/v2/registrations/${m[1]}/form-draft` }, + { method: 'POST', v1: /^\/api\/registrations\/([^/]+)\/forms\/responses$/, v2: m => `/api/v2/registrations/${m[1]}/form-responses` }, + { method: 'PUT', v1: /^\/api\/registrations\/([^/]+)\/forms\/responses$/, v2: m => `/api/v2/registrations/${m[1]}/form-responses` }, + { method: 'GET', v1: /^\/api\/registrations\/([^/]+)$/, v2: m => `/api/v2/registrations/${m[1]}/full` }, + { method: 'PUT', v1: /^\/api\/registrations\/([^/]+)$/, v2: m => `/api/v2/registrations/${m[1]}/status` }, // 1.51.9: series, season passes, bundles, coupons, campuses { method: 'GET', v1: /^\/api\/series\/?$/, v2: () => '/api/v2/series' }, { method: 'POST', v1: /^\/api\/series\/?$/, v2: () => '/api/v2/series' }, @@ -87,7 +105,6 @@ const SUCCESSORS: Successor[] = [ { method: 'POST', v1: /^\/api\/users\/?$/, v2: () => '/api/v2/auth/signup' }, { method: 'POST', v1: /^\/api\/users\/login$/, v2: () => '/api/v2/auth/login' }, { method: 'POST', v1: /^\/api\/users\/login\/2fa$/, v2: () => '/api/v2/auth/login/code' }, - { method: 'GET', v1: /^\/api\/registrations\/myregistrations$/, v2: () => '/api/v2/me/registrations' }, { method: 'POST', v1: /^\/api\/registrations\/?$/, v2: () => '/api/v2/registrations' }, { method: 'DELETE', v1: /^\/api\/registrations\/([^/]+)$/, v2: m => `/api/v2/registrations/${m[1]}/cancel` }, { method: 'POST', v1: /^\/api\/payments\/checkout$/, v2: () => '/api/v2/registrations/{id}/checkout' }, diff --git a/apps/events/backend/src/v2/index.ts b/apps/events/backend/src/v2/index.ts index d3cfe74..af8a6e2 100644 --- a/apps/events/backend/src/v2/index.ts +++ b/apps/events/backend/src/v2/index.ts @@ -13,6 +13,7 @@ import './resources/seriesDeals'; import './resources/events'; import './resources/me'; import './resources/registrations'; +import './resources/registrationsManage'; import './resources/checkin'; import './resources/auth'; diff --git a/apps/events/backend/src/v2/resources/registrationsManage.ts b/apps/events/backend/src/v2/resources/registrationsManage.ts new file mode 100644 index 0000000..c52bd1a --- /dev/null +++ b/apps/events/backend/src/v2/resources/registrationsManage.ts @@ -0,0 +1,214 @@ +import { z } from 'zod'; +import type { Request } from 'express'; +import { defineRoute, type ApiUser } from '../route'; +import { pageOf, single } from '../paging'; +import { id, idParams } from '../schemas'; +import * as admin from '../../services/registrationAdmin'; + +/* eslint-disable @typescript-eslint/no-explicit-any -- registrations are passed through with their includes */ +const campusScope = require('../../utils/campusScope') as { + listWhere(req: unknown, path?: string): Promise; + scopeEvent(opts?: { need?: 'view' | 'manage'; resolve?: string; from?: (req: any) => unknown; ownerOk?: boolean }): any; + scopeBody(targets: [string, string][], opts?: { need?: 'view' | 'manage'; orphan?: 'pass' | 'deny' }): any; +}; +const { notOnSeasonPass } = require('../../utils/seasonPass') as { notOnSeasonPass: any }; +const plain = (v: T): any => JSON.parse(JSON.stringify(v)); + +/** The v2 request as the registration service's Call. */ +function callFrom(req: Request, user: ApiUser | null, parts: { params?: object; body?: object; query?: object }): admin.Call { + const { getClientIp } = require('../../utils/requestUtils') as { getClientIp(req: unknown): string }; + return { + actor: user ? { id: user.id, role: user.role, email: user.email } : null, + params: (parts.params ?? {}) as Record, + body: parts.body ?? {}, + query: parts.query ?? {}, + readOnly: !!(req as any).readOnly, + ip: getClientIp(req), + listWhere: () => campusScope.listWhere(req, 'event'), + }; +} + +const OWNER_OR_STAFF = 'scopeEvent(registration, owner-ok)'; +const ownerOrStaff = campusScope.scopeEvent({ resolve: 'registration', ownerOk: true }); +const STATUSES = ['pending', 'confirmed', 'partial_paid', 'paid', 'cancelled'] as const; + +/** A registration with everything the dashboards show: items and their prices, payments, attendees, coupons, `totalDueComputed`. */ +const fullRegistration = z.looseObject({ id, status: z.enum(STATUSES), eventId: id, userId: id, totalDueComputed: z.number().optional() }); +const message = single(z.looseObject({ message: z.string() })); +const lineBody = z.object({ eventOptionId: id, variantId: id.nullish(), quantity: z.number().int().min(1).max(1000), sessionIds: z.array(id).max(200).optional() }); +const attendeeBody = z.looseObject({ id: id.optional().describe('An attendee already on it (left out = removed)'), eventOptionId: id, variantId: id.nullish(), name: z.string().max(200) }); +const responsesBody = z.object({ + responses: z.array(z.object({ + attendeeId: id.nullish().describe('The named attendee this form is for'), + answers: z.record(z.string(), z.unknown()).describe('Field id → answer (stored as text)'), + })).max(500), +}); + +// ─── Owner (or staff) ──────────────────────────────────────────────────────── + +export const fullOne = defineRoute({ + method: 'get', path: '/registrations/:id/full', tag: 'Registrations', summary: 'A registration with everything on it', + description: [ + 'Items and prices, payments, coupons and bundles, named attendees, form answers and the total due.', + 'The owner, a named attendee or staff — or anyone with the link when not signed in (registration ids can\'t be guessed). Attendees\' contact details are only shown to the payer and staff.', + ].join('\n\n'), + access: 'optional', campusScope: OWNER_OR_STAFF, middleware: [ownerOrStaff], params: idParams, response: single(fullRegistration), + async handler({ params, user, req }) { return { data: plain(await admin.getRegistrationById(callFrom(req, user, { params }))) }; }, +}); + +export const myFull = defineRoute({ + method: 'get', path: '/me/registrations/full', tag: 'Me', summary: 'My registrations with everything on them', + description: 'What the dashboard shows: as `/registrations/{id}/full`, newest first, with the event and its form. Only upcoming ones unless `past=true`.', + access: 'user', + query: z.object({ past: z.enum(['true', 'false']).default('false') }), + response: z.object({ data: z.array(fullRegistration) }), + async handler({ query, user, req }) { return { data: plain(await admin.getUserRegistrations(callFrom(req, user, { query: { showPast: query.past } }))) }; }, +}); + +export const changeItems = defineRoute({ + method: 'put', path: '/registrations/:id/items', tag: 'Registrations', summary: 'Change the tickets on a registration', + description: [ + 'The whole list of items it should have. Added places need stock and are priced now; places already paid for keep their price, and nothing goes below tickets already issued or the amount paid.', + 'Not for registrations made with a season pass, nor once the event has ended or is closed. Staff can add kids and volunteer places; owners can only keep or lower them.', + ].join('\n\n'), + access: 'user', campusScope: OWNER_OR_STAFF, middleware: [ownerOrStaff, notOnSeasonPass], params: idParams, + body: z.object({ options: z.array(lineBody.omit({ sessionIds: true })).min(1).max(100) }), response: single(fullRegistration), + async handler({ params, body, user, req }) { return { data: plain(await admin.updateRegistrationOptions(callFrom(req, user, { params, body }))) }; }, +}); + +export const sendInvoice = defineRoute({ + method: 'post', path: '/registrations/:id/invoice', tag: 'Registrations', summary: 'Send me the invoice again', + access: 'user', campusScope: OWNER_OR_STAFF, middleware: [ownerOrStaff], params: idParams, + body: z.object({ channel: z.enum(['email', 'whatsapp']).default('email') }), response: message, + async handler({ params, body, user, req }) { return { data: await admin.sendInvoice(callFrom(req, user, { params, body })) }; }, +}); + +export const applyCoupon = defineRoute({ + method: 'post', path: '/registrations/:id/coupon', tag: 'Registrations', summary: 'Apply a coupon code', + description: 'By the owner, or by staff on their behalf (logged). Not on season pass registrations.', + access: 'user', campusScope: OWNER_OR_STAFF, middleware: [ownerOrStaff, notOnSeasonPass], params: idParams, + body: z.object({ code: z.string().trim().min(1).max(40) }), response: single(fullRegistration.extend({ message: z.string() })), + async handler({ params, body, user, req }) { return { data: plain(await admin.applyCoupon(callFrom(req, user, { params, body }))) }; }, +}); + +export const removeCoupon = defineRoute({ + method: 'delete', path: '/registrations/:id/coupon', tag: 'Registrations', summary: 'Take a coupon code off', + description: 'Staff. Its use is freed. Not once a ticket on it has been scanned; unused tickets are withdrawn if it\'s no longer paid.', + access: 'staff', campusScope: 'scopeEvent(registration)', middleware: [campusScope.scopeEvent({ resolve: 'registration' })], params: idParams, response: message, + async handler({ params, user, req }) { return { data: await admin.removeCoupon(callFrom(req, user, { params })) }; }, +}); + +export const setAttendees = defineRoute({ + method: 'put', path: '/registrations/:id/attendees', tag: 'Registrations', summary: 'Name the people on a registration', + description: 'The whole list: attendees left out are removed (not once their ticket has been scanned). `ticketDelivery` says who gets the tickets.', + access: 'user', campusScope: OWNER_OR_STAFF, middleware: [ownerOrStaff], params: idParams, + body: z.object({ attendees: z.array(attendeeBody).max(1000), ticketDelivery: z.enum(['payer', 'each']).optional() }), + response: single(z.looseObject({ id, ticketDelivery: z.string().nullable(), attendees: z.array(z.looseObject({ id, name: z.string() })) })), + async handler({ params, body, user, req }) { return { data: plain(await admin.updateAttendees(callFrom(req, user, { params, body }))) }; }, +}); + +export const sendFormLink = defineRoute({ + method: 'post', path: '/registrations/:id/attendees/:attendeeId/form-link', tag: 'Registrations', summary: 'Send an attendee their form', + description: 'A link to fill in their own attendee form, by email and/or WhatsApp.', + access: 'user', campusScope: OWNER_OR_STAFF, middleware: [ownerOrStaff], params: z.object({ id, attendeeId: id }), response: message, + async handler({ params, user, req }) { return { data: await admin.sendAttendeeFormLink(callFrom(req, user, { params })) }; }, +}); + +export const getDraft = defineRoute({ + method: 'get', path: '/registrations/:id/form-draft', tag: 'Registrations', summary: 'Attendee forms saved part-way', + access: 'optional', campusScope: OWNER_OR_STAFF, middleware: [ownerOrStaff], params: idParams, + response: single(z.object({ data: z.record(z.string(), z.unknown()), updatedAt: z.string().nullable() })), + async handler({ params, user, req }) { return { data: plain(await admin.getFormDraft(callFrom(req, user, { params }))) }; }, +}); + +export const saveDraft = defineRoute({ + method: 'put', path: '/registrations/:id/form-draft', tag: 'Registrations', summary: 'Save attendee forms part-way', + description: 'Kept for the registration\'s owner (also when staff save it), until the forms are submitted.', + access: 'optional', campusScope: OWNER_OR_STAFF, middleware: [ownerOrStaff], params: idParams, + body: z.object({ data: z.record(z.string(), z.unknown()) }), response: single(z.object({ message: z.string(), updatedAt: z.string() })), + async handler({ params, body, user, req }) { return { data: plain(await admin.saveFormDraft(callFrom(req, user, { params, body }))) }; }, +}); + +export const submitForms = defineRoute({ + method: 'post', path: '/registrations/:id/form-responses', tag: 'Registrations', summary: 'Submit attendee forms', + description: 'One response per main ticket at most; each named attendee answers once. Tickets are issued once it\'s paid and the forms are in.', + access: 'optional', campusScope: OWNER_OR_STAFF, middleware: [ownerOrStaff], params: idParams, body: responsesBody, + response: single(z.looseObject({ message: z.string(), count: z.number().int().optional() })), + async handler({ params, body, user, req }) { return { data: plain(await admin.submitFormResponses(callFrom(req, user, { params, body }))) }; }, +}); + +export const replaceForms = defineRoute({ + method: 'put', path: '/registrations/:id/form-responses', tag: 'Registrations', summary: 'Replace the attendee forms', + description: 'Supervisors: every response on the registration is replaced by these.', + access: 'supervisor', campusScope: 'scopeEvent(registration)', middleware: [campusScope.scopeEvent({ resolve: 'registration' })], params: idParams, body: responsesBody, response: message, + async handler({ params, body, user, req }) { return { data: await admin.replaceFormResponses(callFrom(req, user, { params, body })) }; }, +}); + +// ─── Staff ─────────────────────────────────────────────────────────────────── + +export const list = defineRoute({ + method: 'get', path: '/registrations', tag: 'Registrations', summary: 'Every registration (staff)', + description: 'Newest first, for the events you may see. `unpaid=true` for ones still owing; `userId` for one person\'s.', + access: 'staff', campusScope: 'scopeList (listWhere)', + query: z.object({ + page: z.coerce.number().int().min(1).default(1), + limit: z.coerce.number().int().min(1).max(200).default(100).describe('At most 200'), + unpaid: z.enum(['true', 'false']).default('false'), + userId: id.optional(), + }), + response: z.object({ data: z.array(fullRegistration), meta: z.object({ page: z.number().int(), limit: z.number().int(), total: z.number().int(), pages: z.number().int() }) }), + async handler({ query, user, req }) { + const out = await admin.getRegistrations(callFrom(req, user, { query: { page: String(query.page), limit: String(query.limit), unpaid: query.unpaid === 'true' ? '1' : '', userId: query.userId } })); + return pageOf(plain(out.data), out.total, { page: out.page, limit: out.limit }); + }, +}); + +export const forEvent = defineRoute({ + method: 'get', path: '/events/:id/registrations', tag: 'Registrations', summary: 'An event\'s registrations', + description: 'Oldest first, with tickets, payments and attendees. `search` matches the name, email or phone.', + access: 'staff', campusScope: 'scopeEvent(view)', middleware: [campusScope.scopeEvent()], params: idParams, + query: z.object({ search: z.string().max(200).optional() }), + response: z.object({ data: z.array(fullRegistration) }), + async handler({ params, query, user, req }) { return { data: plain(await admin.getRegistrationsByEvent(callFrom(req, user, { params: { eventId: params.id }, query }))) }; }, +}); + +export const setStatus = defineRoute({ + method: 'patch', path: '/registrations/:id/status', tag: 'Registrations', summary: 'Set a registration\'s status', + description: 'Staff. `paid` issues and sends the tickets; leaving `paid` withdraws unused tickets (refused once one has been scanned); `cancelled` frees its places for the waitlist.', + access: 'staff', campusScope: 'scopeEvent(registration)', middleware: [campusScope.scopeEvent({ resolve: 'registration' })], params: idParams, + body: z.object({ status: z.enum(STATUSES) }), response: single(fullRegistration), + async handler({ params, body, user, req }) { return { data: plain(await admin.updateRegistrationStatus(callFrom(req, user, { params, body }))) }; }, +}); + +export const manual = defineRoute({ + method: 'post', path: '/registrations/manual', tag: 'Registrations', summary: 'Register someone (at the door, by phone)', + description: [ + 'Supervisors. Finds the person by email or phone (refused when those are two different accounts) or makes an account and sends them an activation link (`skipActivationNotice` to not).', + 'Added to their existing registration for the event if they have one. Free ones are marked paid and get their tickets; otherwise they\'re sent a link to pay.', + ].join('\n\n'), + access: 'supervisor', campusScope: 'scopeEvent(body.eventId)', middleware: [campusScope.scopeEvent({ from: req => req.body?.eventId })], status: 201, + body: z.looseObject({ + eventId: id, + options: z.array(lineBody).min(1).max(100), + user: z.looseObject({ name: z.string().trim().min(1).max(200), email: z.string().max(200).nullish(), phoneNumber: z.string().max(40).nullish(), password: z.string().max(200).optional().describe('Self-service kiosk: the visitor sets it, and the account is active at once') }), + notificationPreference: z.enum(['email', 'whatsapp', 'both']).optional(), + skipActivationNotice: z.boolean().optional(), + couponCode: z.string().max(40).optional(), + attendees: z.array(attendeeBody).max(1000).optional(), + ticketDelivery: z.enum(['payer', 'each']).optional(), + }), + response: single(fullRegistration.extend({ couponError: z.string().optional() })), + async handler({ body, user, req }) { return { data: plain(await admin.createManualRegistration(callFrom(req, user, { body }))) }; }, +}); + +export const bulk = defineRoute({ + method: 'post', path: '/registrations/bulk', tag: 'Registrations', summary: 'Do one thing to many registrations', + description: '`markPaid`, `cancel`, `moveOption`, `allocate` or `message`, for up to 500 you may manage. Each is done on its own: the answer lists what worked and what didn\'t.', + access: 'supervisor', campusScope: 'scopeBody(registrationIds, deny orphans)', middleware: [campusScope.scopeBody([['registrationIds', 'registration']], { orphan: 'deny' })], + body: z.looseObject({ action: z.enum(['markPaid', 'cancel', 'moveOption', 'allocate', 'message']), registrationIds: z.array(id).min(1).max(500) }), + response: single(z.looseObject({})), + async handler({ body, req }) { + const { runBulk } = require('../../utils/bulkRegistrations') as { runBulk(req: unknown, body: object): Promise }; + return { data: plain(await runBulk(req, body)) }; + }, +}); diff --git a/apps/events/backend/tests/v2.test.ts b/apps/events/backend/tests/v2.test.ts index 3ed4a0e..803e978 100644 --- a/apps/events/backend/tests/v2.test.ts +++ b/apps/events/backend/tests/v2.test.ts @@ -82,6 +82,10 @@ jest.mock('../src/services/deals', () => Object.fromEntries(Object.keys(mockDeal const mockCampuses = { publicCampuses: jest.fn(), campusBySlug: jest.fn(), adminCampuses: jest.fn(), setCampusesEnabled: jest.fn(), createCampus: jest.fn(), updateCampus: jest.fn(), reorderCampuses: jest.fn(), deleteCampus: jest.fn(), campusAudience: jest.fn() }; jest.mock('../src/services/campuses', () => Object.fromEntries(Object.keys(mockCampuses).map(k => [k, (...a: unknown[]) => (mockCampuses as Record)[k](...a)]))); +const mockAdmin = { getRegistrations: jest.fn(), getUserRegistrations: jest.fn(), getRegistrationById: jest.fn(), updateRegistrationStatus: jest.fn(), getRegistrationsByEvent: jest.fn(), createManualRegistration: jest.fn(), updateRegistrationOptions: jest.fn(), submitFormResponses: jest.fn(), replaceFormResponses: jest.fn(), getFormDraft: jest.fn(), saveFormDraft: jest.fn(), sendInvoice: jest.fn(), applyCoupon: jest.fn(), removeCoupon: jest.fn(), updateAttendees: jest.fn(), sendAttendeeFormLink: jest.fn() }; +jest.mock('../src/services/registrationAdmin', () => Object.fromEntries(Object.keys(mockAdmin).map(k => [k, (...a: unknown[]) => (mockAdmin as Record)[k](...a)]))); +jest.mock('../src/utils/seasonPass', () => ({ notOnSeasonPass: (_req: unknown, _res: unknown, next: () => void) => next() })); + import { v2Router } from '../src/v2'; import { ServiceError } from '../src/services/errors'; import { routes } from '../src/v2/route'; @@ -602,3 +606,54 @@ describe('series, deals and campuses', () => { expect((await request(app).put('/api/v2/campuses/enabled').send({ enabled: true })).status).toBe(403); }); }); + +describe('managing registrations', () => { + const reg = { id: 'r1', status: 'pending', eventId: 'e1', userId: 'u1', totalDueComputed: 150, payments: [] }; + + test('a guest with the link can read a registration in full', async () => { + mockAdmin.getRegistrationById.mockResolvedValue(reg); + const res = await request(app).get('/api/v2/registrations/r1/full'); + expect(res.status).toBe(200); + expect(res.body.data).toMatchObject({ id: 'r1', totalDueComputed: 150, payments: [] }); + expect(mockAdmin.getRegistrationById.mock.calls[0][0]).toMatchObject({ actor: null, params: { id: 'r1' } }); + }); + + test('the staff list is paged and campus-scoped', async () => { + signedIn = { id: 'u1', role: 'user' }; + expect((await request(app).get('/api/v2/registrations')).status).toBe(403); + signedIn = { id: 's1', role: 'staff' }; + mockAdmin.getRegistrations.mockResolvedValue({ data: [reg], total: 1, page: 1, limit: 100, pages: 1 }); + const res = await request(app).get('/api/v2/registrations?unpaid=true'); + expect(res.body).toEqual({ data: [reg], meta: { page: 1, limit: 100, total: 1, pages: 1 } }); + const call = mockAdmin.getRegistrations.mock.calls[0][0]; + expect(call.query).toMatchObject({ unpaid: '1', page: '1', limit: '100' }); + expect(typeof call.listWhere).toBe('function'); + }); + + test('a status must be one of the five', async () => { + signedIn = { id: 's1', role: 'staff' }; + const res = await request(app).patch('/api/v2/registrations/r1/status').send({ status: 'refunded' }); + expect(res.status).toBe(400); + expect(res.body.error.code).toBe('VALIDATION_FAILED'); + expect(mockAdmin.updateRegistrationStatus).not.toHaveBeenCalled(); + }); + + test('registering someone at the door is for supervisors, and answers 201', async () => { + const body = { eventId: 'e1', options: [{ eventOptionId: 'o1', quantity: 2 }], user: { name: 'Thandi', phoneNumber: '0821234567' } }; + signedIn = { id: 's1', role: 'staff' }; + expect((await request(app).post('/api/v2/registrations/manual').send(body)).status).toBe(403); + signedIn = { id: 'v1', role: 'supervisor' }; + mockAdmin.createManualRegistration.mockResolvedValue(reg); + const res = await request(app).post('/api/v2/registrations/manual').send(body); + expect(res.status).toBe(201); + expect(mockAdmin.createManualRegistration.mock.calls[0][0].body).toMatchObject(body); + }); + + test("a refusal keeps the service's status", async () => { + signedIn = { id: 'u1', role: 'user' }; + mockAdmin.updateRegistrationOptions.mockRejectedValueOnce(new ServiceError(400, 'Cannot reduce items below the amount already paid')); + const res = await request(app).put('/api/v2/registrations/r1/items').send({ options: [{ eventOptionId: 'o1', quantity: 1 }] }); + expect(res.status).toBe(400); + expect(res.body.error).toMatchObject({ code: 'VALIDATION_FAILED', message: 'Cannot reduce items below the amount already paid' }); + }); +}); diff --git a/apps/events/frontend/src/app/dashboard/admin/registrations/page.tsx b/apps/events/frontend/src/app/dashboard/admin/registrations/page.tsx index 60b9a78..87e1811 100644 --- a/apps/events/frontend/src/app/dashboard/admin/registrations/page.tsx +++ b/apps/events/frontend/src/app/dashboard/admin/registrations/page.tsx @@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useMemo, useState } from "react"; import { useAuth } from "@/hooks/useAuth"; import { useRouter } from "next/navigation"; -import { apiFetch, fetchManagedEvents } from "@/lib/api"; +import { apiFetch, fetchManagedEvents, fetchAllRegistrations } from "@/lib/api"; import { useDismissingState } from "@/hooks/useDismissingState"; import { ClipboardList } from "lucide-react"; import { errorMessage } from "@/lib/utils"; @@ -12,6 +12,7 @@ import { BackLink } from "@/components/shared/BackLink"; import { RegistrationBulkBar } from "@/components/admin/RegistrationBulkBar"; import { SavedFilters } from "@/components/shared/SavedFilters"; import { EventPicker } from "@/components/shared/EventPicker"; +import { apiV2Data } from "@/lib/apiV2"; const STATUS_OPTIONS = ["pending", "confirmed", "partial_paid", "paid", "cancelled"] as const; @@ -80,7 +81,7 @@ export default function AdminRegistrationsPage() { if (!token) return; try { setLoadingRegs(true); - const regs = await apiFetch("/api/registrations", { authToken: token }); + const regs = await fetchAllRegistrations(token); const list = Array.isArray(regs) ? regs.sort((a, b) => { const eventCompare = (a.event?.startDate || a.eventId).localeCompare(b.event?.startDate || b.eventId); if (eventCompare !== 0) return eventCompare; @@ -140,7 +141,7 @@ export default function AdminRegistrationsPage() { setError(null); setInfo(null); if (!confirm(`Cancel registration #${String(reg.id).slice(0, 8)} for ${reg.user?.name || reg.userId}?`)) return; try { - await apiFetch(`/api/registrations/${encodeURIComponent(reg.id)}`, { method: "DELETE", authToken: token }); + await apiV2Data("post", "/registrations/{id}/cancel", { params: { id: reg.id }, authToken: token }); setInfo("Registration cancelled"); await loadRegistrations(); } catch (e) { @@ -152,7 +153,7 @@ export default function AdminRegistrationsPage() { if (!token) return; setError(null); setInfo(null); try { - await apiFetch(`/api/registrations/${encodeURIComponent(reg.id)}`, { method: "PUT", authToken: token, body: { status } }); + await apiV2Data("patch", "/registrations/{id}/status", { params: { id: reg.id }, authToken: token, body: { status: status as "pending" | "confirmed" | "partial_paid" | "paid" | "cancelled" } }); setInfo("Status updated"); await loadRegistrations(); } catch (e) { diff --git a/apps/events/frontend/src/app/dashboard/supervisor/at-the-door/page.tsx b/apps/events/frontend/src/app/dashboard/supervisor/at-the-door/page.tsx index c87b778..95eb7d3 100644 --- a/apps/events/frontend/src/app/dashboard/supervisor/at-the-door/page.tsx +++ b/apps/events/frontend/src/app/dashboard/supervisor/at-the-door/page.tsx @@ -19,7 +19,7 @@ import { bookableSessions, choosesSessions, isPickOption, todaysSession } from " import { SessionPicker } from "@/components/events/SessionPicker"; import type { Event, EventOption, PublicBundle, Registration, Ticket as TicketRecord, UserSummary } from "@/types"; import { EventPicker } from "@/components/shared/EventPicker"; -import { apiV2 } from "@/lib/apiV2"; +import { apiV2, apiV2Data } from "@/lib/apiV2"; type NewAttendee = { name: string; email: string | null; phone: string | null; notifPref: "email" | "whatsapp" | "both" }; @@ -265,20 +265,20 @@ export default function AtTheDoorPage() { try { if (pendingEditReg) { // Edit existing registration — replace options via PUT - let res = await apiFetch(`/api/registrations/${pendingEditReg.id}/options`, { - method: "PUT", - authToken: token, - body: { options: opts } - }); + let res = await (apiV2Data("put", "/registrations/{id}/items", { + params: { id: pendingEditReg.id }, + authToken: token, + body: { options: opts }, + }) as Promise); let message = "Registration updated"; if (doorCoupon) { // Applied after the items are saved, so it's worked out on the final items. try { - res = await apiFetch(`/api/registrations/${pendingEditReg.id}/coupon`, { - method: "POST", - authToken: token, - body: { code: doorCoupon.code }, - }); + res = await (apiV2Data("post", "/registrations/{id}/coupon", { + params: { id: pendingEditReg.id }, + authToken: token, + body: { code: doorCoupon.code }, + }) as Promise); message = `Registration updated — code ${doorCoupon.code} applied`; } catch (ce) { message = `Registration updated, but the code wasn't applied: ${errorMessage(ce) || "unknown error"}`; @@ -290,10 +290,9 @@ export default function AtTheDoorPage() { handleRegistrationSelected(res); } else if (pendingUser) { // New attendee - const res = await apiFetch("/api/registrations/manual", { - method: "POST", - authToken: token, - body: { + const res = await (apiV2Data("post", "/registrations/manual", { + authToken: token, + body: { eventId, user: { name: pendingUser.name, @@ -306,8 +305,8 @@ export default function AtTheDoorPage() { ...(doorAllowsNames && (doorNaming || doorYouthStart) && attendeesPayload(nameOptions, (o, v) => quantities[v ? `${o}::${v}` : o] || 0, doorEntries).length > 0 ? { attendees: attendeesPayload(nameOptions, (o, v) => quantities[v ? `${o}::${v}` : o] || 0, doorEntries), ticketDelivery: doorDelivery } : {}), - } - }); + }, + }) as Promise); setShowOptionsModal(false); if (res?.couponError) setError(`Registered, but the code wasn't applied: ${res.couponError}`); handleRegistrationCreated(res); @@ -360,7 +359,7 @@ export default function AtTheDoorPage() { const handleEditRegistration = async (reg: Registration) => { let freshReg = reg; try { - freshReg = await apiFetch(`/api/registrations/${reg.id}`, { authToken: token }); + freshReg = await (apiV2Data("get", "/registrations/{id}/full", { params: { id: reg.id }, authToken: token }) as Promise); } catch (e) { setError(errorMessage(e) || "Failed to load latest registration data"); return; @@ -575,7 +574,7 @@ function DoorRegistrationPanel({ token, eventId, onSelected, onEditRegistration, const load = async () => { try { setLoading(true); - const regs = await apiFetch(`/api/registrations/event/${eventId}`, { authToken: token }); + const regs = await (apiV2Data("get", "/events/{id}/registrations", { params: { id: eventId }, authToken: token }) as Promise); if (!cancelled) setAllRegs(regs || []); } catch { if (!cancelled) setAllRegs([]); @@ -601,7 +600,7 @@ function DoorRegistrationPanel({ token, eventId, onSelected, onEditRegistration, if (!token || !eventId) return; try { setLoading(true); - const regs = await apiFetch(`/api/registrations/event/${eventId}`, { authToken: token }); + const regs = await (apiV2Data("get", "/events/{id}/registrations", { params: { id: eventId }, authToken: token }) as Promise); setAllRegs(regs || []); } catch {} finally { setLoading(false); } }} @@ -715,9 +714,10 @@ function DoorPaymentPanel({ token, registration, onSuccess, setError }: { } }); - const updated = await apiFetch(`/api/registrations/${registration.id}`, { - authToken: token - }); + const updated = await (apiV2Data("get", "/registrations/{id}/full", { + params: { id: registration.id }, + authToken: token, + }) as Promise); const updatedBalance = Math.max(0, registrationTotal(updated) - totalPaidOn(updated)); @@ -1677,7 +1677,7 @@ function RefundModal({ open, onClose, token, registration, maxRefund, onRefunded } }); // Re-fetch registration to get updated status & payments - const updated = await apiFetch(`/api/registrations/${registration.id}`, { authToken: token }); + const updated = await (apiV2Data("get", "/registrations/{id}/full", { params: { id: registration.id }, authToken: token }) as Promise); onRefunded(updated); } catch (e) { setLocalError(errorMessage(e) || "Refund failed."); @@ -1778,7 +1778,7 @@ function DoorRefundPanel({ token, eventId, setInfo }: { if (!token || !eventId) return; try { setLoading(true); - const regs = await apiFetch(`/api/registrations/event/${eventId}`, { authToken: token }); + const regs = await (apiV2Data("get", "/events/{id}/registrations", { params: { id: eventId }, authToken: token }) as Promise); setAllRegs(regs || []); } catch { setAllRegs([]); @@ -1800,7 +1800,7 @@ function DoorRefundPanel({ token, eventId, setInfo }: { setSelectedReg(updated); setInfo("Refund recorded"); // Refresh list - const regs = await apiFetch(`/api/registrations/event/${eventId}`, { authToken: token }).catch(() => null); + const regs = await (apiV2Data("get", "/events/{id}/registrations", { params: { id: eventId }, authToken: token }) as Promise).catch(() => null); if (regs) setAllRegs(regs); }; diff --git a/apps/events/frontend/src/app/dashboard/supervisor/email-attendees/page.tsx b/apps/events/frontend/src/app/dashboard/supervisor/email-attendees/page.tsx index 66cba80..2d28727 100644 --- a/apps/events/frontend/src/app/dashboard/supervisor/email-attendees/page.tsx +++ b/apps/events/frontend/src/app/dashboard/supervisor/email-attendees/page.tsx @@ -13,6 +13,7 @@ import { BackLink } from "@/components/shared/BackLink"; import { MessageKindPicker, matchedText, type MessageKind } from "@/components/shared/MessageKindPicker"; import { CampusAudiencePicker } from "@/components/shared/CampusAudiencePicker"; import { EventPicker } from "@/components/shared/EventPicker"; +import { apiV2Data } from "@/lib/apiV2"; type Attendee = { id: string; name: string; email: string; pref: string }; type TemplateKey = 'custom'|'payment_reminder'|'event_reminder'|'tickets'; @@ -390,7 +391,7 @@ function EmailAttendeesPageInner() { setAttendees([]); setSelectedAttendeeIds([]); if (!eventId || !token) return; - const regs = await apiFetch(`/api/registrations/event/${encodeURIComponent(eventId)}`, { authToken: token }); + const regs = await (apiV2Data("get", "/events/{id}/registrations", { params: { id: eventId }, authToken: token }) as Promise); const uniq = new Map(); (regs || []).forEach((r) => { const u: User | undefined = r?.user; diff --git a/apps/events/frontend/src/app/dashboard/supervisor/forms/page.tsx b/apps/events/frontend/src/app/dashboard/supervisor/forms/page.tsx index c6f0984..c3dc341 100644 --- a/apps/events/frontend/src/app/dashboard/supervisor/forms/page.tsx +++ b/apps/events/frontend/src/app/dashboard/supervisor/forms/page.tsx @@ -11,7 +11,7 @@ import { errorMessage } from "@/lib/utils"; import type { Event, EventForm, FormResponse, Registration, User } from "@/types"; import { BackLink } from "@/components/shared/BackLink"; import { EventPicker } from "@/components/shared/EventPicker"; -import { apiV2 } from "@/lib/apiV2"; +import { apiV2, apiV2Data } from "@/lib/apiV2"; type FormFieldType = 'yes_no' | 'text' | 'date' | 'numeric' | 'statement' | 'paragraph' | 'rating' | 'multiple_choice'; @@ -350,7 +350,7 @@ export default function FormsBrowserPage() { if (!token || !evId) return; try { setLoadingRegs(true); - const regs = await apiFetch(`/api/registrations/event/${encodeURIComponent(evId)}`, { authToken: token }); + const regs = await (apiV2Data("get", "/events/{id}/registrations", { params: { id: evId }, authToken: token }) as Promise); const sorted = (Array.isArray(regs) ? regs : []).sort((a, b) => (a.user?.name || '').toLowerCase().localeCompare((b.user?.name || '').toLowerCase())); setFillRegistrations(sorted); } catch { @@ -374,7 +374,7 @@ export default function FormsBrowserPage() { (async () => { if (mode !== 'fill' || !fillRegistrationId) return; try { - const reg = await apiFetch(`/api/registrations/${encodeURIComponent(fillRegistrationId)}`, { authToken: token! }); + const reg = await (apiV2Data("get", "/registrations/{id}/full", { params: { id: fillRegistrationId }, authToken: token }) as Promise); setFillRegistration(reg); if (reg?.event?.id) { const evFull = await fetchEvent(reg.event.id); @@ -435,8 +435,10 @@ export default function FormsBrowserPage() { if (v == null || String(v).trim() === '') throw new Error(`Response #${i+1}: Missing answer for a required field`); } } - await apiFetch(`/api/registrations/${encodeURIComponent(fillRegistrationId)}/forms/responses`, { - method: 'PUT', authToken: token, body: { responses: editableResponses } + await apiV2Data("put", "/registrations/{id}/form-responses", { + params: { id: fillRegistrationId }, + authToken: token, + body: { responses: editableResponses }, }); setInfo('Responses saved'); const resList = await apiFetch<{ items?: FormResponse[] } | FormResponse[]>(`/api/forms/responses?registrationId=${encodeURIComponent(fillRegistrationId)}`, { authToken: token! }); diff --git a/apps/events/frontend/src/app/dashboard/supervisor/manual-registration/page.tsx b/apps/events/frontend/src/app/dashboard/supervisor/manual-registration/page.tsx index 40c6414..30b50a2 100644 --- a/apps/events/frontend/src/app/dashboard/supervisor/manual-registration/page.tsx +++ b/apps/events/frontend/src/app/dashboard/supervisor/manual-registration/page.tsx @@ -4,12 +4,13 @@ import { ExtraFieldInput, isExtraFieldType } from "@/components/shared/FormField import React, { useEffect, useState } from "react"; import { useAuth } from "@/hooks/useAuth"; import { useRouter } from "next/navigation"; -import { apiFetch, fetchEvent } from "@/lib/api"; +import { fetchEvent } from "@/lib/api"; import { useDismissingState } from "@/hooks/useDismissingState"; import { UserPlus } from "lucide-react"; import { errorMessage } from "@/lib/utils"; import type { Registration } from "@/types"; import { BackLink } from "@/components/shared/BackLink"; +import { apiV2Data } from "@/lib/apiV2"; type FormField = { id: string; type: 'yes_no'|'text'|'date'|'numeric'|'statement'|'paragraph'|'rating'|'multiple_choice'; label: string; isRequired?: boolean; helpText?: string|null; options?: unknown }; @@ -39,15 +40,14 @@ export default function ManualRegistrationPage() { setBusy(true); setError(null); try { - const res = await apiFetch("/api/registrations/manual", { - method: "POST", + const res = await (apiV2Data("post", "/registrations/manual", { authToken: token, body: { eventId, options: [{ eventOptionId: optionId, quantity }], user: { name, ...(email ? { email } : {}), ...(phoneNumber ? { phoneNumber } : {}) }, }, - }); + }) as Promise); setCreatedReg(res); // Load form definition for this event (if any) try { @@ -154,8 +154,10 @@ function AttendeeFormsSection({ registration, form, formsData, setFormsData }: { setError(null); setInfo(null); const payload: { answers: Record }[] = []; for (let i = 0; i < count; i++) payload.push({ answers: formsData[i] || {} }); - await apiFetch(`/api/registrations/${encodeURIComponent(registration.id)}/forms/responses`, { - method: 'POST', authToken: token, body: { responses: payload } + await apiV2Data("post", "/registrations/{id}/form-responses", { + params: { id: registration.id }, + authToken: token, + body: { responses: payload }, }); setInfo('Attendee forms submitted successfully.'); } catch (e) { diff --git a/apps/events/frontend/src/app/dashboard/supervisor/manual/page.tsx b/apps/events/frontend/src/app/dashboard/supervisor/manual/page.tsx index ea9f7d1..f43eaa2 100644 --- a/apps/events/frontend/src/app/dashboard/supervisor/manual/page.tsx +++ b/apps/events/frontend/src/app/dashboard/supervisor/manual/page.tsx @@ -3,7 +3,7 @@ import React, { useEffect, useMemo, useRef, useState } from "react"; import { useAuth } from "@/hooks/useAuth"; import { useRouter } from "next/navigation"; -import { apiFetch, fetchAllUsers, fetchManagedEvents, fetchEvent } from "@/lib/api"; +import { apiFetch, fetchAllUsers, fetchManagedEvents, fetchEvent, fetchAllRegistrations } from "@/lib/api"; import { scoreUser } from "@/lib/fuzzyMatch"; import { useDismissingState } from "@/hooks/useDismissingState"; import { CouponCodeField, AppliedCoupon } from "@/components/shared/CouponCodeField"; @@ -17,6 +17,7 @@ import { SessionPicker } from "@/components/events/SessionPicker"; import type { Event, EventOption, PublicBundle, Registration, RegistrationOption, User } from "@/types"; import { BackLink } from "@/components/shared/BackLink"; import { EventPicker } from "@/components/shared/EventPicker"; +import { apiV2Data } from "@/lib/apiV2"; // ─── Pricing helpers ───────────────────────────────────────────────────────── @@ -24,7 +25,7 @@ function fmtPrice(n: number) { return n === 0 ? "Free" : `R ${n.toFixed(2)}`; } -// Effective unit price for an existing registration option (as returned by /api/registrations). +// Effective unit price for an existing registration option (as returned by /api/v2/registrations). // Prefers priceSnapshot (authoritative price captured at registration time) and only falls // back to a live early-bird calculation for legacy rows without a snapshot. function optionUnitPrice(opt: RegistrationOption): number { @@ -103,7 +104,7 @@ export default function ManualRegistrationPage() { // balances can be computed without a per-registration fetch loop). useEffect(() => { if (!token) return; - apiFetch("/api/registrations", { authToken: token }) + fetchAllRegistrations(token) .then(regs => setAllRegistrations(Array.isArray(regs) ? regs : [])) .catch(() => {}); }, [token]); @@ -180,7 +181,7 @@ export default function ManualRegistrationPage() { setPayPaidAtLocal(""); // Refresh registrations so the displayed outstanding balance updates try { - const regs = await apiFetch("/api/registrations", { authToken: token }); + const regs = await fetchAllRegistrations(token); setAllRegistrations(Array.isArray(regs) ? regs : []); } catch {} } catch (e) { @@ -346,8 +347,7 @@ export default function ManualRegistrationPage() { const hasEmail = !!guest.email.trim(); const hasPhone = !!guest.phoneNumber.trim(); const resolvedPref = hasEmail && hasPhone ? notifPref : hasPhone ? "whatsapp" : "email"; - const res = await apiFetch("/api/registrations/manual", { - method: "POST", + const res = await (apiV2Data("post", "/registrations/manual", { authToken: token, body: { eventId: selectedEventId, @@ -358,8 +358,8 @@ export default function ManualRegistrationPage() { ...(selectedEventAllowsNames && (namingOthers || selectedIsYouth) && attendeesPayload(options, manualQtyFor, attendeeEntries).length > 0 ? { attendees: attendeesPayload(options, manualQtyFor, attendeeEntries), ticketDelivery: delivery } : {}), - } - }); + }, + }) as Promise); setMessage(res?.couponError ? `Manual registration created, but the code wasn't applied: ${res.couponError}` : coupon ? `Manual registration created with code ${coupon.code}.` : "Manual registration created successfully."); diff --git a/apps/events/frontend/src/app/dashboard/supervisor/payments/page.tsx b/apps/events/frontend/src/app/dashboard/supervisor/payments/page.tsx index 949db67..e2691ec 100644 --- a/apps/events/frontend/src/app/dashboard/supervisor/payments/page.tsx +++ b/apps/events/frontend/src/app/dashboard/supervisor/payments/page.tsx @@ -3,7 +3,7 @@ import React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useAuth } from "@/hooks/useAuth"; import { useRouter, useSearchParams } from "next/navigation"; -import { apiFetch, fetchAllUsers, fetchAllPayments, fetchManagedEvents } from "@/lib/api"; +import { apiFetch, fetchAllUsers, fetchAllPayments, fetchManagedEvents, fetchAllRegistrations } from "@/lib/api"; import { useDismissingState } from "@/hooks/useDismissingState"; import { scoreUser } from "@/lib/fuzzyMatch"; import { Wallet, RotateCcw, HandHeart, ScanLine, Link2 } from "lucide-react"; @@ -209,14 +209,14 @@ function PaymentsContent() { useEffect(() => { loadPayments(); }, [loadPayments]); - // Registrations still owing (not paid or cancelled), for the dropdowns. GET /api/registrations + // Registrations still owing (not paid or cancelled), for the dropdowns. GET /api/v2/registrations // embeds each registration's `payments`, so balances come from that in one pass. Refunds load // the chosen person's own registrations (including paid ones) when needed. const loadRegistrations = useCallback(async () => { if (!token) return; try { setLoadingRegs(true); - const regs = await apiFetch("/api/registrations?unpaid=1", { authToken: token }); + const regs = await fetchAllRegistrations(token, { unpaid: true }); const list = Array.isArray(regs) ? regs : []; setRegOutstanding(computeOutstanding(list)); // Sort by createdAt desc @@ -891,7 +891,7 @@ function RefundSection({ allUsers, onDone }: RefundSectionProps) { setLoadingUser(true); Promise.all([ fetchAllPayments(token, { userId }), - apiFetch(`/api/registrations?userId=${encodeURIComponent(userId)}`, { authToken: token }), + fetchAllRegistrations(token, { userId }), ]).then(([p, r]) => { if (cancelled) return; setPayments(p); diff --git a/apps/events/frontend/src/app/dashboard/supervisor/whatsapp-attendees/page.tsx b/apps/events/frontend/src/app/dashboard/supervisor/whatsapp-attendees/page.tsx index 267b8cd..b96198c 100644 --- a/apps/events/frontend/src/app/dashboard/supervisor/whatsapp-attendees/page.tsx +++ b/apps/events/frontend/src/app/dashboard/supervisor/whatsapp-attendees/page.tsx @@ -13,6 +13,7 @@ import { BackLink } from "@/components/shared/BackLink"; import { MessageKindPicker, matchedText, type MessageKind } from "@/components/shared/MessageKindPicker"; import { CampusAudiencePicker } from "@/components/shared/CampusAudiencePicker"; import { EventPicker } from "@/components/shared/EventPicker"; +import { apiV2Data } from "@/lib/apiV2"; // Attendee with preference info type Attendee = { id: string; name: string; phone: string; pref: string }; @@ -426,7 +427,7 @@ function WhatsAppAttendeesPageInner() { try { setLoadingAttendees(true); setAttendees([]); setSelectedAttendeeIds([]); if (!eventId || !token) return; - const regs = await apiFetch(`/api/registrations/event/${encodeURIComponent(eventId)}`, { authToken: token }); + const regs = await (apiV2Data("get", "/events/{id}/registrations", { params: { id: eventId }, authToken: token }) as Promise); const uniq = new Map(); (regs || []).forEach((r) => { const u: User | undefined = r?.user; diff --git a/apps/events/frontend/src/app/dashboard/user/forms/page.tsx b/apps/events/frontend/src/app/dashboard/user/forms/page.tsx index 0605e54..0d59bc7 100644 --- a/apps/events/frontend/src/app/dashboard/user/forms/page.tsx +++ b/apps/events/frontend/src/app/dashboard/user/forms/page.tsx @@ -3,12 +3,13 @@ import { ExtraFieldInput, isExtraFieldType } from "@/components/shared/FormField import React, { Suspense, useEffect, useMemo, useState } from "react"; import { useSearchParams, useRouter } from "next/navigation"; import { useAuth } from "@/hooks/useAuth"; -import { apiFetch, fetchEvent } from "@/lib/api"; +import { fetchEvent } from "@/lib/api"; import { useDismissingState } from "@/hooks/useDismissingState"; import { FileText } from "lucide-react"; import { errorMessage } from "@/lib/utils"; import type { Registration } from "@/types"; import { BackLink } from "@/components/shared/BackLink"; +import { apiV2Data } from "@/lib/apiV2"; // Types for form fields type FormField = { id: string; type: 'yes_no'|'text'|'date'|'numeric'|'statement'|'paragraph'|'rating'|'multiple_choice'; label: string; isRequired?: boolean; helpText?: string|null; options?: unknown }; @@ -35,13 +36,13 @@ function FormsContent() { setError(null); setInfo(null); try { - const reg = await apiFetch(`/api/registrations/${encodeURIComponent(registrationId)}`, { authToken: token }); + const reg = await (apiV2Data("get", "/registrations/{id}/full", { params: { id: registrationId }, authToken: token }) as Promise); setRegistration(reg); const ev = await fetchEvent<{ form?: { isRequired: boolean; fields: FormField[] } | null }>(reg.eventId); if (ev?.form) setEventForm(ev.form); // Load any saved draft try { - const draft = await apiFetch<{ data?: Record> } | null>(`/api/registrations/${encodeURIComponent(registrationId)}/forms/draft`, { authToken: token }); + const draft = await (apiV2Data("get", "/registrations/{id}/form-draft", { params: { id: registrationId }, authToken: token }) as Promise<{ data?: Record> } | null>); if (draft && draft.data && typeof draft.data === 'object') setFormsData(draft.data); } catch {} } catch (e) { @@ -99,14 +100,14 @@ function FormsContent() { setInfo('No remaining attendee forms to submit.'); return; } - await apiFetch(`/api/registrations/${encodeURIComponent(registrationId)}/forms/responses`, { - method: 'POST', + await apiV2Data("post", "/registrations/{id}/form-responses", { + params: { id: registrationId }, authToken: token, - body: { responses: payload } + body: { responses: payload }, }); setInfo('Attendee forms submitted successfully.'); // reload registration to reflect new responses - const reg = await apiFetch(`/api/registrations/${encodeURIComponent(registrationId)}`, { authToken: token }); + const reg = await (apiV2Data("get", "/registrations/{id}/full", { params: { id: registrationId }, authToken: token }) as Promise); setRegistration(reg); setFormsData({}); // On success, redirect to the user dashbaord @@ -120,10 +121,10 @@ function FormsContent() { if (!token || !registrationId) return; try { setError(null); setInfo(null); - await apiFetch(`/api/registrations/${encodeURIComponent(registrationId)}/forms/draft`, { - method: 'PUT', + await apiV2Data("put", "/registrations/{id}/form-draft", { + params: { id: registrationId }, authToken: token, - body: { data: formsData } + body: { data: formsData }, }); setInfo('Draft saved. You can return later to finish.'); } catch (e) { diff --git a/apps/events/frontend/src/app/dashboard/user/page.tsx b/apps/events/frontend/src/app/dashboard/user/page.tsx index e88ebdf..c49672c 100644 --- a/apps/events/frontend/src/app/dashboard/user/page.tsx +++ b/apps/events/frontend/src/app/dashboard/user/page.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from "react"; import { useAuth } from "@/hooks/useAuth"; import { apiFetch, createFullPaymentCheckout, fetchEvent } from "@/lib/api"; -import { apiV2 } from "@/lib/apiV2"; +import { apiV2, apiV2Data } from "@/lib/apiV2"; import { useOnlinePayments } from "@/lib/onlinePayments"; import { useRouter } from "next/navigation"; import { formatDate } from "@/lib/date"; @@ -124,7 +124,7 @@ export default function UserDashboardPage() { // waterfalling — this was previously fetched only after registrations + all // their payments had already resolved. const [myRegs, myTicks] = await Promise.all([ - apiFetch(`/api/registrations/myregistrations?showPast=${showPast ? '1' : '0'}`, { authToken: token }), + (apiV2Data("get", "/me/registrations/full", { query: { past: showPast ? "true" : "false" }, authToken: token }) as Promise), apiFetch("/api/tickets/mytickets", { authToken: token }), ]); setRegistrations(myRegs); @@ -189,7 +189,7 @@ export default function UserDashboardPage() { return; } // Load registration to get number of submitted responses - const regFull = await apiFetch(`/api/registrations/${encodeURIComponent(r.id)}`, { authToken: token }); + const regFull = await (apiV2Data("get", "/registrations/{id}/full", { params: { id: r.id }, authToken: token }) as Promise); const submittedCount = (regFull?.formResponses || []).length; // Required count equals the number of main tickets purchased const requiredCount = (r.registrationOptions || []) @@ -273,11 +273,11 @@ export default function UserDashboardPage() { loadingSubtitle: "Please wait while we prepare your invoice.", }); try { - const res = await apiFetch<{ message?: string }>(`/api/registrations/${encodeURIComponent(registrationId)}/send-invoice`, { - method: "POST", + const res = await (apiV2Data("post", "/registrations/{id}/invoice", { + params: { id: registrationId }, body: { channel }, authToken: token, - }); + }) as Promise<{ message?: string }>); setDialog({ open: true, loading: false, title: "Invoice sent", message: (res && res.message) || "Invoice sent." }); } catch (e) { setDialog({ open: false, message: "", loading: false }); @@ -332,7 +332,7 @@ export default function UserDashboardPage() { // Refresh this registration's billing so the displayed outstanding reflects the new price try { const now = new Date(); - const r = await apiFetch(`/api/registrations/${encodeURIComponent(registrationId)}`, { authToken: token }); + const r = await (apiV2Data("get", "/registrations/{id}/full", { params: { id: registrationId }, authToken: token }) as Promise); const pays = await apiFetch(`/api/payments/registration/${encodeURIComponent(registrationId)}`, { authToken: token }); const totalPaid = pays.reduce((s, p) => s + (p.amount || 0), 0); const totalDue = (r.registrationOptions || []).reduce((sum, opt) => sum + registrationOptionUnitPrice(opt, null, now) * (opt.quantity || 0), 0); @@ -409,12 +409,12 @@ export default function UserDashboardPage() { setCodeBusy(true); setCodeError(null); try { - const res = await apiFetch<{ message?: string }>(`/api/registrations/${encodeURIComponent(activeRegId)}/coupon`, { - method: 'POST', + const res = await (apiV2Data("post", "/registrations/{id}/coupon", { + params: { id: activeRegId }, authToken: token, body: { code: codeInput.trim() }, - }); - const myRegs = await apiFetch(`/api/registrations/myregistrations?showPast=${showPast ? '1' : '0'}`, { authToken: token }); + }) as Promise<{ message?: string }>); + const myRegs = await (apiV2Data("get", "/me/registrations/full", { query: { past: showPast ? "true" : "false" }, authToken: token }) as Promise); setRegistrations(myRegs); const updated = myRegs.find(r => r.id === activeRegId); const pays = await apiFetch(`/api/payments/registration/${encodeURIComponent(activeRegId)}`, { authToken: token }); @@ -440,7 +440,7 @@ export default function UserDashboardPage() { const reloadAfterAttendees = async () => { if (!token) return; try { - const myRegs = await apiFetch(`/api/registrations/myregistrations?showPast=${showPast ? '1' : '0'}`, { authToken: token }); + const myRegs = await (apiV2Data("get", "/me/registrations/full", { query: { past: showPast ? "true" : "false" }, authToken: token }) as Promise); setRegistrations(myRegs); const myTicks = await apiFetch("/api/tickets/mytickets", { authToken: token }); setTickets(myTicks); @@ -456,7 +456,7 @@ export default function UserDashboardPage() { setCancelLoading(true); try { await apiV2("post", "/registrations/{id}/cancel", { params: { id: activeRegId }, authToken: token }); - const myRegs = await apiFetch(`/api/registrations/myregistrations?showPast=${showPast ? '1' : '0'}`, { authToken: token }); + const myRegs = await (apiV2Data("get", "/me/registrations/full", { query: { past: showPast ? "true" : "false" }, authToken: token }) as Promise); setRegistrations(myRegs); setActiveRegId(null); setShowCancelConfirm(false); @@ -593,13 +593,13 @@ export default function UserDashboardPage() { } setLoading(true); try { - await apiFetch(`/api/registrations/${encodeURIComponent(activeReg.id)}/options`, { - method: 'PUT', + await apiV2Data("put", "/registrations/{id}/items", { + params: { id: activeReg.id }, authToken: token, body: { options: payloadOptions }, }); // Reload registrations to reflect changes - const myRegs = await apiFetch(`/api/registrations/myregistrations?showPast=${showPast ? '1' : '0'}`, { authToken: token }); + const myRegs = await (apiV2Data("get", "/me/registrations/full", { query: { past: showPast ? "true" : "false" }, authToken: token }) as Promise); setRegistrations(myRegs); try { const myTicks = await apiFetch("/api/tickets/mytickets", { authToken: token }); diff --git a/apps/events/frontend/src/app/forms/page.tsx b/apps/events/frontend/src/app/forms/page.tsx index dd2e568..6533e48 100644 --- a/apps/events/frontend/src/app/forms/page.tsx +++ b/apps/events/frontend/src/app/forms/page.tsx @@ -3,12 +3,13 @@ import { ExtraFieldInput, isExtraFieldType } from "@/components/shared/FormField import React, { Suspense, useEffect, useMemo, useState } from "react"; import { useSearchParams, useRouter } from "next/navigation"; import { useAuth } from "@/hooks/useAuth"; -import { apiFetch, fetchEvent } from "@/lib/api"; +import { fetchEvent } from "@/lib/api"; import { Navbar } from "@/components/layout/Navbar"; import { Footer } from "@/components/layout/Footer"; import { FileText } from "lucide-react"; import { errorMessage } from "@/lib/utils"; import type { Registration } from "@/types"; +import { apiV2Data } from "@/lib/apiV2"; // Types for form fields type FormField = { id: string; type: 'yes_no'|'text'|'date'|'numeric'|'statement'|'paragraph'|'rating'|'multiple_choice'; label: string; isRequired?: boolean; helpText?: string|null; options?: unknown }; @@ -40,13 +41,13 @@ function FormsContent() { setInfo(null); try { // authToken optional — guests access via registrationId alone - const reg = await apiFetch(`/api/registrations/${encodeURIComponent(registrationId)}`, { authToken: token || undefined }); + const reg = await (apiV2Data("get", "/registrations/{id}/full", { params: { id: registrationId }, authToken: token }) as Promise); setRegistration(reg); const ev = await fetchEvent<{ form?: { isRequired: boolean; fields: FormField[] } | null }>(reg.eventId); if (ev?.form) setEventForm(ev.form); // Load any saved draft to prefill fields try { - const draft = await apiFetch<{ data?: Record> } | null>(`/api/registrations/${encodeURIComponent(registrationId)}/forms/draft`, { authToken: token || undefined }); + const draft = await (apiV2Data("get", "/registrations/{id}/form-draft", { params: { id: registrationId }, authToken: token }) as Promise<{ data?: Record> } | null>); if (draft && draft.data && typeof draft.data === 'object') setFormsData(draft.data); } catch {} } catch (e) { @@ -124,10 +125,10 @@ function FormsContent() { router.push(`/registration/success?registrationId=${encodeURIComponent(registrationId)}${totalDue>0?`&totalDue=${encodeURIComponent(totalDue.toFixed(2))}`:''}${donationParam}`); return; } - await apiFetch(`/api/registrations/${encodeURIComponent(registrationId)}/forms/responses`, { - method: 'POST', - authToken: token || undefined, - body: { responses: payload } + await apiV2Data("post", "/registrations/{id}/form-responses", { + params: { id: registrationId }, + authToken: token, + body: { responses: payload }, }); // On success, redirect to the success page const totalDue = (registration?.registrationOptions || []).reduce((s, ro) => s + ((ro.eventOption?.price || 0) * (ro.quantity || 0)), 0); @@ -141,10 +142,10 @@ function FormsContent() { if (!registrationId) return; try { setError(null); setInfo(null); - await apiFetch(`/api/registrations/${encodeURIComponent(registrationId)}/forms/draft`, { - method: 'PUT', - authToken: token || undefined, - body: { data: formsData } + await apiV2Data("put", "/registrations/{id}/form-draft", { + params: { id: registrationId }, + authToken: token, + body: { data: formsData }, }); setInfo('Draft saved. You can come back and finish later.'); if (!token || !registrationId) return; diff --git a/apps/events/frontend/src/app/registration/success/page.tsx b/apps/events/frontend/src/app/registration/success/page.tsx index e989617..d00cf9e 100644 --- a/apps/events/frontend/src/app/registration/success/page.tsx +++ b/apps/events/frontend/src/app/registration/success/page.tsx @@ -8,6 +8,7 @@ import { CheckCircle2 } from "lucide-react"; import { useOnlinePayments } from "@/lib/onlinePayments"; import { errorMessage } from "@/lib/utils"; import type { Registration } from "@/types"; +import { apiV2Data } from "@/lib/apiV2"; type FormField = { id: string; type: 'yes_no'|'text'|'date'|'numeric'|'statement'|'paragraph'|'rating'|'multiple_choice'; label: string; isRequired?: boolean; helpText?: string|null; options?: unknown }; @@ -40,7 +41,7 @@ function RegistrationSuccessContent() { if (!registrationId) return; try { // Try to fetch registration and event form - const r = token ? await (await import('@/lib/api')).apiFetch(`/api/registrations/${encodeURIComponent(registrationId)}`, { authToken: token }) : null; + const r = token ? await (apiV2Data("get", "/registrations/{id}/full", { params: { id: registrationId }, authToken: token }) as Promise) : null; if (r) { setReg(r); const ev = await (await import('@/lib/api')).fetchEvent<{ form?: { isRequired: boolean; fields: FormField[] } | null }>(r.eventId); @@ -95,7 +96,7 @@ function RegistrationSuccessContent() { // reload the registration so the displayed totalDue reflects it, instead of redirecting. setError(`${res.message || 'Pricing has changed.'} New total: R ${(res.newTotal ?? 0).toFixed(2)}. Please try again.`); try { - const r = await (await import('@/lib/api')).apiFetch(`/api/registrations/${encodeURIComponent(registrationId)}`, { authToken: token }); + const r = await (apiV2Data("get", "/registrations/{id}/full", { params: { id: registrationId }, authToken: token }) as Promise); if (r) setReg(r); } catch {} return; diff --git a/apps/events/frontend/src/app/self-service/page.tsx b/apps/events/frontend/src/app/self-service/page.tsx index 74fe945..c8054df 100644 --- a/apps/events/frontend/src/app/self-service/page.tsx +++ b/apps/events/frontend/src/app/self-service/page.tsx @@ -13,6 +13,7 @@ import { choosesSessions, isPickOption } from "@/lib/sessions"; import { SessionPicker } from "@/components/events/SessionPicker"; import { ModalOverlay } from "@/components/shared/ModalOverlay"; import { EventPicker } from "@/components/shared/EventPicker"; +import { apiV2Data } from "@/lib/apiV2"; // ─── Types ──────────────────────────────────────────────────────────────────── type EarlyBirdTier = { deadline: string; price: number; order?: number; variantId?: string | null }; @@ -478,11 +479,10 @@ export default function SelfServicePage() { payload.attendees = kioskNames; payload.ticketDelivery = delivery; } - const result = await apiFetch("/api/registrations/manual", { - method: "POST", - body: payload, + const result = await (apiV2Data("post", "/registrations/manual", { + body: payload as never, authToken: supervisorToken, - }); + }) as Promise); setCurrentRegistrationId(result?.id || null); setRegistrationIsFree(result?.status === "paid" || (result?.totalDueComputed ?? total) === 0); @@ -539,8 +539,8 @@ export default function SelfServicePage() { try { const responses = collectedAnswers.map((answers) => ({ answers })); - await apiFetch(`/api/registrations/${currentRegistrationId}/forms/responses`, { - method: "POST", + await apiV2Data("post", "/registrations/{id}/form-responses", { + params: { id: currentRegistrationId }, body: { responses }, authToken: supervisorToken, }); diff --git a/apps/events/frontend/src/components/admin/RegistrationBulkBar.tsx b/apps/events/frontend/src/components/admin/RegistrationBulkBar.tsx index 5108b0a..28799fa 100644 --- a/apps/events/frontend/src/components/admin/RegistrationBulkBar.tsx +++ b/apps/events/frontend/src/components/admin/RegistrationBulkBar.tsx @@ -6,6 +6,7 @@ import { apiFetch, API_BASE } from "@/lib/api"; import { errorMessage } from "@/lib/utils"; import { downloadReportExcel } from "@/lib/export"; import type { Event, Registration } from "@/types"; +import { apiV2Data } from "@/lib/apiV2"; type Action = "" | "message" | "markPaid" | "moveOption" | "allocate" | "cancel" | "export"; type Result = { id: string; ok: boolean; skipped?: boolean; message: string }; @@ -102,7 +103,7 @@ export function RegistrationBulkBar({ selected, events, token, onClear, onDone } : {}; setBusy(true); try { - const res = await apiFetch("/api/registrations/bulk", { method: "POST", authToken: token, body: { action, registrationIds: selected.map(r => r.id), ...params } }); + const res = await (apiV2Data("post", "/registrations/bulk", { authToken: token, body: { action: action as Exclude, registrationIds: selected.map(r => r.id), ...params } }) as Promise); setResult(res); onDone(); } catch (e) { diff --git a/apps/events/frontend/src/components/reports/ReportsV2.tsx b/apps/events/frontend/src/components/reports/ReportsV2.tsx index afecacf..ca89941 100644 --- a/apps/events/frontend/src/components/reports/ReportsV2.tsx +++ b/apps/events/frontend/src/components/reports/ReportsV2.tsx @@ -332,7 +332,7 @@ export default function ReportsV2({ backHref }: { backHref?: string } = {}) { const byEv: Record = {}; for (const id of eventIds) { try { - const list = await apiFetch(`/api/registrations/event/${encodeURIComponent(id)}`, { authToken: token }); + const list = await (apiV2Data("get", "/events/{id}/registrations", { params: { id: id }, authToken: token }) as Promise); byEv[id] = Array.isArray(list) ? list : []; } catch { byEv[id] = []; diff --git a/apps/events/frontend/src/components/shared/AttendeesPanel.tsx b/apps/events/frontend/src/components/shared/AttendeesPanel.tsx index 334b298..4f2f5aa 100644 --- a/apps/events/frontend/src/components/shared/AttendeesPanel.tsx +++ b/apps/events/frontend/src/components/shared/AttendeesPanel.tsx @@ -6,6 +6,7 @@ import { apiFetch } from "@/lib/api"; import { isMinorOn } from "@/components/shared/AttendeeNamesEditor"; import { errorMessage } from "@/lib/utils"; import type { Attendee } from "@/types"; +import { apiV2Data } from "@/lib/apiV2"; const CONSENT_LABEL: Record = { pending: { text: "consent pending", cls: "text-amber-700" }, @@ -95,8 +96,8 @@ export function AttendeesPanel({ registration, token, canEdit, hasForm, onSaved, setBusy(true); setError(null); try { - await apiFetch(`/api/registrations/${encodeURIComponent(registration.id)}/attendees`, { - method: "PUT", + await apiV2Data("put", "/registrations/{id}/attendees", { + params: { id: registration.id }, authToken: token, body: { ticketDelivery: delivery, @@ -127,7 +128,7 @@ export function AttendeesPanel({ registration, token, canEdit, hasForm, onSaved, const sendLink = async (a: Attendee) => { try { - const res = await apiFetch<{ message: string }>(`/api/registrations/${encodeURIComponent(registration.id)}/attendees/${encodeURIComponent(a.id)}/send-form-link`, { method: "POST", authToken: token }); + const res = await (apiV2Data("post", "/registrations/{id}/attendees/{attendeeId}/form-link", { params: { id: registration.id, attendeeId: a.id }, authToken: token }) as Promise<{ message: string }>); onMessage(res.message); } catch (e) { setError(errorMessage(e) || "Couldn't send the form link"); diff --git a/apps/events/frontend/src/lib/api-v2/openapi.json b/apps/events/frontend/src/lib/api-v2/openapi.json index 4f3cea5..3584c87 100644 --- a/apps/events/frontend/src/lib/api-v2/openapi.json +++ b/apps/events/frontend/src/lib/api-v2/openapi.json @@ -11867,6 +11867,191 @@ } } } + }, + "get": { + "tags": [ + "Registrations" + ], + "summary": "Every registration (staff)", + "description": "Newest first, for the events you may see. `unpaid=true` for ones still owing; `userId` for one person's.\n\n**Who:** Staff, supervisors and admins.", + "operationId": "getRegistrations", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "page", + "in": "query", + "required": false, + "schema": { + "default": 1, + "type": "integer", + "minimum": 1, + "maximum": 9007199254740991 + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "description": "At most 200", + "schema": { + "default": 100, + "type": "integer", + "minimum": 1, + "maximum": 200 + } + }, + { + "name": "unpaid", + "in": "query", + "required": false, + "schema": { + "default": "false", + "type": "string", + "enum": [ + "true", + "false" + ] + } + }, + { + "name": "userId", + "in": "query", + "required": false, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "status": { + "type": "string", + "enum": [ + "pending", + "confirmed", + "partial_paid", + "paid", + "cancelled" + ] + }, + "eventId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "userId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "totalDueComputed": { + "type": "number" + } + }, + "required": [ + "id", + "status", + "eventId", + "userId" + ], + "additionalProperties": {} + } + }, + "meta": { + "type": "object", + "properties": { + "page": { + "type": "integer", + "minimum": -9007199254740991, + "maximum": 9007199254740991 + }, + "limit": { + "type": "integer", + "minimum": -9007199254740991, + "maximum": 9007199254740991 + }, + "total": { + "type": "integer", + "minimum": -9007199254740991, + "maximum": 9007199254740991 + }, + "pages": { + "type": "integer", + "minimum": -9007199254740991, + "maximum": 9007199254740991 + } + }, + "required": [ + "page", + "limit", + "total", + "pages" + ], + "additionalProperties": false + } + }, + "required": [ + "data", + "meta" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Not allowed for this role (FORBIDDEN)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } } }, "/registrations/{id}": { @@ -12958,6 +13143,2157 @@ } } }, + "/registrations/{id}/full": { + "get": { + "tags": [ + "Registrations" + ], + "summary": "A registration with everything on it", + "description": "Items and prices, payments, coupons and bundles, named attendees, form answers and the total due.\n\nThe owner, a named attendee or staff — or anyone with the link when not signed in (registration ids can't be guessed). Attendees' contact details are only shown to the payer and staff.\n\n**Who:** Anyone; signed-in staff may see more.", + "operationId": "getRegistrationsIdFull", + "security": [ + {}, + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "description": "The id", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "status": { + "type": "string", + "enum": [ + "pending", + "confirmed", + "partial_paid", + "paid", + "cancelled" + ] + }, + "eventId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "userId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "totalDueComputed": { + "type": "number" + } + }, + "required": [ + "id", + "status", + "eventId", + "userId" + ], + "additionalProperties": {} + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/me/registrations/full": { + "get": { + "tags": [ + "Me" + ], + "summary": "My registrations with everything on them", + "description": "What the dashboard shows: as `/registrations/{id}/full`, newest first, with the event and its form. Only upcoming ones unless `past=true`.\n\n**Who:** Any signed-in person.", + "operationId": "getMeRegistrationsFull", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "past", + "in": "query", + "required": false, + "schema": { + "default": "false", + "type": "string", + "enum": [ + "true", + "false" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "status": { + "type": "string", + "enum": [ + "pending", + "confirmed", + "partial_paid", + "paid", + "cancelled" + ] + }, + "eventId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "userId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "totalDueComputed": { + "type": "number" + } + }, + "required": [ + "id", + "status", + "eventId", + "userId" + ], + "additionalProperties": {} + } + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/registrations/{id}/items": { + "put": { + "tags": [ + "Registrations" + ], + "summary": "Change the tickets on a registration", + "description": "The whole list of items it should have. Added places need stock and are priced now; places already paid for keep their price, and nothing goes below tickets already issued or the amount paid.\n\nNot for registrations made with a season pass, nor once the event has ended or is closed. Staff can add kids and volunteer places; owners can only keep or lower them.\n\n**Who:** Any signed-in person.", + "operationId": "putRegistrationsIdItems", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "description": "The id", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "options": { + "minItems": 1, + "maxItems": 100, + "type": "array", + "items": { + "type": "object", + "properties": { + "eventOptionId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "variantId": { + "anyOf": [ + { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + { + "type": "null" + } + ] + }, + "quantity": { + "type": "integer", + "minimum": 1, + "maximum": 1000 + } + }, + "required": [ + "eventOptionId", + "quantity" + ] + } + } + }, + "required": [ + "options" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "status": { + "type": "string", + "enum": [ + "pending", + "confirmed", + "partial_paid", + "paid", + "cancelled" + ] + }, + "eventId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "userId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "totalDueComputed": { + "type": "number" + } + }, + "required": [ + "id", + "status", + "eventId", + "userId" + ], + "additionalProperties": {} + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/registrations/{id}/invoice": { + "post": { + "tags": [ + "Registrations" + ], + "summary": "Send me the invoice again", + "description": "**Who:** Any signed-in person.", + "operationId": "postRegistrationsIdInvoice", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "description": "The id", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "channel": { + "default": "email", + "type": "string", + "enum": [ + "email", + "whatsapp" + ] + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "additionalProperties": {} + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/registrations/{id}/coupon": { + "post": { + "tags": [ + "Registrations" + ], + "summary": "Apply a coupon code", + "description": "By the owner, or by staff on their behalf (logged). Not on season pass registrations.\n\n**Who:** Any signed-in person.", + "operationId": "postRegistrationsIdCoupon", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "description": "The id", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "string", + "minLength": 1, + "maxLength": 40 + } + }, + "required": [ + "code" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "status": { + "type": "string", + "enum": [ + "pending", + "confirmed", + "partial_paid", + "paid", + "cancelled" + ] + }, + "eventId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "userId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "totalDueComputed": { + "type": "number" + }, + "message": { + "type": "string" + } + }, + "required": [ + "id", + "status", + "eventId", + "userId", + "message" + ], + "additionalProperties": {} + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Registrations" + ], + "summary": "Take a coupon code off", + "description": "Staff. Its use is freed. Not once a ticket on it has been scanned; unused tickets are withdrawn if it's no longer paid.\n\n**Who:** Staff, supervisors and admins.", + "operationId": "deleteRegistrationsIdCoupon", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "description": "The id", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "additionalProperties": {} + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Not allowed for this role (FORBIDDEN)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/registrations/{id}/attendees": { + "put": { + "tags": [ + "Registrations" + ], + "summary": "Name the people on a registration", + "description": "The whole list: attendees left out are removed (not once their ticket has been scanned). `ticketDelivery` says who gets the tickets.\n\n**Who:** Any signed-in person.", + "operationId": "putRegistrationsIdAttendees", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "description": "The id", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "attendees": { + "maxItems": 1000, + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "description": "An attendee already on it (left out = removed)", + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "eventOptionId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "variantId": { + "anyOf": [ + { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + { + "type": "null" + } + ] + }, + "name": { + "type": "string", + "maxLength": 200 + } + }, + "required": [ + "eventOptionId", + "name" + ], + "additionalProperties": {} + } + }, + "ticketDelivery": { + "type": "string", + "enum": [ + "payer", + "each" + ] + } + }, + "required": [ + "attendees" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "ticketDelivery": { + "type": [ + "string", + "null" + ] + }, + "attendees": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "name": { + "type": "string" + } + }, + "required": [ + "id", + "name" + ], + "additionalProperties": {} + } + } + }, + "required": [ + "id", + "ticketDelivery", + "attendees" + ], + "additionalProperties": {} + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/registrations/{id}/attendees/{attendeeId}/form-link": { + "post": { + "tags": [ + "Registrations" + ], + "summary": "Send an attendee their form", + "description": "A link to fill in their own attendee form, by email and/or WhatsApp.\n\n**Who:** Any signed-in person.", + "operationId": "postRegistrationsIdAttendeesAttendeeIdForm-link", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + }, + { + "name": "attendeeId", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "additionalProperties": {} + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/registrations/{id}/form-draft": { + "get": { + "tags": [ + "Registrations" + ], + "summary": "Attendee forms saved part-way", + "description": "**Who:** Anyone; signed-in staff may see more.", + "operationId": "getRegistrationsIdForm-draft", + "security": [ + {}, + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "description": "The id", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "data": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {} + }, + "updatedAt": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "data", + "updatedAt" + ], + "additionalProperties": false + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + }, + "put": { + "tags": [ + "Registrations" + ], + "summary": "Save attendee forms part-way", + "description": "Kept for the registration's owner (also when staff save it), until the forms are submitted.\n\n**Who:** Anyone; signed-in staff may see more.", + "operationId": "putRegistrationsIdForm-draft", + "security": [ + {}, + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "description": "The id", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {} + } + }, + "required": [ + "data" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + }, + "required": [ + "message", + "updatedAt" + ], + "additionalProperties": false + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/registrations/{id}/form-responses": { + "post": { + "tags": [ + "Registrations" + ], + "summary": "Submit attendee forms", + "description": "One response per main ticket at most; each named attendee answers once. Tickets are issued once it's paid and the forms are in.\n\n**Who:** Anyone; signed-in staff may see more.", + "operationId": "postRegistrationsIdForm-responses", + "security": [ + {}, + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "description": "The id", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "responses": { + "maxItems": 500, + "type": "array", + "items": { + "type": "object", + "properties": { + "attendeeId": { + "description": "The named attendee this form is for", + "anyOf": [ + { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + { + "type": "null" + } + ] + }, + "answers": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {}, + "description": "Field id → answer (stored as text)" + } + }, + "required": [ + "answers" + ] + } + } + }, + "required": [ + "responses" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "count": { + "type": "integer", + "minimum": -9007199254740991, + "maximum": 9007199254740991 + } + }, + "required": [ + "message" + ], + "additionalProperties": {} + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + }, + "put": { + "tags": [ + "Registrations" + ], + "summary": "Replace the attendee forms", + "description": "Supervisors: every response on the registration is replaced by these.\n\n**Who:** Supervisors and admins.", + "operationId": "putRegistrationsIdForm-responses", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "description": "The id", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "responses": { + "maxItems": 500, + "type": "array", + "items": { + "type": "object", + "properties": { + "attendeeId": { + "description": "The named attendee this form is for", + "anyOf": [ + { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + { + "type": "null" + } + ] + }, + "answers": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": {}, + "description": "Field id → answer (stored as text)" + } + }, + "required": [ + "answers" + ] + } + } + }, + "required": [ + "responses" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "additionalProperties": {} + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Not allowed for this role (FORBIDDEN)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/events/{id}/registrations": { + "get": { + "tags": [ + "Registrations" + ], + "summary": "An event's registrations", + "description": "Oldest first, with tickets, payments and attendees. `search` matches the name, email or phone.\n\n**Who:** Staff, supervisors and admins.", + "operationId": "getEventsIdRegistrations", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "description": "The id", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + }, + { + "name": "search", + "in": "query", + "required": false, + "schema": { + "type": "string", + "maxLength": 200 + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "status": { + "type": "string", + "enum": [ + "pending", + "confirmed", + "partial_paid", + "paid", + "cancelled" + ] + }, + "eventId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "userId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "totalDueComputed": { + "type": "number" + } + }, + "required": [ + "id", + "status", + "eventId", + "userId" + ], + "additionalProperties": {} + } + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Not allowed for this role (FORBIDDEN)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/registrations/{id}/status": { + "patch": { + "tags": [ + "Registrations" + ], + "summary": "Set a registration's status", + "description": "Staff. `paid` issues and sends the tickets; leaving `paid` withdraws unused tickets (refused once one has been scanned); `cancelled` frees its places for the waitlist.\n\n**Who:** Staff, supervisors and admins.", + "operationId": "patchRegistrationsIdStatus", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "description": "The id", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "pending", + "confirmed", + "partial_paid", + "paid", + "cancelled" + ] + } + }, + "required": [ + "status" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "status": { + "type": "string", + "enum": [ + "pending", + "confirmed", + "partial_paid", + "paid", + "cancelled" + ] + }, + "eventId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "userId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "totalDueComputed": { + "type": "number" + } + }, + "required": [ + "id", + "status", + "eventId", + "userId" + ], + "additionalProperties": {} + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Not allowed for this role (FORBIDDEN)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not found (NOT_FOUND)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/registrations/manual": { + "post": { + "tags": [ + "Registrations" + ], + "summary": "Register someone (at the door, by phone)", + "description": "Supervisors. Finds the person by email or phone (refused when those are two different accounts) or makes an account and sends them an activation link (`skipActivationNotice` to not).\n\nAdded to their existing registration for the event if they have one. Free ones are marked paid and get their tickets; otherwise they're sent a link to pay.\n\n**Who:** Supervisors and admins.", + "operationId": "postRegistrationsManual", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "eventId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "options": { + "minItems": 1, + "maxItems": 100, + "type": "array", + "items": { + "type": "object", + "properties": { + "eventOptionId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "variantId": { + "anyOf": [ + { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + { + "type": "null" + } + ] + }, + "quantity": { + "type": "integer", + "minimum": 1, + "maximum": 1000 + }, + "sessionIds": { + "maxItems": 200, + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + }, + "required": [ + "eventOptionId", + "quantity" + ] + } + }, + "user": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1, + "maxLength": 200 + }, + "email": { + "anyOf": [ + { + "type": "string", + "maxLength": 200 + }, + { + "type": "null" + } + ] + }, + "phoneNumber": { + "anyOf": [ + { + "type": "string", + "maxLength": 40 + }, + { + "type": "null" + } + ] + }, + "password": { + "description": "Self-service kiosk: the visitor sets it, and the account is active at once", + "type": "string", + "maxLength": 200 + } + }, + "required": [ + "name" + ], + "additionalProperties": {} + }, + "notificationPreference": { + "type": "string", + "enum": [ + "email", + "whatsapp", + "both" + ] + }, + "skipActivationNotice": { + "type": "boolean" + }, + "couponCode": { + "type": "string", + "maxLength": 40 + }, + "attendees": { + "maxItems": 1000, + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "description": "An attendee already on it (left out = removed)", + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "eventOptionId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "variantId": { + "anyOf": [ + { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + { + "type": "null" + } + ] + }, + "name": { + "type": "string", + "maxLength": 200 + } + }, + "required": [ + "eventOptionId", + "name" + ], + "additionalProperties": {} + } + }, + "ticketDelivery": { + "type": "string", + "enum": [ + "payer", + "each" + ] + } + }, + "required": [ + "eventId", + "options", + "user" + ], + "additionalProperties": {} + } + } + } + }, + "responses": { + "201": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "status": { + "type": "string", + "enum": [ + "pending", + "confirmed", + "partial_paid", + "paid", + "cancelled" + ] + }, + "eventId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "userId": { + "type": "string", + "minLength": 1, + "maxLength": 64 + }, + "totalDueComputed": { + "type": "number" + }, + "couponError": { + "type": "string" + } + }, + "required": [ + "id", + "status", + "eventId", + "userId" + ], + "additionalProperties": {} + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Not allowed for this role (FORBIDDEN)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/registrations/bulk": { + "post": { + "tags": [ + "Registrations" + ], + "summary": "Do one thing to many registrations", + "description": "`markPaid`, `cancel`, `moveOption`, `allocate` or `message`, for up to 500 you may manage. Each is done on its own: the answer lists what worked and what didn't.\n\n**Who:** Supervisors and admins.", + "operationId": "postRegistrationsBulk", + "security": [ + { + "bearerAuth": [] + } + ], + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "action": { + "type": "string", + "enum": [ + "markPaid", + "cancel", + "moveOption", + "allocate", + "message" + ] + }, + "registrationIds": { + "minItems": 1, + "maxItems": 500, + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 64 + } + } + }, + "required": [ + "action", + "registrationIds" + ], + "additionalProperties": {} + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": {}, + "additionalProperties": {} + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Validation failed (VALIDATION_FAILED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Not signed in (UNAUTHENTICATED)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Not allowed for this role (FORBIDDEN)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, "/checkin/{qrCode}": { "get": { "tags": [ diff --git a/apps/events/frontend/src/lib/api-v2/schema.d.ts b/apps/events/frontend/src/lib/api-v2/schema.d.ts index 9ca1f02..b336d9a 100644 --- a/apps/events/frontend/src/lib/api-v2/schema.d.ts +++ b/apps/events/frontend/src/lib/api-v2/schema.d.ts @@ -1133,7 +1133,13 @@ export interface paths { path?: never; cookie?: never; }; - get?: never; + /** + * Every registration (staff) + * @description Newest first, for the events you may see. `unpaid=true` for ones still owing; `userId` for one person's. + * + * **Who:** Staff, supervisors and admins. + */ + get: operations["getRegistrations"]; put?: never; /** * Register for an event @@ -1266,6 +1272,312 @@ export interface paths { patch?: never; trace?: never; }; + "/registrations/{id}/full": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** + * A registration with everything on it + * @description Items and prices, payments, coupons and bundles, named attendees, form answers and the total due. + * + * The owner, a named attendee or staff — or anyone with the link when not signed in (registration ids can't be guessed). Attendees' contact details are only shown to the payer and staff. + * + * **Who:** Anyone; signed-in staff may see more. + */ + get: operations["getRegistrationsIdFull"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/me/registrations/full": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** + * My registrations with everything on them + * @description What the dashboard shows: as `/registrations/{id}/full`, newest first, with the event and its form. Only upcoming ones unless `past=true`. + * + * **Who:** Any signed-in person. + */ + get: operations["getMeRegistrationsFull"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/registrations/{id}/items": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + /** + * Change the tickets on a registration + * @description The whole list of items it should have. Added places need stock and are priced now; places already paid for keep their price, and nothing goes below tickets already issued or the amount paid. + * + * Not for registrations made with a season pass, nor once the event has ended or is closed. Staff can add kids and volunteer places; owners can only keep or lower them. + * + * **Who:** Any signed-in person. + */ + put: operations["putRegistrationsIdItems"]; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/registrations/{id}/invoice": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** + * Send me the invoice again + * @description **Who:** Any signed-in person. + */ + post: operations["postRegistrationsIdInvoice"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/registrations/{id}/coupon": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** + * Apply a coupon code + * @description By the owner, or by staff on their behalf (logged). Not on season pass registrations. + * + * **Who:** Any signed-in person. + */ + post: operations["postRegistrationsIdCoupon"]; + /** + * Take a coupon code off + * @description Staff. Its use is freed. Not once a ticket on it has been scanned; unused tickets are withdrawn if it's no longer paid. + * + * **Who:** Staff, supervisors and admins. + */ + delete: operations["deleteRegistrationsIdCoupon"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/registrations/{id}/attendees": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + /** + * Name the people on a registration + * @description The whole list: attendees left out are removed (not once their ticket has been scanned). `ticketDelivery` says who gets the tickets. + * + * **Who:** Any signed-in person. + */ + put: operations["putRegistrationsIdAttendees"]; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/registrations/{id}/attendees/{attendeeId}/form-link": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** + * Send an attendee their form + * @description A link to fill in their own attendee form, by email and/or WhatsApp. + * + * **Who:** Any signed-in person. + */ + post: operations["postRegistrationsIdAttendeesAttendeeIdForm-link"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/registrations/{id}/form-draft": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** + * Attendee forms saved part-way + * @description **Who:** Anyone; signed-in staff may see more. + */ + get: operations["getRegistrationsIdForm-draft"]; + /** + * Save attendee forms part-way + * @description Kept for the registration's owner (also when staff save it), until the forms are submitted. + * + * **Who:** Anyone; signed-in staff may see more. + */ + put: operations["putRegistrationsIdForm-draft"]; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/registrations/{id}/form-responses": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + /** + * Replace the attendee forms + * @description Supervisors: every response on the registration is replaced by these. + * + * **Who:** Supervisors and admins. + */ + put: operations["putRegistrationsIdForm-responses"]; + /** + * Submit attendee forms + * @description One response per main ticket at most; each named attendee answers once. Tickets are issued once it's paid and the forms are in. + * + * **Who:** Anyone; signed-in staff may see more. + */ + post: operations["postRegistrationsIdForm-responses"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/events/{id}/registrations": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** + * An event's registrations + * @description Oldest first, with tickets, payments and attendees. `search` matches the name, email or phone. + * + * **Who:** Staff, supervisors and admins. + */ + get: operations["getEventsIdRegistrations"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/registrations/{id}/status": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + /** + * Set a registration's status + * @description Staff. `paid` issues and sends the tickets; leaving `paid` withdraws unused tickets (refused once one has been scanned); `cancelled` frees its places for the waitlist. + * + * **Who:** Staff, supervisors and admins. + */ + patch: operations["patchRegistrationsIdStatus"]; + trace?: never; + }; + "/registrations/manual": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** + * Register someone (at the door, by phone) + * @description Supervisors. Finds the person by email or phone (refused when those are two different accounts) or makes an account and sends them an activation link (`skipActivationNotice` to not). + * + * Added to their existing registration for the event if they have one. Free ones are marked paid and get their tickets; otherwise they're sent a link to pay. + * + * **Who:** Supervisors and admins. + */ + post: operations["postRegistrationsManual"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/registrations/bulk": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** + * Do one thing to many registrations + * @description `markPaid`, `cancel`, `moveOption`, `allocate` or `message`, for up to 500 you may manage. Each is done on its own: the answer lists what worked and what didn't. + * + * **Who:** Supervisors and admins. + */ + post: operations["postRegistrationsBulk"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; "/checkin/{qrCode}": { parameters: { query?: never; @@ -6338,6 +6650,76 @@ export interface operations { }; }; }; + getRegistrations: { + parameters: { + query?: { + page?: number; + /** @description At most 200 */ + limit?: number; + unpaid?: "true" | "false"; + userId?: string; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: ({ + id: string; + /** @enum {string} */ + status: "pending" | "confirmed" | "partial_paid" | "paid" | "cancelled"; + eventId: string; + userId: string; + totalDueComputed?: number; + } & { + [key: string]: unknown; + })[]; + meta: { + page: number; + limit: number; + total: number; + pages: number; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not allowed for this role (FORBIDDEN) */ + 403: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; postRegistrations: { parameters: { query?: never; @@ -6870,6 +7252,1062 @@ export interface operations { }; }; }; + getRegistrationsIdFull: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The id */ + id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + id: string; + /** @enum {string} */ + status: "pending" | "confirmed" | "partial_paid" | "paid" | "cancelled"; + eventId: string; + userId: string; + totalDueComputed?: number; + } & { + [key: string]: unknown; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + getMeRegistrationsFull: { + parameters: { + query?: { + past?: "true" | "false"; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: ({ + id: string; + /** @enum {string} */ + status: "pending" | "confirmed" | "partial_paid" | "paid" | "cancelled"; + eventId: string; + userId: string; + totalDueComputed?: number; + } & { + [key: string]: unknown; + })[]; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + putRegistrationsIdItems: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The id */ + id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": { + options: { + eventOptionId: string; + variantId?: string | null; + quantity: number; + }[]; + }; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + id: string; + /** @enum {string} */ + status: "pending" | "confirmed" | "partial_paid" | "paid" | "cancelled"; + eventId: string; + userId: string; + totalDueComputed?: number; + } & { + [key: string]: unknown; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + postRegistrationsIdInvoice: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The id */ + id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": { + /** + * @default email + * @enum {string} + */ + channel?: "email" | "whatsapp"; + }; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + message: string; + } & { + [key: string]: unknown; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + postRegistrationsIdCoupon: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The id */ + id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": { + code: string; + }; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + id: string; + /** @enum {string} */ + status: "pending" | "confirmed" | "partial_paid" | "paid" | "cancelled"; + eventId: string; + userId: string; + totalDueComputed?: number; + message: string; + } & { + [key: string]: unknown; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + deleteRegistrationsIdCoupon: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The id */ + id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + message: string; + } & { + [key: string]: unknown; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not allowed for this role (FORBIDDEN) */ + 403: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + putRegistrationsIdAttendees: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The id */ + id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": { + attendees: ({ + /** @description An attendee already on it (left out = removed) */ + id?: string; + eventOptionId: string; + variantId?: string | null; + name: string; + } & { + [key: string]: unknown; + })[]; + /** @enum {string} */ + ticketDelivery?: "payer" | "each"; + }; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + id: string; + ticketDelivery: string | null; + attendees: ({ + id: string; + name: string; + } & { + [key: string]: unknown; + })[]; + } & { + [key: string]: unknown; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + "postRegistrationsIdAttendeesAttendeeIdForm-link": { + parameters: { + query?: never; + header?: never; + path: { + id: string; + attendeeId: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + message: string; + } & { + [key: string]: unknown; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + "getRegistrationsIdForm-draft": { + parameters: { + query?: never; + header?: never; + path: { + /** @description The id */ + id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + data: { + [key: string]: unknown; + }; + updatedAt: string | null; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + "putRegistrationsIdForm-draft": { + parameters: { + query?: never; + header?: never; + path: { + /** @description The id */ + id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": { + data: { + [key: string]: unknown; + }; + }; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + message: string; + updatedAt: string; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + "putRegistrationsIdForm-responses": { + parameters: { + query?: never; + header?: never; + path: { + /** @description The id */ + id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": { + responses: { + /** @description The named attendee this form is for */ + attendeeId?: string | null; + /** @description Field id → answer (stored as text) */ + answers: { + [key: string]: unknown; + }; + }[]; + }; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + message: string; + } & { + [key: string]: unknown; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not allowed for this role (FORBIDDEN) */ + 403: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + "postRegistrationsIdForm-responses": { + parameters: { + query?: never; + header?: never; + path: { + /** @description The id */ + id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": { + responses: { + /** @description The named attendee this form is for */ + attendeeId?: string | null; + /** @description Field id → answer (stored as text) */ + answers: { + [key: string]: unknown; + }; + }[]; + }; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + message: string; + count?: number; + } & { + [key: string]: unknown; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + getEventsIdRegistrations: { + parameters: { + query?: { + search?: string; + }; + header?: never; + path: { + /** @description The id */ + id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: ({ + id: string; + /** @enum {string} */ + status: "pending" | "confirmed" | "partial_paid" | "paid" | "cancelled"; + eventId: string; + userId: string; + totalDueComputed?: number; + } & { + [key: string]: unknown; + })[]; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not allowed for this role (FORBIDDEN) */ + 403: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + patchRegistrationsIdStatus: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The id */ + id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": { + /** @enum {string} */ + status: "pending" | "confirmed" | "partial_paid" | "paid" | "cancelled"; + }; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + id: string; + /** @enum {string} */ + status: "pending" | "confirmed" | "partial_paid" | "paid" | "cancelled"; + eventId: string; + userId: string; + totalDueComputed?: number; + } & { + [key: string]: unknown; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not allowed for this role (FORBIDDEN) */ + 403: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not found (NOT_FOUND) */ + 404: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + postRegistrationsManual: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": { + eventId: string; + options: { + eventOptionId: string; + variantId?: string | null; + quantity: number; + sessionIds?: string[]; + }[]; + user: { + name: string; + email?: string | null; + phoneNumber?: string | null; + /** @description Self-service kiosk: the visitor sets it, and the account is active at once */ + password?: string; + } & { + [key: string]: unknown; + }; + /** @enum {string} */ + notificationPreference?: "email" | "whatsapp" | "both"; + skipActivationNotice?: boolean; + couponCode?: string; + attendees?: ({ + /** @description An attendee already on it (left out = removed) */ + id?: string; + eventOptionId: string; + variantId?: string | null; + name: string; + } & { + [key: string]: unknown; + })[]; + /** @enum {string} */ + ticketDelivery?: "payer" | "each"; + } & { + [key: string]: unknown; + }; + }; + }; + responses: { + /** @description OK */ + 201: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + id: string; + /** @enum {string} */ + status: "pending" | "confirmed" | "partial_paid" | "paid" | "cancelled"; + eventId: string; + userId: string; + totalDueComputed?: number; + couponError?: string; + } & { + [key: string]: unknown; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not allowed for this role (FORBIDDEN) */ + 403: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; + postRegistrationsBulk: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": { + /** @enum {string} */ + action: "markPaid" | "cancel" | "moveOption" | "allocate" | "message"; + registrationIds: string[]; + } & { + [key: string]: unknown; + }; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + data: { + [key: string]: unknown; + }; + }; + }; + }; + /** @description Validation failed (VALIDATION_FAILED) */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not signed in (UNAUTHENTICATED) */ + 401: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + /** @description Not allowed for this role (FORBIDDEN) */ + 403: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Error"]; + }; + }; + }; + }; getCheckinQrCode: { parameters: { query?: { diff --git a/apps/events/frontend/src/lib/api.ts b/apps/events/frontend/src/lib/api.ts index 17d8818..704f46d 100644 --- a/apps/events/frontend/src/lib/api.ts +++ b/apps/events/frontend/src/lib/api.ts @@ -1,4 +1,4 @@ -import type { Event, Paginated, Payment, User } from "@/types"; +import type { Event, Paginated, Payment, Registration, User } from "@/types"; export type ApiOptions = { method?: string; @@ -216,6 +216,23 @@ export async function fetchManagedEvents(token: string | null | undef return data as unknown as T[]; } +/** + * Every registration staff may see (API v2 GET /registrations, all pages), newest first, in full. + * `unpaid`: only ones still owing; `userId`: one person's. + */ +export async function fetchAllRegistrations(token: string | null | undefined, filter: { unpaid?: boolean; userId?: string } = {}): Promise { + const { apiV2 } = await import("@/lib/apiV2"); + const out: T[] = []; + for (let page = 1; ; page++) { + const res = await apiV2("get", "/registrations", { + authToken: token, + query: { page, limit: 200, unpaid: filter.unpaid ? "true" : "false", ...(filter.userId ? { userId: filter.userId } : {}) }, + }); + out.push(...(res.data as unknown as T[])); + if (page >= res.meta.pages) return out; + } +} + /** * One event in full (API v2 GET /events/{id}/full): ticket options with what's left, sessions, * form, attachments, bundles. Staff signed in (`authToken`) also see inactive and not-yet-live