diff --git a/apps/events/CHANGELOG.md b/apps/events/CHANGELOG.md index 1cbc749..b79f995 100644 --- a/apps/events/CHANGELOG.md +++ b/apps/events/CHANGELOG.md @@ -7,6 +7,22 @@ and this project follows [Semantic Versioning](https://semver.org/). ## [Unreleased] +## [1.47.0] - 2026-10-28 + +### Added + +- **Copy an event** — "Copy" on each card on the Events page opens the event editor filled in from + that event: details, campus, sessions, ticket options, variants and early-bird tiers, sections, + the registration form, notification recipients, the feedback questions, certificates and session + reminders. Everything can be changed before saving. A **New start** box at the top moves every + date by the same amount — the end, the sessions, the registration deadline, early-bird deadlines + and the feedback date. On save the event's allocation groups (rooms, buses, teams) are copied + too, and for admins its planned costs (a cost on a ticket option goes to the option with the + same name). Not copied: registrations, coupons, attachments, bundles, the short link, the go-live + time, cancelled sessions, kids check-in (kids ticket and rooms) and volunteer roles. +- `POST /api/events/:id/copy-from` (blocked in licence read-only mode, campus-checked for both + events); `POST /api/events` takes `clonedFromId`, recorded in the `event_created` audit entry. + ## [1.46.2] - 2026-10-28 ### Added diff --git a/apps/events/FEATURES.md b/apps/events/FEATURES.md index c3d39be..a7e7ad9 100644 --- a/apps/events/FEATURES.md +++ b/apps/events/FEATURES.md @@ -90,6 +90,14 @@ Feedback → Attendance**. - **Basic details** — title, description, start/end dates, registration deadline, picture (upload or URL), location (defaults to the org's address), contact person. +- **Copy an event** — "Copy" on an event card opens the editor filled in from that + event (details, campus, sessions, options, variants, early birds, sections, form, + notification recipients, feedback questions, certificates, reminders). Setting + the **New start** moves every date with it (end, sessions, registration deadline, + early-bird deadlines, feedback date). Allocation groups are copied on save, and + for admins the planned costs (matched to options by name). Not copied: + registrations, coupons, attachments, the short link, the go-live time, kids + check-in and volunteer roles. - **Contact-only events** — for things like baptisms: shown publicly with a "Contact us" popup instead of registration, with no tickets. - **Multi-day events (sessions)** — one event on several dates, e.g. every diff --git a/apps/events/WHATS-NEW.md b/apps/events/WHATS-NEW.md index 14be8b4..7036749 100644 --- a/apps/events/WHATS-NEW.md +++ b/apps/events/WHATS-NEW.md @@ -12,6 +12,15 @@ Write for church admins, not developers: no environment variables, endpoints or developer log is CHANGELOG.md. A tagged version without a section here shows "No details given". --> +## 1.47.0 + +- **Copy an event.** Running the same camp, course or breakfast again? Press **Copy** on the event + and the editor opens with everything filled in: tickets and prices, early birds, sessions, the + form, feedback questions, certificates and groups. +- **Pick the new start date** and every other date moves with it — sessions, deadlines and + early-bird dates included. Check each step, change what's different this time, and save. +- Registrations, coupons, attachments, kids check-in and volunteer roles aren't copied. + ## 1.46.2 - **See what's new before you update.** When a new version is out, the Licence page lists what it diff --git a/apps/events/backend/API_DOCUMENTATION.md b/apps/events/backend/API_DOCUMENTATION.md index 8e6c817..a878a4a 100644 --- a/apps/events/backend/API_DOCUMENTATION.md +++ b/apps/events/backend/API_DOCUMENTATION.md @@ -136,6 +136,7 @@ At login, if a WhatsApp code can't be sent, the code falls back to the account's | GET | `/api/events/by-alias/:redirectUrl` | public | Get event by URL alias | | POST | `/api/events` | supervisor+ | Create event | | PUT | `/api/events/:id` | supervisor+ | Update event | +| POST | `/api/events/:id/copy-from` | supervisor+ | Copying an event: copy `fromEventId`'s allocation sets/groups (not kids rooms) and, for admins, planned costs into this new event (409 once it has registrations or groups) | | DELETE | `/api/events/:id` | admin | Delete event | | POST | `/api/events/:id/email-attendees` | supervisor+ | Bulk email attendees (`dryRun: true` to preview) | | POST | `/api/events/:id/email-attendees/schedule` | supervisor+ | Schedule bulk email | @@ -170,6 +171,10 @@ At login, if a WhatsApp code can't be sent, the code falls back to the account's } ``` +A copy made with "Copy" on the Events page is an ordinary `POST /api/events` from the event form, +with `clonedFromId` (the source event, noted in the `event_created` audit entry), followed by the +options, feedback form, sections and recipients as for a new event, then `POST /api/events/:id/copy-from`. + --- ## Event Options & Variants diff --git a/apps/events/backend/package-lock.json b/apps/events/backend/package-lock.json index 8b46356..fb67ac0 100644 --- a/apps/events/backend/package-lock.json +++ b/apps/events/backend/package-lock.json @@ -1,12 +1,12 @@ { "name": "event-management-backend", - "version": "1.46.2", + "version": "1.47.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "event-management-backend", - "version": "1.46.2", + "version": "1.47.0", "hasInstallScript": true, "dependencies": { "@prisma/adapter-pg": "^7.10.1", diff --git a/apps/events/backend/package.json b/apps/events/backend/package.json index a9dbbc8..e07c883 100644 --- a/apps/events/backend/package.json +++ b/apps/events/backend/package.json @@ -1,6 +1,6 @@ { "name": "event-management-backend", - "version": "1.46.2", + "version": "1.47.0", "description": "Event Management System Backend", "main": "src/index.js", "scripts": { diff --git a/apps/events/backend/src/controllers/eventController.js b/apps/events/backend/src/controllers/eventController.js index b126b8c..f75763a 100644 --- a/apps/events/backend/src/controllers/eventController.js +++ b/apps/events/backend/src/controllers/eventController.js @@ -102,6 +102,20 @@ async function saveSchedule(tx, eventId, body) { return changes; } +// @desc Copy allocation groups (and, for admins, planned costs) from another event into a new copy +// @route POST /api/events/:id/copy-from +// @access Private/Supervisor +const copyEventSetupFrom = async (req, res) => { + try { + const fromEventId = req.body?.fromEventId; + if (!fromEventId) return res.status(400).json({ message: 'fromEventId is required' }); + const copied = await require('../utils/eventClone').copyEventSetup(String(fromEventId), req.params.id, { withCosts: req.user?.role === 'admin' }); + res.json(copied); + } catch (error) { + res.status(error.statusCode || 400).json({ message: error.message }); + } +}; + // Helper to convert stored picture path/URL to an absolute, externally reachable URL based on the incoming request function toAbsoluteUrl(req, url) { if (!url) return url; @@ -196,7 +210,7 @@ const createEvent = async (req, res) => { action: 'event_created', targetType: 'Event', targetId: createdEvent.id, - metadata: { title: createdEvent.title }, + metadata: { title: createdEvent.title, ...(req.body.clonedFromId ? { clonedFromId: String(req.body.clonedFromId) } : {}) }, ip: getClientIp(req), }); @@ -2156,6 +2170,7 @@ const getEventByAlias = async (req, res) => { module.exports = { createEvent, + copyEventSetupFrom, getEvents, getAllEvents, getEventsAll, diff --git a/apps/events/backend/src/hub/readOnly.js b/apps/events/backend/src/hub/readOnly.js index 5244497..132196d 100644 --- a/apps/events/backend/src/hub/readOnly.js +++ b/apps/events/backend/src/hub/readOnly.js @@ -13,6 +13,7 @@ const { licenceStatus } = require('./licence'); const BLOCKED = [ ['POST', /^\/api\/events\/?$/], ['PUT', /^\/api\/events\/[^/]+\/?$/], + ['POST', /^\/api\/events\/[^/]+\/copy-from\/?$/], ['POST', /^\/api\/events\/[^/]+\/options\/?$/], ['PUT', /^\/api\/events\/options\/[^/]+\/?$/], ['POST', /^\/api\/events\/options\/[^/]+\/variants\/?$/], diff --git a/apps/events/backend/src/index.js b/apps/events/backend/src/index.js index 3fec456..5416bd4 100644 --- a/apps/events/backend/src/index.js +++ b/apps/events/backend/src/index.js @@ -584,6 +584,10 @@ app.get('/docs', async (req, res) => { pathParams:{ ':id':'Event UUID' }, request:{ body:{ title:'Camp 2025 Updated', price:500 }}, responses:[{ status:200, desc:'Updated', body:{ id:'ev-uuid-...', title:'Camp 2025 Updated', price:500 }}]}, + { method:'POST', path:'/api/events/:id/copy-from', auth:'supervisor+', desc:'Copying an event (1.47.0): after the copy is created from the event form, copy the source event\'s allocation sets and groups (not the kids rooms) and, for admins, its planned costs (matched to options by name). Only into an event with no registrations or allocation sets yet. POST /api/events takes clonedFromId to note the source in the audit log.', + pathParams:{ ':id':'The new event' }, + request:{ body:{ fromEventId:'ev-uuid-source' }}, + responses:[{ status:200, desc:'Copied', body:{ sets:2, groups:9, costs:3 }}, { status:409, desc:'The event already has registrations or groups' }]}, { method:'GET', path:'/api/events/:id/notify-recipients', auth:'supervisor+', desc:'Get which users receive registration/payment/daily-summary notifications for this event. Lightweight — skips the option/stock computation that GET /api/events/:id does.', pathParams:{ ':id':'Event UUID' }, responses:[{ status:200, desc:'Success', body:[{ id:'user-uuid-1', name:'Jane Supervisor', email:'jane@example.com', role:'supervisor' }]}]}, diff --git a/apps/events/backend/src/routes/eventRoutes.js b/apps/events/backend/src/routes/eventRoutes.js index 8e7d037..1e38f8f 100644 --- a/apps/events/backend/src/routes/eventRoutes.js +++ b/apps/events/backend/src/routes/eventRoutes.js @@ -2,6 +2,7 @@ const express = require('express'); const router = express.Router(); const { createEvent, + copyEventSetupFrom, getEvents, getAllEvents, getEventsAll, @@ -29,7 +30,7 @@ const { getEventByAlias } = require('../controllers/eventController'); const { protect, admin, supervisor, optionalAuth } = require('../middleware/authMiddleware'); -const { scopeEvent, scopeList } = require('../utils/campusScope'); +const { scopeEvent, scopeBody, scopeList } = require('../utils/campusScope'); // Public routes router.get('/', getEvents); @@ -55,6 +56,9 @@ router.route('/:id') .put(protect, supervisor, scopeEvent({ need: 'manage' }), updateEvent) .delete(protect, admin, deleteEvent); +// Clone: copy allocation groups (and costs, for admins) from the source event into a new copy. +router.post('/:id/copy-from', protect, supervisor, scopeEvent({ need: 'manage' }), scopeBody([['fromEventId', 'event']]), copyEventSetupFrom); + // Notification recipients: who gets registration/payment/daily-summary emails for this event router.route('/:id/notify-recipients') .get(protect, supervisor, scopeEvent(), getEventNotifyRecipients) diff --git a/apps/events/backend/src/utils/eventClone.js b/apps/events/backend/src/utils/eventClone.js new file mode 100644 index 0000000..fb753a3 --- /dev/null +++ b/apps/events/backend/src/utils/eventClone.js @@ -0,0 +1,93 @@ +/** + * Event cloning (1.47.0). The copy itself is made by the event form in the browser — it opens + * "New event" filled in from the source event (details, sessions, options, variants, early-bird + * tiers, form, feedback form, sections, notification recipients), so everything can be changed + * before saving. This file copies the parts that form doesn't hold, once the new event exists: + * allocation sets with their groups, and (admins only) the planned costs. + * + * Never copied: registrations and everything people did, coupons, attachments, bundles, the kids + * check-in setup (kids ticket and rooms) and volunteer roles. + */ + +const prisma = require('../config/db'); +const { v4: uuidv4 } = require('uuid'); + +const COST_FIELDS = ['label', 'costType', 'amount', 'paidFromMethod', 'notes']; + +/** + * Costs for the new event. A cost tied to a ticket option moves to the new event's option with + * the same name; when there's none it stays on the event as a whole. + * @param {object[]} costs the source event's EventCost rows (with `eventOption.name`) + * @param {object[]} newOptions the new event's options ({ id, name }) + */ +function costCopies(costs, newOptions) { + const byName = new Map(newOptions.map(o => [String(o.name).trim().toLowerCase(), o.id])); + return costs.map(c => { + const data = {}; + for (const f of COST_FIELDS) data[f] = c[f] ?? null; + const name = c.eventOption?.name ? String(c.eventOption.name).trim().toLowerCase() : null; + data.eventOptionId = (name && byName.get(name)) || null; + return data; + }); +} + +/** The source's allocation sets worth copying: all but the kids rooms. */ +function setsToCopy(sets, kidsRoomSetId) { + return sets.filter(s => s.id !== kidsRoomSetId); +} + +function cloneError(message, statusCode = 400) { + const err = new Error(message); + err.statusCode = statusCode; + return err; +} + +/** + * Copies allocation sets and groups (and costs when `withCosts`) from `fromId` to the just-made + * event `toId`. Refused once the new event has registrations or allocation sets, so it can only + * fill a fresh copy. + * @returns {Promise<{ sets: number, groups: number, costs: number }>} + */ +async function copyEventSetup(fromId, toId, { withCosts = false } = {}) { + if (fromId === toId) throw cloneError("An event can't be copied onto itself"); + const [from, to] = await Promise.all([ + prisma.event.findUnique({ + where: { id: fromId }, + select: { + id: true, kidsRoomSetId: true, + allocationSets: { orderBy: { order: 'asc' }, include: { groups: { orderBy: { order: 'asc' } } } }, + costs: { orderBy: { createdAt: 'asc' }, include: { eventOption: { select: { name: true } } } }, + }, + }), + prisma.event.findUnique({ + where: { id: toId }, + select: { id: true, eventOptions: { select: { id: true, name: true } }, _count: { select: { registrations: true, allocationSets: true } } }, + }), + ]); + if (!from || !to) throw cloneError('Event not found', 404); + if (to._count.registrations > 0 || to._count.allocationSets > 0) { + throw cloneError('Setup can only be copied into a new event (this one already has registrations or groups)', 409); + } + + const sets = setsToCopy(from.allocationSets, from.kidsRoomSetId); + const costs = withCosts ? costCopies(from.costs, to.eventOptions) : []; + let groups = 0; + await prisma.$transaction(async tx => { + for (const s of sets) { + const set = await tx.allocationSet.create({ data: { id: uuidv4(), eventId: toId, name: s.name, showOnTicket: s.showOnTicket, order: s.order } }); + for (const g of s.groups) { + await tx.allocationGroup.create({ + data: { + id: uuidv4(), setId: set.id, name: g.name, capacity: g.capacity, gender: g.gender, + leaderUserId: g.leaderUserId, order: g.order, minAge: g.minAge, maxAge: g.maxAge, ratio: g.ratio, + }, + }); + groups++; + } + } + for (const c of costs) await tx.eventCost.create({ data: { id: uuidv4(), eventId: toId, ...c } }); + }); + return { sets: sets.length, groups, costs: costs.length }; +} + +module.exports = { copyEventSetup, costCopies, setsToCopy }; diff --git a/apps/events/backend/tests/eventClone.test.js b/apps/events/backend/tests/eventClone.test.js new file mode 100644 index 0000000..8fd1491 --- /dev/null +++ b/apps/events/backend/tests/eventClone.test.js @@ -0,0 +1,31 @@ +jest.mock('../src/config/db', () => ({})); +const { costCopies, setsToCopy } = require('../src/utils/eventClone'); +const { isBlocked } = require('../src/hub/readOnly'); + +describe('event cloning', () => { + test('costs move to the new option with the same name, else to the whole event', () => { + const costs = [ + { id: 'c1', label: 'Venue', costType: 'fixed', amount: 5000, paidFromMethod: null, notes: null, eventOptionId: null, eventOption: null }, + { id: 'c2', label: 'Meals', costType: 'per_person', amount: 120, paidFromMethod: 'cash', notes: 'x', eventOptionId: 'old-a', eventOption: { name: 'Adult ' } }, + { id: 'c3', label: 'T-shirts', costType: 'per_person', amount: 80, paidFromMethod: null, notes: null, eventOptionId: 'old-b', eventOption: { name: 'Leader' } }, + ]; + const out = costCopies(costs, [{ id: 'new-a', name: 'adult' }, { id: 'new-c', name: 'Child' }]); + expect(out).toEqual([ + { label: 'Venue', costType: 'fixed', amount: 5000, paidFromMethod: null, notes: null, eventOptionId: null }, + { label: 'Meals', costType: 'per_person', amount: 120, paidFromMethod: 'cash', notes: 'x', eventOptionId: 'new-a' }, + { label: 'T-shirts', costType: 'per_person', amount: 80, paidFromMethod: null, notes: null, eventOptionId: null }, + ]); + // Nothing of the source rows' identity is carried over. + for (const c of out) expect(c.id).toBeUndefined(); + }); + + test('kids rooms are not copied', () => { + const sets = [{ id: 'rooms' }, { id: 'kids' }, { id: 'buses' }]; + expect(setsToCopy(sets, 'kids').map(s => s.id)).toEqual(['rooms', 'buses']); + expect(setsToCopy(sets, null)).toHaveLength(3); + }); + + test('copying setup is blocked in licence read-only mode', () => { + expect(isBlocked('POST', '/api/events/abc/copy-from')).toBe(true); + }); +}); diff --git a/apps/events/docs/HANDOVER.md b/apps/events/docs/HANDOVER.md index 906b884..ce07986 100644 --- a/apps/events/docs/HANDOVER.md +++ b/apps/events/docs/HANDOVER.md @@ -1,6 +1,6 @@ # Handover — where things stand and how to carry on -Last updated: 2026-10-28, after **1.46.2** (and Hub 1.4.0). The plan itself is in +Last updated: 2026-10-28, after **1.47.0** (and Hub 1.4.0). The plan itself is in [ROADMAP-v2.md](./ROADMAP-v2.md) (decisions table at the end); the previous round of features is in [FEATURES-ROUND-1.md](./FEATURES-ROUND-1.md). @@ -14,6 +14,7 @@ encrypted settings unreadable or break existing installs. | Version | What | |---------|------| +| 1.47.0 | **Copy an event** (§6 part 1): "Copy" opens the event editor filled in from the source (campus, sessions, options, tiers, sections, form, recipients, feedback, certificates); "New start" moves every date; allocation groups and (admins) costs copied by `POST /api/events/:id/copy-from`. No registrations, coupons, attachments, kids check-in or volunteer roles | | 1.46.0 | **Volunteer rosters** (§5): serving roles per event or session, anyone signs up (or supervisors assign), day-before reminders, "can't make it" swaps that happen on accept (notify recipients emailed), self check-in with the event's QR code or by staff, kids-room roles count as leaders on duty, free volunteer ticket off by default, roster sheet and hours served. Also fixes the 1.45.0 kids ticket being offered publicly | | 1.46.1 | Removed the Gitea CI workflow (no runner): test, lint and deploy by hand | | 1.46.2 | Licence page: what's new (from WHATS-NEW.md via the Hub), withdraw update request, "Not now", urgent updates, provider notices banner (Hub 1.4.0: releases from git tags, Notices page) | @@ -47,7 +48,8 @@ encrypted settings unreadable or break existing installs. Hub 1.1.0 is deployed with update requests rolled out, and `scripts/install.sh` has been tried on a test server (both done 2026-10-28). -1. **1.47.0 — Event series & cloning** (§6), then **1.48.0 — outbound webhooks** (§8). +1. **Event series** (§6), one patch per part: **1.47.1 series** (can span campuses), **1.47.2 + year-on-year reports**, **1.47.3 season pass** — then **1.48.0 — outbound webhooks** (§8). ## Working on this repo @@ -197,8 +199,7 @@ a test server (both done 2026-10-28). site's heartbeat reports a newer version. Joshua then runs `scripts/deploy.sh` on the server. - Local testing: run the Hub (`../events-hub`, ports 5200/3200), create a licence there, and start Cross Events with `HUB_URL=http://localhost:5200` and `HUB_PUBLIC_KEY` = the key on Hub → Settings. -- `scripts/install.sh` — fresh Ubuntu server to a running site (written and syntax-checked; not yet - run on a real server). +- `scripts/install.sh` — fresh Ubuntu server to a running site (tried on a test server 2026-10-28). ## Where campuses live (1.43.0) @@ -282,6 +283,20 @@ a test server (both done 2026-10-28). - e2e: `volunteers.spec.ts` on the seeded hidden "E2E Serving Sunday" (role, ticket hidden publicly, sign-up, cover request, staff take over, QR check-in, roster). +## Where copying an event lives (1.47.0) + +- The copy is made in the browser: `EventModal` in `app/dashboard/supervisor/events/page.tsx` takes + `source` (create mode, `cloning`), fills its state from it (`cloneOptions` leaves out the kids and + volunteer tickets and all ids; cancelled sessions dropped; sessions keyed by the source's ids so + late joining still points right; sections loaded and mapped onto the copied options; feedback + questions without the sent/answered state), and `moveAllDates` shifts every date for "New start". + It saves through the normal create path, so **a new field on the event form is copied + automatically** if it's initialised from `base`. +- What the form doesn't hold is copied by the server afterwards: `utils/eventClone.js` + (`copyEventSetup`: allocation sets/groups except `kidsRoomSetId`, costs for admins only since + costs are admin-only) via `POST /api/events/:id/copy-from`. Tests: `tests/eventClone.test.js`, + e2e "copy an event" in `supervisor.spec.ts`. + ## Known gaps / follow-ups - WhatsApp STOP only works once someone pastes the webhook URL from Site settings → WhatsApp diff --git a/apps/events/docs/ROADMAP-v2.md b/apps/events/docs/ROADMAP-v2.md index f93bd71..3547201 100644 --- a/apps/events/docs/ROADMAP-v2.md +++ b/apps/events/docs/ROADMAP-v2.md @@ -34,7 +34,8 @@ Wallet passes are removed from scope (2026-10-28), so everything after volunteer up by one. 1.45.0 **kids check-in** shipped (fully digital: pickup codes, sticker panel, rooms with ratios, offline desk). 1.46.0 **volunteer rosters** shipped (roles per event or session, sign-ups and assigning, swaps on accept, QR self check-in, kids-room roles on duty, optional volunteer ticket). -**Next: 1.47.0 Event series and cloning.** +Event series and cloning ships as 1.47.0–1.47.3 (2026-10-28); 1.47.0 **copy an event** shipped. +**Next: 1.47.1 Event series.** **Repositories:** @@ -460,15 +461,21 @@ Plan who serves where, for an event or each session. (Shipped in 1.46.0 — deci ## 6. Event series and cloning -- **Clone event:** copy an event with its options, variants, early-bird tiers, - forms, consent text, feedback form, cost template, allocation groups and - sessions (dates shifted to the new start). No registrations. -- **Series:** group separate events (Camp 2025, Camp 2026; monthly Men's +Four releases, one per part (2026-10-28): **1.47.0** clone, **1.47.1** series, **1.47.2** +year-on-year reports, **1.47.3** season pass. + +- **Clone event (1.47.0 ✅):** "Copy" opens the **New event popup filled in** from the source, so + everything can be changed before saving: options, variants, early-bird tiers, form, consent + text, feedback form, sections, notification recipients, certificates, reminders, allocation + groups, cost template (admins) and sessions. A "New start" moves every date with it. Of the + newer features only the **campus** is copied — not kids check-in or volunteer roles. No + registrations, **no coupons**. +- **Series (1.47.1):** group separate events (Camp 2025, Camp 2026; monthly Men's Breakfast) on one series page, with "Next in this series" and a series - follow/notify option. -- **Year-on-year reports:** registrations, income and attendance compared + follow/notify option. **A series can span several campuses.** +- **Year-on-year reports (1.47.2):** registrations, income and attendance compared across events in a series. -- **Season pass:** a bundle across events in a series (extends event bundles). +- **Season pass (1.47.3):** a bundle across events in a series (extends event bundles). --- @@ -953,7 +960,7 @@ income justify the hardware: | 6 | 1.41.0 ✅ – 1.42.0 ✅ + Hub 1.0 ✅ – 1.1 ✅ | Install/update scripts, `/health`, licence step in `/setup`, "Connect to Hub", heartbeat, licence states — plus the **Hub** app (separate repo); rename to Cross Events (1.41.3); Request update (1.42.0 / Hub 1.1.0) | Must exist before the first church is sold; Hope Family Church registers as install #1 | | 7 | 1.43.0 ✅ – 1.44.0 ✅ | **Multi-campus**: 1.43.0 campuses (settings, events, public filter and landing pages, home campus, filters, messages, summaries); 1.44.0 campus-scoped staff | Kids rooms and volunteer roles are per campus, so campuses come first; scoping is split out because it's security-heavy | | 8 | 1.45.0 ✅ – 1.46.0 ✅ | Kids check-in, Volunteer rosters | Depend on sessions and campuses | -| 9 | 1.47.0 – 1.48.0 | Event series & cloning, Outbound webhooks (Wallet passes removed from scope) | Smaller, independent wins | +| 9 | 1.47.0 ✅ – 1.47.3, 1.48.0 | Event series & cloning (1.47.0 clone, 1.47.1 series, 1.47.2 year-on-year reports, 1.47.3 season pass), Outbound webhooks (Wallet passes removed from scope) | Smaller, independent wins | | 10 | 1.49.0 – 1.51.0 | Admin dashboard/Ctrl+K/bulk actions, Afrikaans, Accessibility pass | Polish before the big release | | 11 | 1.52.0 | TypeScript backend + OpenAPI + `/api/v2` alongside v1 | The breaking-change groundwork | | 12 | **2.0.0** | **AI helpers** (§15 — headline feature: draft an event, summarise reports and feedback, draft messages, improve text; through the Hub with a rand cap per licence), v1 API removed, migration guide, marketing site/docs for selling | The release. AI needs the Hub (phase 6) for the key, metering and caps | @@ -1008,6 +1015,7 @@ feature. | — | Wallet passes | **Removed from scope** (2026-10-28); everything after volunteer rosters moves up by one | | — | Kids check-in (1.45.0) | One release. **Fully digital** — no label printers: pickup code on the parent's phone, a "write on the sticker" panel for blank stickers. Staff desk only (no kiosk). Anyone with the pickup code can collect; families list authorised adults without accounts. Child profiles deleted after 6 months without a check-in (2026-10-28) | | — | Volunteer rosters (1.46.0) | Anyone with an account can volunteer. Roles are per event (or per session) — rosters cover one event/session and never repeat. A swap needs no approval: it happens once someone accepts, and the event's notify recipients are emailed. Volunteers check in by scanning a QR code or are checked in by staff. The free volunteer ticket is off by default and chosen per event. A role linked to a kids room counts its checked-in volunteers as leaders on duty for the room's ratio (2026-10-28) | +| — | Event series and cloning (1.47.x) | One release per part: 1.47.0 clone, 1.47.1 series, 1.47.2 year-on-year reports, 1.47.3 season pass. A clone opens the New event popup filled in from the source, so everything is set there before saving. Of the newer features a clone copies only the campus (not kids check-in or volunteer roles); coupons are never copied. A series can span several campuses (2026-10-28) | | — | POPIA: WhatsApp STOP | In 1.38.0, via WAWP's incoming `message` webhook with a secret in the URL (WAWP doesn't sign webhooks) (2026-10-23) | ## Still open diff --git a/apps/events/e2e/supervisor.spec.ts b/apps/events/e2e/supervisor.spec.ts index 3557eba..b37e80d 100644 --- a/apps/events/e2e/supervisor.spec.ts +++ b/apps/events/e2e/supervisor.spec.ts @@ -32,6 +32,48 @@ test.describe("supervisor tools", () => { expect(created?.sessions?.filter((s) => !s.cancelled)).toHaveLength(5); }); + test("copy an event: the popup is filled in and every date moves with the new start", async ({ page }) => { + type Full = EventRow & { eventOptions: { name: string; price: number }[]; sessions: { startsAt: string; label?: string | null }[] }; + const source = await api(page, "supervisor", "GET", `/api/events/${seed().events.course}`); + + await loginAs(page, "supervisor"); + await page.goto("/dashboard/supervisor/events"); + await page.locator("li", { hasText: "E2E Alpha Course" }).first().getByRole("button", { name: "Copy" }).click(); + await expect(page.getByRole("heading", { name: "Copy Event" })).toBeVisible(); + await expect(page.getByPlaceholder("Event title")).toHaveValue("E2E Alpha Course"); + await page.getByPlaceholder("Event title").fill("E2E Alpha Course (next term)"); + + // A week later: the start box holds the first session, so move it by seven days. + const start = page.getByTestId("copy-panel").locator('input[type="datetime-local"]'); + const current = await start.inputValue(); + const later = new Date(new Date(current).getTime() + 7 * 24 * 60 * 60 * 1000); + const pad = (n: number) => String(n).padStart(2, "0"); + await start.fill(`${later.getFullYear()}-${pad(later.getMonth() + 1)}-${pad(later.getDate())}T${pad(later.getHours())}:${pad(later.getMinutes())}`); + + const create = page.getByRole("button", { name: "Create Event" }); + for (let i = 0; i < 15 && !(await create.isVisible()); i++) { + await page.getByRole("button", { name: "Next →" }).click(); + } + await create.click(); + await expect(page.getByRole("heading", { name: "Copy Event" })).toBeHidden(); + + const all = await api(page, "supervisor", "GET", "/api/events/all?includePast=true"); + const row = all.find((e) => e.title === "E2E Alpha Course (next term)"); + expect(row).toBeTruthy(); + const copy = await api(page, "supervisor", "GET", `/api/events/${row!.id}`); + expect(copy.scheduleType).toBe("sessions"); + const active = (s: Full) => s.sessions.filter((x) => !(x as { cancelled?: boolean }).cancelled); + expect(active(copy)).toHaveLength(active(source).length); + const week = 7 * 24 * 60 * 60 * 1000; + // The form works in whole minutes (the seeded times have seconds). + const minute = (iso: string) => Math.floor(new Date(iso).getTime() / 60000) * 60000; + active(copy).forEach((s, i) => { + expect(minute(s.startsAt) - minute(active(source)[i].startsAt)).toBe(week); + expect(s.label ?? null).toBe(active(source)[i].label ?? null); + }); + expect(copy.eventOptions.map((o) => [o.name, o.price]).sort()).toEqual(source.eventOptions.map((o) => [o.name, o.price]).sort()); + }); + test("self-service kiosk: a visitor registers for a free event", async ({ page }) => { await page.goto("/self-service"); await page.getByPlaceholder("supervisor@example.com").fill(seed().users.supervisor.email); diff --git a/apps/events/frontend/package-lock.json b/apps/events/frontend/package-lock.json index f70eb07..b55bd12 100644 --- a/apps/events/frontend/package-lock.json +++ b/apps/events/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "hope-events-frontend", - "version": "1.46.2", + "version": "1.47.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "hope-events-frontend", - "version": "1.46.2", + "version": "1.47.0", "dependencies": { "@dnd-kit/core": "^6.3.1", "@hookform/resolvers": "^5.2.1", diff --git a/apps/events/frontend/package.json b/apps/events/frontend/package.json index ca3ad1e..3ffd1ae 100644 --- a/apps/events/frontend/package.json +++ b/apps/events/frontend/package.json @@ -1,6 +1,6 @@ { "name": "hope-events-frontend", - "version": "1.46.2", + "version": "1.47.0", "private": true, "scripts": { "dev": "next dev --turbopack", diff --git a/apps/events/frontend/src/app/dashboard/supervisor/events/page.tsx b/apps/events/frontend/src/app/dashboard/supervisor/events/page.tsx index 8e93aa1..c39a62b 100644 --- a/apps/events/frontend/src/app/dashboard/supervisor/events/page.tsx +++ b/apps/events/frontend/src/app/dashboard/supervisor/events/page.tsx @@ -10,7 +10,7 @@ import { useDismissingState } from "@/hooks/useDismissingState"; import { useSiteSettings } from "@/contexts/SiteSettingsContext"; import { useMyCampuses } from "@/hooks/useCampuses"; import { CampusBadge, CampusFilter, matchesCampus } from "@/components/shared/CampusFilter"; -import { Calendar } from "lucide-react"; +import { Calendar, Copy } from "lucide-react"; import { ChoicesEditor } from "@/components/shared/FormFieldExtras"; import { errorMessage } from "@/lib/utils"; import type { Event, EventAttachment, EventFormField, EventOption, Paginated, Section } from "@/types"; @@ -870,14 +870,49 @@ const blankOptions = (): OptionDraft[] => [ interface EventModalProps { mode: "create" | "edit"; event?: Event | null; + // Create mode: start from a copy of this event (cloning). + source?: Event | null; onClose: () => void; onSuccess: () => void; } -function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) { +/** A source event's ticket options as drafts for a copy — no ids, and without the staff-only + * kids and volunteer tickets (kids check-in and rosters aren't copied). `sourceIds` lines up + * with `drafts`, to map the source's sections onto the copy. */ +function cloneOptions(source: Event): { drafts: OptionDraft[]; sourceIds: string[] } { + const staffOnly = new Set([source.kidsOptionId, source.volunteerOptionId].filter(Boolean)); + const kept = (source.eventOptions || []).filter(o => !staffOnly.has(o.id)); + const tier = (t: { deadline: string; price: number; stockLimit?: number | null }): Tier => ({ deadline: toLocalDT(t.deadline), price: String(t.price ?? ""), stockLimit: String(t.stockLimit ?? "0") }); + return { + sourceIds: kept.map(o => o.id), + drafts: kept.map(o => ({ + name: o.name, + price: String(o.price ?? ""), + isMainTicket: !!o.isMainTicket, + stockLimit: String(o.stockLimit ?? "0"), + staffPrice: o.staffPrice !== null && o.staffPrice !== undefined ? String(o.staffPrice) : "", + sessionMode: o.sessionMode || "all", + earlyBirdTiers: (o.earlyBirdTiers || []).filter(t => !t.variantId).map(tier), + variants: (o.variants || []).map(v => ({ + name: v.name, + price: v.price !== null && v.price !== undefined ? String(v.price) : "", + stockLimit: String(v.stockLimit ?? "0"), + staffPrice: v.staffPrice !== null && v.staffPrice !== undefined ? String(v.staffPrice) : "", + earlyBirdTiers: (o.earlyBirdTiers || []).filter(t => t.variantId === v.id).map(tier), + })), + })), + }; +} + +const withoutIds = (fields: FieldDef[]): FieldDef[] => fields.map(f => ({ ...f, id: undefined })); + +function EventModal({ mode, event: ev, source, onClose, onSuccess }: EventModalProps) { const { token } = useAuth(); const { settings } = useSiteSettings(); const campusInfo = useMyCampuses(); + // Cloning fills "New event" from the source; everything can still be changed before saving. + const cloning = mode === "create" && !!source; + const base = mode === "edit" ? ev : source; // Campus-scoped: events for all campuses (and other campuses') are set up by admins and // supervisors for every campus — the server refuses changes, so the editor says so up front. const campusReadOnly = mode === "edit" && campusInfo.scoped && !campusInfo.campuses.some(c => c.id === ev?.campusId); @@ -888,26 +923,27 @@ function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) { // ── event draft ── // New events default their location to the organisation's address (settings.org_address); - // editing an existing event always reflects its own saved location instead. - const [draft, setDraft] = useState(() => ev ? { - title: ev.title || "", description: ev.description || "", - startDate: toLocalDT(ev.startDate), endDate: toLocalDT(ev.endDate), - registrationDeadline: toLocalDT(ev.registrationDeadline), goLiveAt: toLocalDT(ev.goLiveAt), - price: String(ev.price ?? ""), picture: ev.picture || "", redirectUrl: ev.redirectUrl || "", - isActive: ev.isActive !== false, isHidden: !!ev.isHidden, requiresAuth: ev.requiresAuth !== false, - requiresRegistration: ev.requiresRegistration !== false, - allowNamedAttendees: !!ev.allowNamedAttendees, - requiresParentalConsent: !!ev.requiresParentalConsent, consentText: ev.consentText || "", - consentCollectMedical: !!ev.consentCollectMedical, consentCollectEmergency: !!ev.consentCollectEmergency, consentCollectPhoto: !!ev.consentCollectPhoto, - waitlistEnabled: !!ev.waitlistEnabled, waitlistOfferHours: String(ev.waitlistOfferHours ?? 24), waitlistPartialOffers: ev.waitlistPartialOffers !== false, - allowTicketTransfer: ev.allowTicketTransfer !== false, - collectGender: !!ev.collectGender, - allowSponsorships: !!ev.allowSponsorships, sponsorshipGoalSpots: ev.sponsorshipGoalSpots ? String(ev.sponsorshipGoalSpots) : "", showSponsorshipProgress: ev.showSponsorshipProgress !== false, - contactName: ev.contactName || "", contactPhone: ev.contactPhone || "", contactEmail: ev.contactEmail || "", - location: ev.location || "", - campusId: ev.campusId || "", - scheduleType: ev.scheduleType === "sessions" ? "sessions" : "single", - attendanceMode: ev.attendanceMode === "pick" ? "pick" : "whole", + // editing an existing event always reflects its own saved location instead. A copy keeps the + // source's, but not its short link (those are unique) or its go-live time. + const [draft, setDraft] = useState(() => base ? { + title: base.title || "", description: base.description || "", + startDate: toLocalDT(base.startDate), endDate: toLocalDT(base.endDate), + registrationDeadline: toLocalDT(base.registrationDeadline), goLiveAt: cloning ? "" : toLocalDT(base.goLiveAt), + price: String(base.price ?? ""), picture: base.picture || "", redirectUrl: cloning ? "" : base.redirectUrl || "", + isActive: cloning || base.isActive !== false, isHidden: !!base.isHidden, requiresAuth: base.requiresAuth !== false, + requiresRegistration: base.requiresRegistration !== false, + allowNamedAttendees: !!base.allowNamedAttendees, + requiresParentalConsent: !!base.requiresParentalConsent, consentText: base.consentText || "", + consentCollectMedical: !!base.consentCollectMedical, consentCollectEmergency: !!base.consentCollectEmergency, consentCollectPhoto: !!base.consentCollectPhoto, + waitlistEnabled: !!base.waitlistEnabled, waitlistOfferHours: String(base.waitlistOfferHours ?? 24), waitlistPartialOffers: base.waitlistPartialOffers !== false, + allowTicketTransfer: base.allowTicketTransfer !== false, + collectGender: !!base.collectGender, + allowSponsorships: !!base.allowSponsorships, sponsorshipGoalSpots: base.sponsorshipGoalSpots ? String(base.sponsorshipGoalSpots) : "", showSponsorshipProgress: base.showSponsorshipProgress !== false, + contactName: base.contactName || "", contactPhone: base.contactPhone || "", contactEmail: base.contactEmail || "", + location: base.location || "", + campusId: base.campusId || "", + scheduleType: base.scheduleType === "sessions" ? "sessions" : "single", + attendanceMode: base.attendanceMode === "pick" ? "pick" : "whole", } : blankDraft(settings.org_address || "")); // A campus-scoped person's new event starts at their (first) campus — they can't make @@ -923,18 +959,22 @@ function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) { }, [mode, campusInfo.scoped, campusInfo.campuses, settings.org_address]); // ── multi-day schedule + attendance settings ── - const [sessions, setSessions] = useState(() => (ev?.sessions || []).map(s => keyed(toSessionDraft(s)))); + // A copy leaves out cancelled sessions and saves the rest as new ones; each keeps the source + // session's id as its key so "late joining until" still points at the same session. + const [sessions, setSessions] = useState(() => cloning + ? (base?.sessions || []).filter(s => !(s.cancelled || s.cancelledAt)).map(s => ({ ...toSessionDraft(s), id: undefined, hasCheckIns: false, key: s.id })) + : (base?.sessions || []).map(s => keyed(toSessionDraft(s)))); const [attendance, setAttendance] = useState(() => ({ - lateJoinEnabled: !!ev?.lateJoinEnabled, - lateJoinUntilKey: ev?.lateJoinUntilSessionId || "", - latePricing: ev?.latePricing || "full", - lateFixedPrice: ev?.lateFixedPrice !== null && ev?.lateFixedPrice !== undefined ? String(ev.lateFixedPrice) : "", - checkInWindow: ev?.checkInWindow || "whole_day", - remindersEnabled: !!ev?.sessionReminders, - reminderOffsets: ev?.sessionReminders?.offsets || [180], - reminderChannels: ev?.sessionReminders?.channels || ["email", "whatsapp"], - certificatesEnabled: !!ev?.certificatesEnabled, - certificate: { ...defaultCertificate(), ...(ev?.certificateConfig || {}) }, + lateJoinEnabled: !!base?.lateJoinEnabled, + lateJoinUntilKey: base?.lateJoinUntilSessionId || "", + latePricing: base?.latePricing || "full", + lateFixedPrice: base?.lateFixedPrice !== null && base?.lateFixedPrice !== undefined ? String(base.lateFixedPrice) : "", + checkInWindow: base?.checkInWindow || "whole_day", + remindersEnabled: !!base?.sessionReminders, + reminderOffsets: base?.sessionReminders?.offsets || [180], + reminderChannels: base?.sessionReminders?.channels || ["email", "whatsapp"], + certificatesEnabled: !!base?.certificatesEnabled, + certificate: { ...defaultCertificate(), ...(base?.certificateConfig || {}) }, })); const updAttendance = (patch: Partial) => setAttendance(a => ({ ...a, ...patch })); const multi = draft.scheduleType === "sessions"; @@ -950,7 +990,12 @@ function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) { const [changedNotice, setChangedNotice] = useState<{ eventId: string; moved: number; cancelled: number } | null>(null); // ── options (with per-variant tiers) ── + const [cloned] = useState(() => (cloning && source ? cloneOptions(source) : null)); const [options, setOptions] = useState(() => { + if (cloned) { + if (!cloned.drafts.length) return blankOptions(); + return cloned.drafts.some(o => o.isMainTicket) ? cloned.drafts : cloned.drafts.map((o, i) => ({ ...o, isMainTicket: i === 0 })); + } if (!ev?.eventOptions?.length) return blankOptions(); return ev.eventOptions.map((o) => { const allTiers = o.earlyBirdTiers || []; @@ -982,15 +1027,32 @@ function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) { // ── sections (staged for create mode) ── const [sectionDrafts, setSectionDrafts] = useState([]); + // A copy takes the source's sections onto the copied options. A section whose options were all + // left out (the kids or volunteer ticket) is dropped rather than widened to "all options". + useEffect(() => { + if (!cloned || !source?.id || !token) return; + apiFetch(`/api/sections?eventId=${source.id}`, { authToken: token }).then(list => { + const drafts: SectionDraft[] = []; + for (const sec of list || []) { + const ids = (sec.allowedOptions || []).map(o => o.eventOptionId); + const optionIndices = ids.map(id => cloned.sourceIds.indexOf(id)).filter(i => i >= 0); + if (ids.length && !optionIndices.length) continue; + drafts.push({ name: sec.name, optionIndices }); + } + setSectionDrafts(drafts); + }).catch(() => {}); + }, [cloned, source?.id, token]); // ── attachments (staged for create mode; uploaded after event is created) ── const [stagedFiles, setStagedFiles] = useState([]); // ── notify recipients (staged for create mode; saved after event is created) ── - const [notifyRecipientDrafts, setNotifyRecipientDrafts] = useState([]); + const [notifyRecipientDrafts, setNotifyRecipientDrafts] = useState(() => (cloning ? source?.notifyRecipients || [] : [])); // ── form ── - const [formDef, setFormDef] = useState({ isRequired: false, fields: [] }); + const [formDef, setFormDef] = useState(() => (cloning && source?.form + ? { isRequired: !!source.form.isRequired, fields: withoutIds(toFieldDefs(source.form.fields)) } + : { isRequired: false, fields: [] })); const formLoadedRef = useRef(false); useEffect(() => { if (mode !== "edit" || !ev?.id || formLoadedRef.current) return; @@ -1005,16 +1067,26 @@ function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) { const [fbDef, setFbDef] = useState({ isRequired: false, fields: [] }); const [fbSettings, setFbSettings] = useState({ sendAt: "", audience: "checked_in", anonymous: false, intro: "" }); const [fbMeta, setFbMeta] = useState<{ sentAt: string | null; invited: number; responses: number } | null>(null); + // How far a copy's dates have been moved so far, for the source's feedback date if it arrives + // after the move. + const shiftedRef = useRef(0); + const feedbackFrom = mode === "edit" ? ev?.id : cloning ? source?.id : undefined; useEffect(() => { - if (mode !== "edit" || !ev?.id || !token) return; - apiFetch(`/api/feedback/event/${ev.id}`, { authToken: token }).then(f => { + if (!feedbackFrom || !token) return; + apiFetch(`/api/feedback/event/${feedbackFrom}`, { authToken: token }).then(f => { if (!f) return; setFbEnabled(true); + if (cloning) { + // The questions and settings only — not whether it was sent or who answered. + setFbDef({ isRequired: false, fields: withoutIds(toFieldDefs(f.fields)) }); + setFbSettings({ sendAt: f.sendAt ? toLocalDT(new Date(new Date(f.sendAt).getTime() + shiftedRef.current)) : "", audience: f.audience || "checked_in", anonymous: !!f.anonymous, intro: f.intro || "" }); + return; + } setFbDef({ isRequired: false, fields: toFieldDefs(f.fields) }); setFbSettings({ sendAt: toLocalDT(f.sendAt), audience: f.audience || "checked_in", anonymous: !!f.anonymous, intro: f.intro || "" }); setFbMeta({ sentAt: f.sentAt, invited: f.invited, responses: f.responses }); }).catch(() => {}); - }, [mode, ev?.id, token]); + }, [feedbackFrom, cloning, token]); const enableFeedback = (on: boolean) => { setFbEnabled(on); if (on && fbDef.fields.length === 0) { @@ -1050,9 +1122,24 @@ function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) { const upd = (patch: Partial) => setDraft(d => ({ ...d, ...patch })); + // ── copy: move every date by the same amount (sessions, deadline, early birds, feedback) ── + const copyStart = multi ? scheduleBounds?.start || "" : draft.startDate; + const moveAllDates = (newStart: string) => { + const ms = newStart && copyStart ? new Date(newStart).getTime() - new Date(copyStart).getTime() : NaN; + if (!ms || isNaN(ms)) return; + shiftedRef.current += ms; + const sh = (v: string) => (v ? toLocalDT(new Date(new Date(v).getTime() + ms)) : v); + const shTiers = (tiers: Tier[]) => tiers.map(t => ({ ...t, deadline: sh(t.deadline) })); + setDraft(d => ({ ...d, startDate: sh(d.startDate), endDate: sh(d.endDate), registrationDeadline: sh(d.registrationDeadline), goLiveAt: sh(d.goLiveAt) })); + setSessions(list => list.map(s => ({ ...s, startsAt: sh(s.startsAt), endsAt: sh(s.endsAt) }))); + setOptions(list => list.map(o => ({ ...o, earlyBirdTiers: shTiers(o.earlyBirdTiers), variants: o.variants.map(v => ({ ...v, earlyBirdTiers: shTiers(v.earlyBirdTiers) })) }))); + setFbSettings(s => ({ ...s, sendAt: sh(s.sendAt) })); + }; + // ── auto-fill first option's price from the event base price (create mode only, until the - // user directly edits that option's price — then it becomes independent) ── - const [mainPriceTouched, setMainPriceTouched] = useState(false); + // user directly edits that option's price — then it becomes independent). A copy keeps its + // own option prices. ── + const [mainPriceTouched, setMainPriceTouched] = useState(cloning); useEffect(() => { if (mode !== "create" || mainPriceTouched) return; setOptions(prev => { @@ -1323,10 +1410,15 @@ function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) { if (formDef.isRequired || formDef.fields.length > 0) { body.form = { isRequired: !!formDef.isRequired, fields: formDef.fields.filter(f => f.label?.trim()).map((f, i) => ({ type: f.type, label: f.label, isRequired: !!f.isRequired, order: i, helpText: f.helpText || null, options: f.type === "multiple_choice" ? cleanChoices(f.options) : undefined })) }; } + if (cloning) body.clonedFromId = source!.id; const created = await apiFetch("/api/events", { method: "POST", authToken: token || undefined, body }); if (created?.id) { await saveOptions(created.id); await saveFeedback(created.id); + // Groups (and planned costs, for admins) aren't in this form; the server copies them. + if (cloning) { + await apiFetch(`/api/events/${created.id}/copy-from`, { method: "POST", authToken: token || undefined, body: { fromEventId: source!.id } }); + } // Fetch event to get final option IDs for sections const fullEvent = await apiFetch(`/api/events/${created.id}`).catch(() => null); const createdOptions = fullEvent?.eventOptions || []; @@ -1399,14 +1491,14 @@ function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) {
{/* Header */}
-

{mode === "create" ? "New Event" : "Edit Event"}

+

{cloning ? "Copy Event" : mode === "create" ? "New Event" : "Edit Event"}

{/* Step bar */}
{STEPS.map((s, i) => { - const clickable = mode === "edit"; + const clickable = mode === "edit" || cloning; return (
- Edit → +
+ + Edit → +
); } @@ -1970,6 +2079,19 @@ export default function ManageEventsPage() { } catch { setEditingEvent(ev); } setModalMode("edit"); }; + // A copy needs the whole source event (options, tiers, form, recipients). + const [copyFrom, setCopyFrom] = useState(null); + const openCopy = async (ev: Event) => { + try { + const full = await apiFetch(`/api/events/${ev.id}`, { authToken: token || undefined }); + setEditingEvent(null); + setCopyFrom(full); + setModalMode("create"); + } catch (e) { + setError(errorMessage(e) || "Couldn't load the event to copy"); + } + }; + const closeModal = () => { setModalMode(null); setEditingEvent(null); setCopyFrom(null); }; return (
@@ -2010,13 +2132,13 @@ export default function ManageEventsPage() {
{filtered.length === 0 ?

{events.length === 0 ? 'No events yet. Click "+ Add Event" to create one.' : "No events match the current filters."}

- :
    {filtered.map(ev => openEdit(ev)} />)}
+ :
    {filtered.map(ev => openEdit(ev)} onCopy={() => openCopy(ev)} />)}
}
{modalMode && ( - { setModalMode(null); setEditingEvent(null); }} + )}
diff --git a/apps/events/frontend/src/content/help/supervisor-events.tsx b/apps/events/frontend/src/content/help/supervisor-events.tsx index 7a5cbcc..8f99373 100644 --- a/apps/events/frontend/src/content/help/supervisor-events.tsx +++ b/apps/events/frontend/src/content/help/supervisor-events.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { Calendar, ListChecks, Layers, FileText, Eye, Bell, Paperclip, Lock, MessageSquareHeart, CalendarDays, ClipboardCheck } from "lucide-react"; +import { Calendar, ListChecks, Layers, FileText, Eye, Bell, Paperclip, Lock, MessageSquareHeart, CalendarDays, ClipboardCheck, Copy } from "lucide-react"; import { GuideItem } from "@/components/shared/GuideItem"; import type { HelpContent } from "./types"; @@ -16,6 +16,9 @@ export const supervisorEventsHelpContent: HelpContent = {

Search or toggle Include past / Show inactive (admin only) / Show closed to find an event, then tap "+ Add Event" or click a card to edit.

+ + "Copy" on an event card opens the editor filled in from that event: details, campus, sessions, ticket options, variants and early birds, sections, the form, notifications, feedback questions, certificates and reminders. Set the New start at the top and every date moves with it — the end, the sessions, the registration deadline, early-bird deadlines and the feedback date. Check each step, change what's different this time, and save. Groups (rooms, buses, teams) are copied too, and for admins the planned costs. Registrations, coupons, attachments, kids check-in and volunteer roles are not. + An event that's been cashed up shows a banner and can't be edited — it must be reopened from Cashup first. @@ -65,7 +68,7 @@ export const supervisorEventsHelpContent: HelpContent = { For multi-session events: late joining (until which session, and a full, pro-rata or fixed late price for main tickets — pro-rata rounds to the nearest R10), the check-in window (the whole day of a session, or only from 2 hours before it until it ends), and reminders before each session. For any event: completion certificates — four designs, your wording and signature, and who qualifies. "Preview certificate" shows a sample.
-

When creating a new event, later steps unlock as you complete the ones before them; editing an existing event lets you jump to any step freely.

+

When creating a new event, later steps unlock as you complete the ones before them; editing an existing event, or a copy, lets you jump to any step freely.

), }, diff --git a/apps/events/frontend/src/types/index.ts b/apps/events/frontend/src/types/index.ts index 44e2f1d..c42e530 100644 --- a/apps/events/frontend/src/types/index.ts +++ b/apps/events/frontend/src/types/index.ts @@ -178,6 +178,10 @@ export type Event = { sessionReminders?: { offsets: number[]; channels: ("email" | "whatsapp")[] } | null; certificatesEnabled?: boolean; certificateConfig?: CertificateConfig | null; + // Staff-only tickets and rooms (kids check-in 1.45.0, volunteer rosters 1.46.0). + kidsOptionId?: string | null; + kidsRoomSetId?: string | null; + volunteerOptionId?: string | null; // Set by GET /api/events while an early-bird tier is still running. earlyBirdEndsAt?: string | null; isSoldOut?: boolean; diff --git a/apps/events/package-lock.json b/apps/events/package-lock.json index 8094446..fdebee1 100644 --- a/apps/events/package-lock.json +++ b/apps/events/package-lock.json @@ -1,12 +1,12 @@ { "name": "hope-events", - "version": "1.46.2", + "version": "1.47.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "hope-events", - "version": "1.46.2", + "version": "1.47.0", "license": "ISC", "devDependencies": { "@playwright/test": "^1.64.0", diff --git a/apps/events/package.json b/apps/events/package.json index 9b7bd92..477ea27 100644 --- a/apps/events/package.json +++ b/apps/events/package.json @@ -1,6 +1,6 @@ { "name": "hope-events", - "version": "1.46.2", + "version": "1.47.0", "main": "index.js", "scripts": { "dev:backend": "cd backend && npm run dev",