From 809988e3989ca36312252b7abd910d283a2e8b73 Mon Sep 17 00:00:00 2001 From: Satelink Network Date: Tue, 24 Nov 2026 22:53:41 +0530 Subject: [PATCH] fix: publishing reliability, facilities UI redesign, and mobile layout --- e2e/test-publish-upi.spec.js | 123 +++++++++++++++++++++ lib/services/event-offers.js | 16 ++- lib/services/event-venue.js | 5 +- lib/services/organiser.js | 65 +++++++---- lib/services/sales-phases.js | 8 +- public/css/organiser.css | 176 ++++++++++++++++++++++++++++++ public/css/site.css | 14 ++- public/js/organiser.js | 204 +++++++++++++++++++++++++++++------ 8 files changed, 545 insertions(+), 66 deletions(-) create mode 100644 e2e/test-publish-upi.spec.js diff --git a/e2e/test-publish-upi.spec.js b/e2e/test-publish-upi.spec.js new file mode 100644 index 0000000..3439d61 --- /dev/null +++ b/e2e/test-publish-upi.spec.js @@ -0,0 +1,123 @@ +// e2e/test-publish-upi.spec.js +import { test, expect } from '@playwright/test'; +import { signInAs, expectAccessible, expectNoHorizontalOverflow } from './helpers.js'; + +test('verify facilities redesign and direct upi publishing', async ({ page }) => { + await signInAs(page, 'organiser'); + await page.goto('/organiser/new?fresh=1'); + + // Start draft + await page.getByRole('button', { name: /Party or nightlife/ }).click(); + await expect(page.locator('#f-title')).toBeVisible(); + + // Step 1: Basics + const title = `The Saturday Night Social ${Date.now()}`; + await page.locator('#f-title').fill(title); + await page.locator('#f-city').fill('Bengaluru'); + await page.locator('#f-area').fill('Indiranagar'); + await page.locator('#f-venue').fill('Secret Warehouse Indiranagar'); + + const tmrw = new Date(Date.now() + 864e5).toISOString().slice(0, 10); + await page.locator('#f-startLocal').fill(`${tmrw}T20:00`); + await page.locator('#f-endLocal').fill(`${tmrw}T23:00`); + + await page.locator('#f-description').fill('Amazing direct UPI party with great music, visual effects and fun people. 21+ only.'); + const rightsCheckbox = page.locator('#f-imageRightsConfirmed'); + if (await rightsCheckbox.isVisible()) { + await rightsCheckbox.check(); + } + + // Step 2: Tickets + await page.getByRole('button', { name: /Next: Tickets/ }).click(); + await expect(page.locator('input[value="direct_upi"]')).toBeVisible(); + + await page.locator('input[value="direct_upi"]').check(); + await expect(page.locator('#f-organiserUpiId')).toBeVisible(); + + await page.locator('#f-organiserUpiId').fill('organiser@okaxis'); + await page.locator('#f-organiserPayeeName').fill('Party Host'); + + const kindSelect = page.locator('select[data-path="tickets.0.kind"]'); + await expect(kindSelect).toBeVisible(); + await kindSelect.selectOption('paid'); + + const priceInput = page.locator('input[data-path="tickets.0.pricePaise"]'); + await expect(priceInput).toBeVisible(); + await priceInput.fill('499'); + + // Step 3: Features + await page.getByRole('button', { name: /Next: Features/ }).click(); + await expect(page.getByRole('heading', { name: /Facilities & amenities/i })).toBeVisible(); + + // Verify all 5 categories exist + await expect(page.getByRole('heading', { name: 'Parking', exact: true })).toBeVisible(); + await expect(page.getByRole('heading', { name: 'Food & Beverages', exact: true })).toBeVisible(); + await expect(page.getByRole('heading', { name: 'Accessibility', exact: true })).toBeVisible(); + await expect(page.getByRole('heading', { name: 'Medical & Safety', exact: true })).toBeVisible(); + await expect(page.getByRole('heading', { name: 'Other Facilities & Rules', exact: true })).toBeVisible(); + + // Test individual facility card toggle + const valetParking = page.locator('[data-act="toggle-facility"][data-key="valet_parking"]'); + await expect(valetParking).toBeVisible(); + await valetParking.click(); + await expect(valetParking).toHaveClass(/is-selected/); + await expect(valetParking).toHaveAttribute('aria-checked', 'true'); + + // Test "Select all" in Parking category + const selectAllParking = page.locator('[data-act="select-all-cat"][data-cat="parking"]'); + await selectAllParking.click(); + const parkingSelected = page.locator('.facility-category-section:has-text("Parking") [aria-checked="true"]'); + expect(await parkingSelected.count()).toBe(5); + + // Test "Clear" in Parking category + const clearParking = page.locator('[data-act="clear-cat"][data-cat="parking"]'); + await clearParking.click(); + expect(await parkingSelected.count()).toBe(0); + + // Toggle specific amenities across categories + await page.locator('[data-act="toggle-facility"][data-key="free_parking"]').click(); + await page.locator('[data-act="toggle-facility"][data-key="alcohol_available"]').click(); + await page.locator('[data-act="toggle-facility"][data-key="wheelchair_accessible"]').click(); + await page.locator('[data-act="toggle-facility"][data-key="first_aid"]').click(); + + // Add custom amenity + await page.locator('#custom-fac-name').fill('Rooftop Swimming Pool'); + await page.locator('#custom-fac-desc').fill('Complimentary towel service provided'); + await page.locator('button[data-act="add-custom-facility"]').click(); + await expect(page.locator('.custom-facility-item')).toContainText('Rooftop Swimming Pool'); + + // Take screenshot of redesigned Facilities UI + await page.screenshot({ path: 'test-results/facilities-redesign.png', fullPage: false }); + await expectNoHorizontalOverflow(page); + await expectAccessible(page); + + // Step 4: Preview + await page.getByRole('button', { name: /^Next/ }).click(); + await expect(page.getByRole('button', { name: /Publish Event/i })).toBeVisible(); + + // Click Publish Event to open dialog + await page.getByRole('button', { name: /Publish Event/i }).click(); + + const dialog = page.locator('[data-publish-dialog]'); + await expect(dialog).toBeVisible(); + await expect(dialog.getByRole('heading', { name: /Publish event/i })).toBeVisible(); + await expect(dialog).toContainText('organiser@okaxis'); + await expect(dialog).toContainText('Party Host'); + + // Take screenshot of confirmation dialog + await page.screenshot({ path: 'test-results/publish-dialog.png' }); + + // Click Publish Event Now + const confirmBtn = dialog.locator('[data-act="publish-confirm"]'); + await expect(confirmBtn).toBeVisible(); + await confirmBtn.click(); + + // Wait for published state + await expect(page.locator('.wz-done')).toBeVisible({ timeout: 10000 }); + await expect(page.locator('.wz-done h1')).toContainText('Your event is live'); + + // Take screenshot of published confirmation + await page.screenshot({ path: 'test-results/event-published.png' }); + await expectNoHorizontalOverflow(page); + await expectAccessible(page); +}); diff --git a/lib/services/event-offers.js b/lib/services/event-offers.js index e3ce755..df26af6 100644 --- a/lib/services/event-offers.js +++ b/lib/services/event-offers.js @@ -4,7 +4,9 @@ import { db } from '../db.js'; import { HttpError } from '../http.js'; -export async function saveEventOffers(c, eventId, offers = []) { +const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; + +export async function saveEventOffers(c, eventId, offers = [], tierMapping = {}) { await c.query(`DELETE FROM event_offers WHERE event_id = $1`, [eventId]); if (!Array.isArray(offers) || offers.length === 0) { await c.query(`UPDATE events SET has_offers = false WHERE id = $1`, [eventId]); @@ -25,10 +27,14 @@ export async function saveEventOffers(c, eventId, offers = []) { const maxDiscountPaise = o.maxDiscountPaise ? parseInt(o.maxDiscountPaise, 10) : null; const minOrderPaise = o.minOrderPaise ? Math.max(0, parseInt(o.minOrderPaise, 10)) : 0; const minQuantity = o.minQuantity ? Math.max(1, parseInt(o.minQuantity, 10)) : 1; - const tierIds = Array.isArray(o.applicableTierIds) ? o.applicableTierIds.filter(Boolean) : []; - const phaseIds = Array.isArray(o.applicablePhaseIds) ? o.applicablePhaseIds.filter(Boolean) : []; - const startsAt = o.startsAt ? new Date(o.startsAt) : null; - const expiresAt = o.expiresAt ? new Date(o.expiresAt) : null; + const tierIds = Array.isArray(o.applicableTierIds) + ? o.applicableTierIds.map((tid) => tierMapping[tid] || tid).filter((tid) => typeof tid === 'string' && UUID_REGEX.test(tid)) + : []; + const phaseIds = Array.isArray(o.applicablePhaseIds) + ? o.applicablePhaseIds.filter((pid) => typeof pid === 'string' && UUID_REGEX.test(pid)) + : []; + const startsAt = o.startsAt && !isNaN(new Date(o.startsAt).getTime()) ? new Date(o.startsAt) : null; + const expiresAt = o.expiresAt && !isNaN(new Date(o.expiresAt).getTime()) ? new Date(o.expiresAt) : null; const totalLimit = o.totalLimit ? parseInt(o.totalLimit, 10) : null; const perUserLimit = o.perUserLimit ? parseInt(o.perUserLimit, 10) : 1; const active = o.active !== false; diff --git a/lib/services/event-venue.js b/lib/services/event-venue.js index 45cdc62..b862456 100644 --- a/lib/services/event-venue.js +++ b/lib/services/event-venue.js @@ -4,6 +4,8 @@ import { db } from '../db.js'; import { HttpError } from '../http.js'; +const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; + export const SECTION_PRESETS = { stage: { name: 'Stage', color: '#1f2937', category: 'stage', shape: 'rect' }, general: { name: 'General Admission / Standing', color: '#3b82f6', category: 'general', shape: 'rect' }, @@ -51,7 +53,8 @@ export async function saveEventVenueLayout(c, eventId, layoutConfig = {}, sectio const minPerBooking = Math.max(1, parseInt(s.minPerBooking, 10) || 1); const maxPerBooking = Math.max(minPerBooking, parseInt(s.maxPerBooking, 10) || 10); const status = s.status === 'unavailable' ? 'unavailable' : (s.status === 'sold_out' ? 'sold_out' : 'available'); - const ticketTypeId = tierMapping[sectionKey] || s.ticketTypeId || null; + const rawTier = tierMapping[sectionKey] || s.ticketTypeId || null; + const ticketTypeId = typeof rawTier === 'string' && UUID_REGEX.test(rawTier) ? rawTier : null; const secRow = (await c.query( `INSERT INTO event_venue_sections ( diff --git a/lib/services/organiser.js b/lib/services/organiser.js index 7eb0b41..bd116cc 100644 --- a/lib/services/organiser.js +++ b/lib/services/organiser.js @@ -4,6 +4,7 @@ // A draft is JSON in event_drafts. It is never visible publicly: public queries read `events`, // and an events row is only created by publishDraft() after an explicit, confirmed request. import crypto from 'node:crypto'; +import { logger } from '../logger.js'; import { db } from '../db.js'; import { HttpError } from '../http.js'; import { z, parse } from '../validate.js'; @@ -149,16 +150,18 @@ export const DraftData = z.object({ schedule: EventScheduleDraft.optional(), tickets: z.array(TicketDraft).max(MAX_TIERS).optional(), facilities: z.array(z.object({ - category: z.string().max(40), + category: z.string().max(40).optional(), facilityKey: z.string().max(80).optional(), + key: z.string().max(80).optional(), name: z.string().max(100), - description: text(500), - icon: text(50), + description: z.string().max(500).nullable().optional(), + icon: z.string().max(50).nullable().optional(), isCustom: flag }).passthrough()).max(60).optional(), offers: z.array(z.object({ + id: z.string().max(60).optional(), name: z.string().max(80), - description: text(500), + description: z.string().max(500).nullable().optional(), code: text(30), discountType: z.enum(['percentage', 'fixed_amount']), discountValue: z.coerce.number().int(), @@ -177,7 +180,8 @@ export const DraftData = z.object({ canvasWidth: looseInt, canvasHeight: looseInt, sections: z.array(z.object({ - sectionKey: z.string().max(60), + id: z.string().max(60).optional(), + sectionKey: z.string().max(60).optional(), name: z.string().max(80), category: z.string().max(40).optional(), color: text(20), @@ -196,6 +200,7 @@ export const DraftData = z.object({ salesTimeline: z.object({ enabled: flag, phases: z.array(z.object({ + id: z.string().max(60).optional(), name: z.string().max(80), startsAt: text(40), endsAt: text(40), @@ -514,7 +519,7 @@ export function publishIssues(d, { checkout = ticketCheckoutStatus(), now = new if (Array.isArray(d.facilities) && d.facilities.length > 0) { d.facilities.forEach((fac, idx) => { if (!clean(fac.name)) { - err('facilities', `facilities.${idx}.name`, `Facility ${idx + 1}: Name is required.`); + err('features', `facilities.${idx}.name`, `Facility ${idx + 1}: Name is required.`); } }); } @@ -522,12 +527,12 @@ export function publishIssues(d, { checkout = ticketCheckoutStatus(), now = new // Offers if (Array.isArray(d.offers) && d.offers.length > 0) { d.offers.forEach((o, idx) => { - if (!clean(o.name)) err('offers', `offers.${idx}.name`, `Offer ${idx + 1}: Offer name is required.`); + if (!clean(o.name)) err('features', `offers.${idx}.name`, `Offer ${idx + 1}: Offer name is required.`); if (!o.discountValue || o.discountValue <= 0) { - err('offers', `offers.${idx}.discountValue`, `${clean(o.name) || 'Offer'}: Discount value must be greater than 0.`); + err('features', `offers.${idx}.discountValue`, `${clean(o.name) || 'Offer'}: Discount value must be greater than 0.`); } if (o.discountType === 'percentage' && o.discountValue > 100) { - err('offers', `offers.${idx}.discountValue`, `${clean(o.name) || 'Offer'}: Percentage discount cannot exceed 100%.`); + err('features', `offers.${idx}.discountValue`, `${clean(o.name) || 'Offer'}: Percentage discount cannot exceed 100%.`); } }); } @@ -536,19 +541,19 @@ export function publishIssues(d, { checkout = ticketCheckoutStatus(), now = new if (d.venueLayout && d.venueLayout.layoutType === 'section_based') { const secs = d.venueLayout.sections || []; if (!secs.length) { - err('venue', 'venueLayout.sections', 'Section-based venue layout selected: add at least one section or switch to General Admission.'); + err('features', 'venueLayout.sections', 'Section-based venue layout selected: add at least one section or switch to General Admission.'); } secs.forEach((s, idx) => { - if (!clean(s.name)) err('venue', `venueLayout.sections.${idx}.name`, `Section ${idx + 1}: Section name is required.`); + if (!clean(s.name)) err('features', `venueLayout.sections.${idx}.name`, `Section ${idx + 1}: Section name is required.`); }); } // Sales timeline if (d.salesTimeline?.enabled && Array.isArray(d.salesTimeline.phases)) { d.salesTimeline.phases.forEach((p, idx) => { - if (!clean(p.name)) err('timeline', `salesTimeline.phases.${idx}.name`, `Phase ${idx + 1}: Phase name is required.`); + if (!clean(p.name)) err('features', `salesTimeline.phases.${idx}.name`, `Phase ${idx + 1}: Phase name is required.`); if (p.startsAt && p.endsAt && new Date(p.endsAt) <= new Date(p.startsAt)) { - err('timeline', `salesTimeline.phases.${idx}.endsAt`, `Phase "${clean(p.name)}": End time must be after start time.`); + err('features', `salesTimeline.phases.${idx}.endsAt`, `Phase "${clean(p.name)}": End time must be after start time.`); } }); } @@ -868,7 +873,8 @@ export async function publishDraft(user, draftId, { version, confirm }) { if (confirm !== true) throw new HttpError(400, 'confirm_required', 'Publishing needs explicit confirmation.'); await requireOrganiser(user); const checkout = ticketCheckoutStatus(); - const result = await db.tx(async (c) => { + try { + const result = await db.tx(async (c) => { const draft = (await c.query('SELECT * FROM event_drafts WHERE id = $1 AND organiser_user_id = $2 FOR UPDATE', [draftId, user.id])).rows[0]; if (!draft) throw new HttpError(404, 'not_found', 'Draft not found'); if (draft.status !== 'active') throw new HttpError(409, 'draft_closed', draft.status === 'published' ? 'This draft has already been published.' : 'This draft was discarded.'); @@ -1011,34 +1017,37 @@ export async function publishDraft(user, draftId, { version, confirm }) { } } + const tierIdMap = {}; for (const [i, t] of tickets.entries()) { const admitCount = Number.isInteger(t.admitCount) && t.admitCount > 0 ? t.admitCount : (t.category === 'couple' ? 2 : t.category === 'group' ? 4 : 1); const minPerBooking = Number.isInteger(t.minPerBooking) && t.minPerBooking > 0 ? t.minPerBooking : 1; const category = clean(t.category) || 'general'; const targetSessionId = t.sessionId || (t.validOn && sessionMap.get(t.validOn)) || null; - await c.query( + const salesStartAt = t.salesStartAt && !isNaN(new Date(t.salesStartAt).getTime()) ? new Date(t.salesStartAt) : null; + const salesEndAt = t.salesEndAt && !isNaN(new Date(t.salesEndAt).getTime()) ? new Date(t.salesEndAt) : null; + const tRow = (await c.query( `INSERT INTO ticket_types ( event_id, name, kind, price_paise, quantity, max_per_booking, min_per_booking, valid_on, eligibility, sort_order, category, admit_count, sales_start_at, sales_end_at, session_id - ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)`, + ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15) RETURNING id`, [ev.id, clean(t.name), t.kind, t.kind === 'free' ? 0 : t.pricePaise, t.quantity, t.maxPerBooking || 1, minPerBooking, t.validOn && t.validOn !== 'all' ? t.validOn : null, f.balance?.enabled || clean(t.eligibility) ? clean(t.eligibility) || null : null, - i, category, admitCount, t.salesStartAt ? new Date(t.salesStartAt) : null, - t.salesEndAt ? new Date(t.salesEndAt) : null, targetSessionId]); + i, category, admitCount, salesStartAt, salesEndAt, targetSessionId])).rows[0]; + if (t.id && tRow?.id) tierIdMap[t.id] = tRow.id; } if (Array.isArray(d.facilities) && d.facilities.length > 0) { await saveEventFacilities(c, ev.id, d.facilities); } if (Array.isArray(d.offers) && d.offers.length > 0) { - await saveEventOffers(c, ev.id, d.offers); + await saveEventOffers(c, ev.id, d.offers, tierIdMap); } if (d.salesTimeline?.enabled && Array.isArray(d.salesTimeline.phases) && d.salesTimeline.phases.length > 0) { - await saveEventSalesPhases(c, ev.id, d.salesTimeline.phases); + await saveEventSalesPhases(c, ev.id, d.salesTimeline.phases, tierIdMap); } if (d.venueLayout && d.venueLayout.layoutType === 'section_based' && Array.isArray(d.venueLayout.sections) && d.venueLayout.sections.length > 0) { - await saveEventVenueLayout(c, ev.id, d.venueLayout, d.venueLayout.sections); + await saveEventVenueLayout(c, ev.id, d.venueLayout, d.venueLayout.sections, tierIdMap); } if (imageIds.length) await c.query(`UPDATE event_images SET is_public = true WHERE id = ANY($1)`, [imageIds]); @@ -1055,6 +1064,20 @@ export async function publishDraft(user, draftId, { version, confirm }) { invalidatePublicEventCache(); const path = `${isTripCategory(result.category) ? '/trips' : '/events'}/${result.slug}`; return { eventId: result.id, slug: result.slug, path, url: `${siteUrl()}${path}`, manageUrl: `/organiser/events/${result.id}` }; + } catch (err) { + if (err instanceof HttpError) throw err; + logger.error('publishDraft transaction failed', err, { draftId, userId: user.id }); + if (err.code === '23505') { + throw new HttpError(422, 'duplicate_entry', 'An event with this title or configuration already exists. Please adjust and try again.'); + } + if (err.code === '23503') { + throw new HttpError(422, 'reference_error', 'A linked resource could not be verified. Please review images and venue details.'); + } + if (err.code === '23514') { + throw new HttpError(422, 'constraint_violation', 'One or more event parameters violates system constraints. Please check ticket limits and dates.'); + } + throw new HttpError(422, 'publish_failed', err.message || 'Event publishing could not be completed. Please review your details and try again.'); + } } // ---------- organiser's events ---------- diff --git a/lib/services/sales-phases.js b/lib/services/sales-phases.js index fa35a91..2e4bb51 100644 --- a/lib/services/sales-phases.js +++ b/lib/services/sales-phases.js @@ -4,7 +4,9 @@ import { db } from '../db.js'; import { HttpError } from '../http.js'; -export async function saveEventSalesPhases(c, eventId, phases = []) { +const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; + +export async function saveEventSalesPhases(c, eventId, phases = [], tierMapping = {}) { await c.query(`DELETE FROM event_sales_phases WHERE event_id = $1`, [eventId]); if (!Array.isArray(phases) || phases.length === 0) { await c.query(`UPDATE events SET has_sales_phases = false WHERE id = $1`, [eventId]); @@ -28,7 +30,9 @@ export async function saveEventSalesPhases(c, eventId, phases = []) { const pricePaise = p.pricePaise != null ? Math.max(0, parseInt(p.pricePaise, 10)) : null; const quota = p.quota != null ? Math.max(1, parseInt(p.quota, 10)) : null; const maxPerBooking = p.maxPerBooking != null ? Math.max(1, parseInt(p.maxPerBooking, 10)) : 10; - const tierIds = Array.isArray(p.applicableTierIds) ? p.applicableTierIds.filter(Boolean) : []; + const tierIds = Array.isArray(p.applicableTierIds) + ? p.applicableTierIds.map((tid) => tierMapping[tid] || tid).filter((tid) => typeof tid === 'string' && UUID_REGEX.test(tid)) + : []; const accessCode = p.accessCode ? String(p.accessCode).trim().toUpperCase() : null; const isActive = p.isActive !== false; diff --git a/public/css/organiser.css b/public/css/organiser.css index 725e69b..27f43b5 100644 --- a/public/css/organiser.css +++ b/public/css/organiser.css @@ -445,3 +445,179 @@ .pill-danger { background: rgba(255, 49, 91, 0.15); border-color: rgba(255, 49, 91, 0.4); color: var(--party-pink, #FF315B); } .pill-pending { background: rgba(255, 200, 0, 0.15); border-color: rgba(255, 200, 0, 0.4); color: #ffd15c; } +/* ========================================================================== + Facilities & Amenities Redesign (Phase 2 & Screenshot 1 Remediation) + ========================================================================== */ +.facilities-top-bar { + margin-bottom: 20px; + padding: 12px 14px; + background: var(--surface-input, #0B0E1E); + border: 1px solid var(--border-soft, #2A3158); + border-radius: 8px; +} +.facility-category-section { + background: var(--surface-input, #0B0E1E); + border: 1px solid var(--border-soft, #2A3158); + border-radius: 10px; + padding: 16px; + margin-bottom: 16px; + transition: border-color 0.2s ease, box-shadow 0.2s ease; +} +.facility-category-section:focus-within { + border-color: rgba(0, 217, 255, 0.4); +} +.facility-category-head { + display: flex; + justify-content: space-between; + align-items: center; + flex-wrap: wrap; + gap: 8px; +} +.facility-category-title-wrap { + display: flex; + align-items: center; + gap: 8px; +} +.facility-category-icon { + font-size: 1.25rem; + line-height: 1; +} +.facility-category-title { + margin: 0; + font-size: 1rem; + font-weight: 700; + color: var(--ink, #FFFFFF); +} +.facility-category-badge { + font-size: 0.75rem; + padding: 2px 8px; + background: rgba(255, 255, 255, 0.08); + border-radius: 999px; + color: var(--muted, #8E92B2); + font-weight: 600; +} +.facility-category-actions { + display: flex; + gap: 6px; + align-items: center; +} +.facility-category-actions .btn-xs { + font-size: 0.75rem; + padding: 3px 8px; + min-height: 28px; +} +.facility-category-hint { + font-size: 0.8rem; + color: var(--muted, #8E92B2); + margin: 4px 0 12px; +} +.facilities-category-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); + gap: 8px; +} +@media (max-width: 600px) { + .facilities-category-grid { + grid-template-columns: 1fr 1fr; + gap: 8px; + } +} +@media (max-width: 380px) { + .facilities-category-grid { + grid-template-columns: 1fr; + } +} +.facility-card { + display: flex; + align-items: center; + gap: 10px; + padding: 10px 12px; + background: rgba(255, 255, 255, 0.03); + border: 1px solid var(--border-soft, #2A3158); + border-radius: 8px; + cursor: pointer; + user-select: none; + min-height: 48px; + transition: all 0.15s ease; + position: relative; +} +.facility-card:hover { + background: rgba(255, 255, 255, 0.06); + border-color: var(--neon-cyan, #00D9FF); + transform: translateY(-1px); +} +.facility-card:focus-visible { + outline: 2px solid var(--neon-cyan, #00D9FF); + outline-offset: 2px; +} +.facility-card.is-selected { + background: rgba(0, 217, 255, 0.08); + border-color: var(--neon-cyan, #00D9FF); + box-shadow: 0 0 12px rgba(0, 217, 255, 0.12); +} +.facility-icon { + font-size: 1.15rem; + flex-shrink: 0; + line-height: 1; +} +.facility-name { + font-size: 0.84rem; + font-weight: 500; + color: var(--ink, #FFFFFF); + flex: 1; + line-height: 1.3; +} +.facility-card.is-selected .facility-name { + color: #FFFFFF; + font-weight: 600; +} +.facility-check { + width: 20px; + height: 20px; + border-radius: 4px; + border: 1.5px solid var(--border-soft, #4B5585); + display: flex; + align-items: center; + justify-content: center; + font-size: 0.75rem; + font-weight: 700; + flex-shrink: 0; + color: transparent; + transition: all 0.15s ease; +} +.facility-card.is-selected .facility-check { + background: var(--neon-cyan, #00D9FF); + border-color: var(--neon-cyan, #00D9FF); + color: #090B16; +} +.custom-facility-box { + margin-top: 20px; + padding: 16px; + border: 1px dashed var(--border-soft, #333B6A); + border-radius: 10px; + background: rgba(255, 255, 255, 0.02); +} +.custom-facilities-list { + list-style: none; + padding: 0; + margin: 0; + display: grid; + gap: 8px; +} +.custom-facility-item { + display: flex; + justify-content: space-between; + align-items: center; + padding: 10px 14px; + background: rgba(255, 255, 255, 0.04); + border: 1px solid var(--border-soft, #333B6A); + border-radius: 8px; +} +.custom-facility-meta { + flex: 1; +} + +@keyframes spin { + to { transform: rotate(360deg); } +} + diff --git a/public/css/site.css b/public/css/site.css index c6752d4..dd3d15d 100644 --- a/public/css/site.css +++ b/public/css/site.css @@ -75,8 +75,8 @@ } *, *::before, *::after { box-sizing: border-box; } -html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; } -body { margin: 0; background-color: var(--bg); background-image: var(--bg-gradient); background-repeat: no-repeat; background-attachment: fixed; color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.6; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; min-height: 100vh; } +html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; max-width: 100%; overflow-x: hidden; } +body { margin: 0; background-color: var(--bg); background-image: var(--bg-gradient); background-repeat: no-repeat; background-attachment: fixed; color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.6; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; min-height: 100vh; max-width: 100%; overflow-x: hidden; } img { max-width: 100%; height: auto; display: block; } a { color: inherit; text-decoration-color: rgba(49, 91, 255, .45); text-underline-offset: 3px; } a:hover { color: var(--neon-cyan); } @@ -2264,7 +2264,10 @@ select:focus-visible, input:focus-visible, textarea:focus-visible { @media (max-width: 768px) { body { - padding-bottom: 64px; + padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); + } + .site-footer { + display: none !important; } .mobile-bottom-nav { display: flex; @@ -2272,15 +2275,16 @@ select:focus-visible, input:focus-visible, textarea:focus-visible { bottom: 0; left: 0; right: 0; - height: 60px; + height: calc(60px + env(safe-area-inset-bottom, 0px)); background: rgba(9, 11, 22, 0.96); backdrop-filter: blur(16px); + -webkit-backdrop-filter: blur(16px); border-top: 1px solid rgba(255, 255, 255, 0.1); z-index: 990; justify-content: space-around; align-items: center; box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4); - padding-bottom: env(safe-area-inset-bottom, 0); + padding-bottom: env(safe-area-inset-bottom, 0px); } .bottom-nav-item { display: flex; diff --git a/public/js/organiser.js b/public/js/organiser.js index fa649d6..69af671 100644 --- a/public/js/organiser.js +++ b/public/js/organiser.js @@ -2476,42 +2476,113 @@ nav('basics', 'features', 'Next: Features'); } + var FACILITY_ICONS = { + paid_parking: '๐Ÿ…ฟ๏ธ', free_parking: '๐Ÿ†“', two_wheeler_parking: '๐Ÿ›ต', four_wheeler_parking: '๐Ÿš—', valet_parking: '๐Ÿ”‘', + food_available: '๐Ÿฝ๏ธ', veg_options: '๐Ÿฅ—', non_veg_options: '๐Ÿ—', alcohol_available: '๐Ÿธ', non_alcoholic: '๐Ÿฅค', outside_food_restrictions: '๐Ÿšซ', + wheelchair_accessible: 'โ™ฟ', accessible_entrance: '๐Ÿšช', accessible_washrooms: '๐Ÿšป', companion_assistance: '๐Ÿค', accessible_parking: '๐Ÿ…ฟ๏ธ', + first_aid: '๐Ÿฉน', medical_staff: '๐Ÿฉบ', ambulance: '๐Ÿš‘', security_personnel: '๐Ÿ‘ฎ', emergency_assistance: '๐Ÿšจ', + common_washrooms: '๐Ÿšป', smoking_zones: '๐Ÿšฌ', cloakroom: '๐Ÿงณ', photography_rules: '๐Ÿ“ท', re_entry_policy: '๐Ÿ”„', + age_restrictions: '๐Ÿ”ž', dress_code: '๐Ÿ‘”', pet_policy: '๐Ÿพ' + }; + + var CATEGORY_ORDER = [ + { key: 'parking', name: 'Parking', icon: '๐Ÿš—', hint: 'Vehicle parking & valet options' }, + { key: 'food_beverage', name: 'Food & Beverages', icon: '๐Ÿฝ๏ธ', hint: 'Dining, dietary options & bar rules' }, + { key: 'accessibility', name: 'Accessibility', icon: 'โ™ฟ', hint: 'Step-free access & guest assistance' }, + { key: 'medical_safety', name: 'Medical & Safety', icon: '๐Ÿ›ก๏ธ', hint: 'First aid, on-site personnel & security' }, + { key: 'other', name: 'Other Facilities & Rules', icon: 'โ„น๏ธ', hint: 'Venue facilities, dress code & policies' } + ]; + function facilitiesCardHtml() { var d = S.data; if (!d.facilities) d.facilities = []; var facs = d.facilities; var selectedKeys = {}; - facs.forEach(function (f) { selectedKeys[f.facilityKey || f.key || f.name] = true; }); - - var preList = (CFG.predefinedFacilities || []).map(function (f) { - var isSel = Boolean(selectedKeys[f.key]); - return ''; + var totalSelected = 0; + facs.forEach(function (f) { + var k = f.facilityKey || f.key || f.name; + selectedKeys[k] = true; + totalSelected++; + }); + + var preList = CFG.predefinedFacilities || []; + var byCat = {}; + CATEGORY_ORDER.forEach(function (c) { byCat[c.key] = []; }); + preList.forEach(function (f) { + var catKey = f.category || 'other'; + if (!byCat[catKey]) byCat[catKey] = []; + byCat[catKey].push(f); + }); + + var categoriesHtml = CATEGORY_ORDER.map(function (cat) { + var items = byCat[cat.key] || []; + if (!items.length) return ''; + var selectedInCat = items.filter(function (f) { return Boolean(selectedKeys[f.key]); }).length; + + var itemsHtml = items.map(function (f) { + var isSel = Boolean(selectedKeys[f.key]); + var icon = FACILITY_ICONS[f.key] || 'โœฆ'; + return ''; + }).join(''); + + return '
' + + '
' + + '
' + + '' + + '

' + esc(cat.name) + '

' + + '' + selectedInCat + ' / ' + items.length + ' selected' + + '
' + + '
' + + '' + + '' + + '
' + + '
' + + '

' + esc(cat.hint) + '

' + + '
' + itemsHtml + '
' + + '
'; }).join(''); var customList = facs.filter(function (f) { return f.isCustom; }).map(function (f) { - return '
  • ' + - '
    ' + esc(f.name) + ' (' + esc(f.category) + ')' + (f.description ? '

    ' + esc(f.description) + '

    ' : '') + '
    ' + - '' + + var catInfo = CATEGORY_ORDER.filter(function (c) { return c.key === f.category; })[0]; + var catLabel = catInfo ? catInfo.name : 'Custom'; + return '
  • ' + + '
    ' + + '' + esc(catLabel) + ' ' + + '' + esc(f.name) + '' + + (f.description ? '

    ' + esc(f.description) + '

    ' : '') + + '
    ' + + '' + '
  • '; }).join(''); - var addCustomBox = '
    ' + - '

    + Add Custom Facility or Amenity

    ' + + var addCustomBox = '
    ' + + '

    + Add Custom Facility or Amenity

    ' + '
    ' + - '
    Facility name
    ' + - '
    Category
    ' + + '
    ' + + '
    ' + + '
    ' + + '
    ' + + '' + + '
    '; + + var topBar = '
    ' + + '

    Select amenities available at your event. Grouped by category for quick setup. Only selected amenities appear on your public event page.

    ' + + '
    ' + + '' + totalSelected + ' amenit' + (totalSelected === 1 ? 'y' : 'ies') + ' selected' + + (totalSelected > 0 ? '' : '') + '
    ' + - '
    Additional notes / details (optional)
    ' + - '' + '
    '; return card('Facilities & amenities (Optional)', - '

    Select available amenities for parking, food, accessibility, medical support, and policies. Only selected facilities appear on your public event page.

    ' + - '
    ' + preList + '
    ' + - (customList ? '' : '') + + topBar + + categoriesHtml + + (customList ? '

    Custom Amenities

      ' + customList + '
    ' : '') + addCustomBox + errSlot('facilities')); } @@ -2653,7 +2724,7 @@ function stepPreview() { var errs = S.issues.filter(function (i) { return i.severity === 'error'; }); var warns = S.issues.filter(function (i) { return i.severity === 'warning'; }); - var label = { basics: 'Basics', tickets: 'Tickets', features: 'Features' }; + var label = { basics: 'Basics', tickets: 'Tickets', features: 'Features', facilities: 'Features', offers: 'Features', venue: 'Features', timeline: 'Features' }; var isDirect = S.data.paymentMethod === 'direct_upi' || (S.data.organiserUpiId && S.data.organiserPayeeName); var readyMsg = isDirect ? 'โœ“ Everything needed is in place. Your event with direct UPI payment is ready to publish.' @@ -3052,9 +3123,14 @@ touch(); render(); return api('DELETE', '/api/organiser/drafts/' + encodeURIComponent(S.draft.id) + '/images/' + encodeURIComponent(id)); case 'fix': - S.shown[b.getAttribute('data-step')] = true; - goStep(b.getAttribute('data-step')); - var target = $('[data-path="' + b.getAttribute('data-field') + '"]', el) || $('[data-err-for="' + b.getAttribute('data-field') + '"]', el); + var targetStep = b.getAttribute('data-step'); + if (targetStep === 'facilities' || targetStep === 'offers' || targetStep === 'venue' || targetStep === 'timeline') { + targetStep = 'features'; + } + S.shown[targetStep] = true; + goStep(targetStep); + var targetField = b.getAttribute('data-field'); + var target = $('[data-path="' + targetField + '"]', el) || $('[data-err-for="' + targetField + '"]', el) || $('[name="' + targetField + '"]', el); if (target) { target.scrollIntoView({ block: 'center' }); if (target.focus) target.focus(); } return; case 'conflict-theirs': @@ -3191,6 +3267,34 @@ }); } touch(); return render(); + case 'select-all-cat': + if (!S.data.facilities) S.data.facilities = []; + var selCatKey = b.getAttribute('data-cat'); + var catItems = (CFG.predefinedFacilities || []).filter(function (x) { return x.category === selCatKey; }); + var existingMap = {}; + S.data.facilities.forEach(function (f) { existingMap[f.facilityKey || f.key] = true; }); + catItems.forEach(function (item) { + if (!existingMap[item.key]) { + S.data.facilities.push({ + facilityKey: item.key, + category: item.category, + name: item.name, + icon: item.icon || '', + isCustom: false + }); + } + }); + touch(); return render(); + case 'clear-cat': + if (!S.data.facilities) return; + var clearCatKey = b.getAttribute('data-cat'); + S.data.facilities = S.data.facilities.filter(function (f) { + return f.category !== clearCatKey || f.isCustom; + }); + touch(); return render(); + case 'clear-all-facilities': + S.data.facilities = []; + touch(); return render(); case 'add-custom-facility': if (!S.data.facilities) S.data.facilities = []; var customNameInput = $('#custom-fac-name', el); @@ -3223,14 +3327,32 @@ } }); + el.addEventListener('keydown', function (ev) { + if (ev.key === ' ' || ev.key === 'Enter') { + var card = ev.target.closest('[data-act="toggle-facility"]'); + if (card) { + ev.preventDefault(); + card.click(); + } + } + }); + function publishNow(btn) { if (S.publishing) return; S.publishing = true; - if (btn) { btn.disabled = true; btn.setAttribute('data-orig-text', btn.textContent); btn.textContent = 'Publishing free eventโ€ฆ'; } + var isDirect = S.data.paymentMethod === 'direct_upi' || (S.data.organiserUpiId && S.data.organiserPayeeName); + var origText = btn ? btn.textContent : (isDirect ? 'Publish Event Now' : 'Publish Free Event Now'); + var loadingText = isDirect ? 'Publishing eventโ€ฆ' : 'Publishing free eventโ€ฆ'; + if (btn) { + btn.disabled = true; + btn.setAttribute('data-orig-text', origText); + btn.innerHTML = '' + esc(loadingText); + } var msg = $('[data-publish-msg]', el); + if (msg) { msg.textContent = ''; msg.style.display = 'none'; } api('POST', '/api/organiser/drafts/' + encodeURIComponent(S.draft.id) + '/publish', { version: S.version, confirm: true }).then(function (r) { S.publishing = false; - if (btn) { btn.disabled = false; btn.textContent = btn.getAttribute('data-orig-text') || 'Publish Free Event Now'; } + if (btn) { btn.disabled = false; btn.textContent = btn.getAttribute('data-orig-text') || origText; } if (r.ok) { store(localKey(), null); S.dirty = false; S.published = r; setStatus('published'); @@ -3239,13 +3361,31 @@ render('[data-focus]'); window.scrollTo(0, 0); return; } - if (r.status === 422 && r.issues) { S.issues = r.issues; var dl = $('[data-publish-dialog]', el); if (dl) dl.close(); render(); return; } - if (r.error === 'version_conflict') { S.conflict = r.draft; var d2 = $('[data-publish-dialog]', el); if (d2) d2.close(); render(); return; } - if (msg) msg.textContent = r.message || 'Could not publish. Please try again.'; - }).catch(function () { + if (r.status === 422 && r.issues) { + S.issues = r.issues; + var dl = $('[data-publish-dialog]', el); + if (dl) dl.close(); + render(); + return; + } + if (r.error === 'version_conflict') { + S.conflict = r.draft; + var d2 = $('[data-publish-dialog]', el); + if (d2) d2.close(); + render(); + return; + } + if (msg) { + msg.textContent = r.message || 'Could not publish event. Please review all details and try again.'; + msg.style.display = 'block'; + } + }).catch(function (err) { S.publishing = false; - if (btn) { btn.disabled = false; btn.textContent = btn.getAttribute('data-orig-text') || 'Publish Free Event Now'; } - if (msg) msg.textContent = 'A network error occurred. Please try again.'; + if (btn) { btn.disabled = false; btn.textContent = btn.getAttribute('data-orig-text') || origText; } + if (msg) { + msg.textContent = (err && err.message) || 'A network error occurred. Please try again.'; + msg.style.display = 'block'; + } }); }