diff --git a/.claude/rules/features/ticket-transfer-resale.md b/.claude/rules/features/ticket-transfer-resale.md index a02c529854..18d742391a 100644 --- a/.claude/rules/features/ticket-transfer-resale.md +++ b/.claude/rules/features/ticket-transfer-resale.md @@ -58,7 +58,7 @@ paths: - Buyer resale lives on the order page only: `useTicketResaleActions(orderLink, timezone)` verifies first, then opens `SellTicketModal` with the estimate. A listed ticket shows `TicketResaleListed` and none of the ticket link, print, transfer or edit actions. The ticket page never offers sell or withdraw, because the link may belong to a guest. - `AttendeeTicket` replaces the QR code when `resale.status` is `LISTED` or `SOLD`, which covers the ticket page and both print views. Never render the QR code for a listed ticket anywhere else. - E2E: `e2e/utils/resale.ts` (`markOrderPaidThroughStripe`) turns an offline-paid order into one paid through Stripe, which is all a listing needs; no real Stripe. -- Organizer oversight is `/manage/event/:id/resale` (`routes/event/Resale`); the failed-refund email links to that exact path. The status filter is server-side (`filter_fields[status]`); "Needs attention" is a client-side filter over the Sold page because the API cannot filter it. The Refund column shows only when the payload carries the money fields, "Close listing" needs `EDIT` and "Retry refund" needs `ISSUE_REFUNDS` as well. The organizer attendee payload's `resale` is `{status, sold_order_id, sold_order_public_id}`: a resold attendee shows "Resold" with the replacement order and no Activate action. +- Organizer oversight is `/manage/event/:id/resale` (`routes/event/Resale`); the failed-refund email links to that exact path. Its settings bar (`ResaleSettings`) saves `allow_ticket_resale` and `ticket_resale_cutoff_minutes` straight away through the same partial update as checkout settings: the switch always asks first (turning on shows `ticketResaleDescription()`, which carries the chargeback sentence), needs `ISSUE_REFUNDS`, and members without `EDIT` see no controls. The status filter is server-side (`filter_fields[status]`); "Needs attention" is a client-side filter over the Sold page because the API cannot filter it. The Refund column shows only when the payload carries the money fields, "Close listing" needs `EDIT` and "Retry refund" needs `ISSUE_REFUNDS` as well. The organizer attendee payload's `resale` is `{status, sold_order_id, sold_order_public_id}`: a resold attendee shows "Resold" with the replacement order and no Activate action. - E2E for organizer pages: `e2e/utils/resale-listings.ts` (`seedResaleListing`) inserts listings in any stored state. A retried refund stays `PENDING` when the replacement order has no platform-fee row, so settle it (`settleResaleRefund`) when the test ends. ## Resale diff --git a/e2e/pages/resale.page.ts b/e2e/pages/resale.page.ts index c6c4833e3e..55b404f2a1 100644 --- a/e2e/pages/resale.page.ts +++ b/e2e/pages/resale.page.ts @@ -32,6 +32,23 @@ export class ResalePage { return this.page.getByTestId('resale-attention-summary'); } + enabledSwitch(): Locator { + return this.page.getByTestId('resale-enabled-switch'); + } + + cutoffSelect(): Locator { + return this.page.getByTestId('resale-cutoff-select'); + } + + async toggleResale(): Promise { + await this.enabledSwitch().click({ force: true }); + } + + async chooseCutoff(label: string): Promise { + await this.cutoffSelect().click(); + await this.page.getByRole('option', { name: label }).click(); + } + async filterBy(status: 'All' | 'Open' | 'Sold' | 'Closed'): Promise { await this.page.getByRole('radiogroup', { name: 'Filter by status' }).getByText(status, { exact: true }).click(); } diff --git a/e2e/tests/management/resale-settings.spec.ts b/e2e/tests/management/resale-settings.spec.ts index 5eb1faf27d..8abdcb47a3 100644 --- a/e2e/tests/management/resale-settings.spec.ts +++ b/e2e/tests/management/resale-settings.spec.ts @@ -1,6 +1,7 @@ import { test, expect } from '../../fixtures'; import { EventSettingsPage } from '../../pages/event-settings.page'; import { ProductEditPage } from '../../pages/product-edit.page'; +import { ResalePage } from '../../pages/resale.page'; import { WebhookPage } from '../../pages/webhook.page'; import { createFreshOrganizer, createLiveEventWithFreeTicket } from '../../api/factory'; @@ -25,6 +26,30 @@ test.describe('organizer controls for ticket resale', () => { expect((await api.getEventSettings(event.eventId)).ticket_resale_cutoff_minutes).toBe(1440); }); + test('an organizer turns resale on, moves the cutoff and turns it off again from the resale page', async ({ authedPage, api, account }) => { + const event = await createLiveEventWithFreeTicket(api, account.organizerId); + + const resale = new ResalePage(authedPage); + await resale.goto(event.eventId); + await expect(resale.enabledSwitch()).not.toBeChecked(); + await expect(resale.cutoffSelect()).toBeDisabled(); + + await resale.toggleResale(); + const turnOn = authedPage.getByRole('dialog', { name: 'Turn on ticket resale?' }); + await expect(turnOn.getByText('that chargeback is at your risk, as with any sale.')).toBeVisible(); + await turnOn.getByRole('button', { name: 'Turn on resale' }).click(); + await expect(resale.enabledSwitch()).toBeChecked(); + await expect.poll(async () => (await api.getEventSettings(event.eventId)).allow_ticket_resale).toBe(true); + + await resale.chooseCutoff('1 day before'); + await expect.poll(async () => (await api.getEventSettings(event.eventId)).ticket_resale_cutoff_minutes).toBe(1440); + + await resale.toggleResale(); + await authedPage.getByRole('dialog', { name: 'Turn off ticket resale?' }).getByRole('button', { name: 'Turn off resale' }).click(); + await expect(resale.enabledSwitch()).not.toBeChecked(); + await expect.poll(async () => (await api.getEventSettings(event.eventId)).allow_ticket_resale).toBe(false); + }); + test('the organizer default decides whether a new event allows resale', async ({ authedPage, api }) => { const organizer = await createFreshOrganizer(api); diff --git a/frontend/public/blank-slate/audience-campaigns.svg b/frontend/public/blank-slate/audience-campaigns.svg new file mode 100644 index 0000000000..bcac6e82cc --- /dev/null +++ b/frontend/public/blank-slate/audience-campaigns.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/frontend/public/blank-slate/audience-contacts.svg b/frontend/public/blank-slate/audience-contacts.svg new file mode 100644 index 0000000000..f10bc80485 --- /dev/null +++ b/frontend/public/blank-slate/audience-contacts.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/frontend/public/blank-slate/audience-overview.svg b/frontend/public/blank-slate/audience-overview.svg new file mode 100644 index 0000000000..28d206c7eb --- /dev/null +++ b/frontend/public/blank-slate/audience-overview.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/frontend/public/blank-slate/audience-segments.svg b/frontend/public/blank-slate/audience-segments.svg new file mode 100644 index 0000000000..744ad1bb05 --- /dev/null +++ b/frontend/public/blank-slate/audience-segments.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/frontend/public/blank-slate/audience-signup-forms.svg b/frontend/public/blank-slate/audience-signup-forms.svg new file mode 100644 index 0000000000..51d16b00a7 --- /dev/null +++ b/frontend/public/blank-slate/audience-signup-forms.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/frontend/src/components/routes/event/Resale/Resale.module.scss b/frontend/src/components/routes/event/Resale/Resale.module.scss index cc071e8998..3c6c610b2a 100644 --- a/frontend/src/components/routes/event/Resale/Resale.module.scss +++ b/frontend/src/components/routes/event/Resale/Resale.module.scss @@ -1,3 +1,5 @@ +@use "../../../../styles/mixins"; + .notice { display: flex; align-items: flex-start; @@ -12,10 +14,72 @@ margin-top: 2px; color: var(--mantine-color-gray-6); } +} + +.settings { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 12px 24px; + margin-bottom: 16px; + padding: 12px 16px; + border: 1px solid var(--mantine-color-gray-3); + border-radius: var(--hi-radius-lg); + background: var(--mantine-color-body); + + :global(.mantine-Switch-root), + :global(.mantine-InputWrapper-root) { + margin-bottom: 0; + } +} + +.settingsToggle { + flex: 1 1 260px; + min-width: 0; +} + +.settingsCutoff { + display: flex; + flex: 0 1 auto; + align-items: center; + gap: 10px; + min-width: 0; +} + +.settingsCutoffLabel { + flex-shrink: 0; + font-size: var(--mantine-font-size-sm); + font-weight: 500; + color: var(--mantine-color-gray-7); +} + +.settingsCutoffSelect { + width: 210px; + min-width: 0; +} + +@include mixins.respond-below(sm) { + .settingsCutoff { + flex: 1 1 100%; + } + + .settingsCutoffSelect { + flex: 1; + width: auto; + } +} + +.settingsHelp { + display: inline-flex; + flex-shrink: 0; + align-items: center; + gap: 6px; + font-size: var(--mantine-font-size-sm); + font-weight: 500; + color: var(--mantine-color-gray-7); - a { - font-weight: 500; - color: var(--mantine-color-primary-7); + &:hover { + color: var(--mantine-color-gray-9); } } diff --git a/frontend/src/components/routes/event/Resale/ResaleSettings.tsx b/frontend/src/components/routes/event/Resale/ResaleSettings.tsx new file mode 100644 index 0000000000..890221456c --- /dev/null +++ b/frontend/src/components/routes/event/Resale/ResaleSettings.tsx @@ -0,0 +1,97 @@ +import {t} from "@lingui/macro"; +import {Popover, Select, Switch, Text, UnstyledButton} from "@mantine/core"; +import {IconInfoCircle} from "@tabler/icons-react"; +import {useAccess} from "../../../../hooks/useAccess.ts"; +import {useUpdateEventSettings} from "../../../../mutations/useUpdateEventSettings.ts"; +import {EventSettings, IdParam} from "../../../../types.ts"; +import {confirmationDialog} from "../../../../utilites/confirmationDialog.tsx"; +import {cutoffOptions} from "../../../../utilites/cutoffOptions.ts"; +import {showError, showSuccess} from "../../../../utilites/notifications.tsx"; +import {resaleToggleRefusedMessage, ticketResaleDescription} from "../../../../utilites/ticketResaleCopy.ts"; +import classes from "./Resale.module.scss"; + +const DEFAULT_CUTOFF_MINUTES = 120; + +interface ResaleSettingsProps { + eventId: IdParam; + eventSettings: EventSettings; +} + +export const ResaleSettings = ({eventId, eventSettings}: ResaleSettingsProps) => { + const canTurnResaleOnOrOff = useAccess().can('ISSUE_REFUNDS'); + const updateMutation = useUpdateEventSettings(); + const isOn = !!eventSettings.allow_ticket_resale; + const cutoffMinutes = eventSettings.ticket_resale_cutoff_minutes ?? DEFAULT_CUTOFF_MINUTES; + + const save = (changes: Partial, savedMessage: string) => { + updateMutation.mutate({eventId, eventSettings: changes}, { + onSuccess: () => showSuccess(savedMessage), + onError: (error: any) => showError(error?.response?.data?.message || t`Something went wrong. Please try again.`), + }); + }; + + const confirmToggle = () => { + if (isOn) { + confirmationDialog( + t`Turn off ticket resale?`, + () => save({allow_ticket_resale: false}, t`Ticket resale is off for this event.`), + { + confirm: t`Turn off resale`, + description: t`Listed tickets come off sale and go back to their buyers to use, unless someone is already paying for one. Tickets that have already been resold are not affected.`, + }, + ); + return; + } + + confirmationDialog( + t`Turn on ticket resale?`, + () => save({allow_ticket_resale: true}, t`Ticket resale is on for this event.`), + { + confirm: t`Turn on resale`, + description: ticketResaleDescription(), + }, + ); + }; + + return ( +
+ + +
+ +