From 80575ff2b941c65ba13f4e91b2a7d54be30adb2a Mon Sep 17 00:00:00 2001 From: Dev Singh Date: Sat, 19 Apr 2025 17:06:56 +0000 Subject: [PATCH] add button to copy emails from view ticketing page --- src/ui/pages/tickets/ViewTickets.page.tsx | 62 ++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/ui/pages/tickets/ViewTickets.page.tsx b/src/ui/pages/tickets/ViewTickets.page.tsx index 5adeaa90..02e0a093 100644 --- a/src/ui/pages/tickets/ViewTickets.page.tsx +++ b/src/ui/pages/tickets/ViewTickets.page.tsx @@ -45,6 +45,12 @@ const getTicketStatus = ( return { status: 'unfulfilled', color: 'orange' }; }; +enum TicketsCopyMode { + ALL, + FULFILLED, + UNFULFILLED, +} + const ViewTicketsPage: React.FC = () => { const { eventId } = useParams(); const [allTickets, setAllTickets] = useState([]); @@ -57,6 +63,38 @@ const ViewTicketsPage: React.FC = () => { const [pageSize, setPageSize] = useState('10'); const pageSizeOptions = ['10', '25', '50', '100']; + const copyEmails = (mode: TicketsCopyMode) => { + try { + let emailsToCopy: string[] = []; + let copyModeHumanString = ''; + switch (mode) { + case TicketsCopyMode.ALL: + emailsToCopy = allTickets.map((x) => x.purchaserData.email); + copyModeHumanString = 'All'; + break; + case TicketsCopyMode.FULFILLED: + emailsToCopy = allTickets.filter((x) => x.fulfilled).map((x) => x.purchaserData.email); + copyModeHumanString = 'Fulfilled'; + break; + case TicketsCopyMode.UNFULFILLED: + emailsToCopy = allTickets.filter((x) => !x.fulfilled).map((x) => x.purchaserData.email); + copyModeHumanString = 'Unfulfilled'; + break; + } + emailsToCopy = [...new Set(emailsToCopy)]; + navigator.clipboard.writeText(emailsToCopy.join(';')); + notifications.show({ + message: `${copyModeHumanString} emails copied!`, + }); + } catch (e) { + notifications.show({ + title: 'Failed to copy emails', + message: 'Please try again or contact support.', + color: 'red', + }); + } + }; + async function checkInUser(ticket: TicketEntry) { try { const response = await api.post(`/api/v1/tickets/checkIn`, { @@ -119,8 +157,30 @@ const ViewTicketsPage: React.FC = () => { return ( View Tickets/Merch Sales + + + + +
-
{pluralize('item', totalQuantitySold, true)} sold