@composable-os/pack-ticketing 0.0.0-stage → 0.1.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +109 -0
- package/dist/automations.d.ts +72 -0
- package/dist/automations.js +347 -0
- package/dist/blocks/ticketing-checkout/ticket-picker.d.ts +25 -0
- package/dist/blocks/ticketing-checkout/ticket-picker.js +77 -0
- package/dist/blocks/ticketing-events/event-list.d.ts +15 -0
- package/dist/blocks/ticketing-events/event-list.js +26 -0
- package/dist/blocks/ticketing-my-tickets/my-tickets.d.ts +9 -0
- package/dist/blocks/ticketing-my-tickets/my-tickets.js +13 -0
- package/dist/blocks/ticketing-native-my-tickets/my-tickets-screen.d.ts +10 -0
- package/dist/blocks/ticketing-native-my-tickets/my-tickets-screen.js +17 -0
- package/dist/blocks/ticketing-native-scanner/door-scanner-screen.d.ts +18 -0
- package/dist/blocks/ticketing-native-scanner/door-scanner-screen.js +42 -0
- package/dist/blocks/ticketing-native-ticket/ticket-screen.d.ts +21 -0
- package/dist/blocks/ticketing-native-ticket/ticket-screen.js +48 -0
- package/dist/blocks/ticketing-order/order-confirmation.d.ts +12 -0
- package/dist/blocks/ticketing-order/order-confirmation.js +11 -0
- package/dist/client/index.d.ts +799 -0
- package/dist/client/index.js +288 -0
- package/dist/dashboards.d.ts +5 -0
- package/dist/dashboards.js +91 -0
- package/dist/index.d.ts +624 -0
- package/dist/index.js +314 -0
- package/dist/tools.d.ts +184 -0
- package/dist/tools.js +591 -0
- package/package.json +31 -4
- package/README.md +0 -3
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { availabilityLabel, eventTime, formatPrice } from "@composable-os/pack-ticketing/client";
|
|
3
|
+
import { Button } from "../ui-button/button.js";
|
|
4
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../ui-card/card.js";
|
|
5
|
+
// An event's times are shown in its own zone, with the zone said when it is not the viewer's.
|
|
6
|
+
const when = (event, at = "startsAt") => eventTime(event, { at }) || null;
|
|
7
|
+
/** Every event on sale, soonest first, each with a button to open it. */
|
|
8
|
+
export function EventList({ ticketing, onOpen, }) {
|
|
9
|
+
const { data, isPending, error } = ticketing.useEventsOnSale();
|
|
10
|
+
if (isPending)
|
|
11
|
+
return _jsx("p", { "aria-busy": "true", children: "Loading events\u2026" });
|
|
12
|
+
if (error)
|
|
13
|
+
return _jsx("p", { role: "alert", children: "We could not load the events. Try again in a moment." });
|
|
14
|
+
if (!data?.events.length)
|
|
15
|
+
return _jsx("p", { children: "Nothing is on sale right now." });
|
|
16
|
+
return (_jsx("ul", { className: "grid gap-4", children: data.events.map((event) => (_jsx("li", { children: _jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: event.name }), _jsx(CardDescription, { children: [when(event), event.venue].filter(Boolean).join(" · ") })] }), _jsxs(CardContent, { children: [availabilityLabel(event.availability) ? (_jsx("p", { children: availabilityLabel(event.availability) })) : null, _jsx(Button, { onClick: () => onOpen(event), children: "Tickets" })] })] }) }, event.id))) }));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* One event's details and its ticket types, with room for the picker below. Prices show in the
|
|
20
|
+
* currency the host gives with them.
|
|
21
|
+
*/
|
|
22
|
+
export function EventSection({ event, children }) {
|
|
23
|
+
return (_jsxs("section", { "aria-labelledby": `event-${event.id}`, className: "grid gap-4", children: [event.image ? _jsx("img", { src: event.image, alt: "", className: "w-full rounded-lg" }) : null, _jsx("h2", { id: `event-${event.id}`, className: "text-2xl font-semibold", children: event.name }), _jsx("p", { className: "text-muted-foreground", children: [when(event), when(event, "endsAt"), event.venue].filter(Boolean).join(" · ") }), event.description ? _jsx("p", { className: "whitespace-pre-line", children: event.description }) : null, _jsx("ul", { className: "grid gap-2", children: event.ticketTypes.map((type) => (_jsxs("li", { className: "flex justify-between gap-4", children: [_jsx("span", { children: type.name }), _jsxs("span", { children: [formatPrice(type.price, type.currency), availabilityLabel(type.availability)
|
|
24
|
+
? ` · ${availabilityLabel(type.availability)}`
|
|
25
|
+
: ""] })] }, type.id))) }), children] }));
|
|
26
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TicketingHooks } from "@composable-os/pack-ticketing/client";
|
|
2
|
+
export declare function MyTickets({ ticketing, onShow, }: {
|
|
3
|
+
ticketing: Pick<TicketingHooks, "useMyTickets">;
|
|
4
|
+
/** Opens one ticket with its code (a QR the app draws). */
|
|
5
|
+
onShow?: (ticket: {
|
|
6
|
+
id: string;
|
|
7
|
+
code: string | null;
|
|
8
|
+
}) => void;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { eventTime } from "@composable-os/pack-ticketing/client";
|
|
3
|
+
const STATE = { valid: "Valid", used: "Used", void: "Cancelled" };
|
|
4
|
+
export function MyTickets({ ticketing, onShow, }) {
|
|
5
|
+
const { data, isPending, error } = ticketing.useMyTickets();
|
|
6
|
+
if (isPending)
|
|
7
|
+
return _jsx("p", { "aria-busy": "true", children: "Loading your tickets\u2026" });
|
|
8
|
+
if (error)
|
|
9
|
+
return _jsx("p", { role: "alert", children: "We could not load your tickets." });
|
|
10
|
+
if (!data?.items.length)
|
|
11
|
+
return _jsx("p", { children: "You have no tickets yet." });
|
|
12
|
+
return (_jsx("ul", { className: "grid gap-2", children: data.items.map((ticket) => (_jsxs("li", { className: "flex justify-between gap-4", children: [_jsxs("span", { children: [ticket.eventName ?? "Ticket", ticket.ticketTypeName ? ` · ${ticket.ticketTypeName}` : "", ticket.startsAt ? ` · ${eventTime(ticket)}` : ""] }), _jsx("span", { children: STATE[ticket.state] ?? ticket.state }), onShow && ticket.state === "valid" ? (_jsx("button", { type: "button", onClick: () => onShow({ id: ticket.id, code: ticket.code }), children: "Show code" })) : null] }, ticket.id))) }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TicketingHooks } from "@composable-os/pack-ticketing/client";
|
|
2
|
+
export declare function MyTicketsScreen({ ticketing, onOpen, }: {
|
|
3
|
+
ticketing: Pick<TicketingHooks, "useMyTickets">;
|
|
4
|
+
/** Pushes the ticket's screen (TicketScreen) on the app's native stack. */
|
|
5
|
+
onOpen: (ticket: {
|
|
6
|
+
id: string;
|
|
7
|
+
code: string | null;
|
|
8
|
+
event: string | null;
|
|
9
|
+
}) => void;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { eventTime } from "@composable-os/pack-ticketing/client";
|
|
3
|
+
import { Text } from "react-native";
|
|
4
|
+
import { List } from "../native-base/list.js";
|
|
5
|
+
import { Row } from "../native-base/row.js";
|
|
6
|
+
import { Screen } from "../native-base/screen.js";
|
|
7
|
+
const STATE = { valid: "Valid", used: "Used", void: "Cancelled" };
|
|
8
|
+
export function MyTicketsScreen({ ticketing, onOpen, }) {
|
|
9
|
+
const { data, isPending, error } = ticketing.useMyTickets();
|
|
10
|
+
return (_jsxs(Screen, { title: "Tickets", children: [isPending ? _jsx(Text, { accessibilityRole: "progressbar", children: "Loading your tickets\u2026" }) : null, error ? _jsx(Text, { accessibilityRole: "alert", children: "We could not load your tickets." }) : null, data ? (_jsx(List, { empty: "You have no tickets yet.", children: data.items.map((ticket) => (_jsx(Row, { title: ticket.eventName ?? "Ticket", detail: [
|
|
11
|
+
ticket.ticketTypeName,
|
|
12
|
+
ticket.startsAt ? eventTime(ticket) : null,
|
|
13
|
+
STATE[ticket.state] ?? ticket.state,
|
|
14
|
+
]
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
.join(" · "), onPress: ticket.state === "valid" ? () => onOpen(ticket) : undefined }, ticket.id))) })) : null] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TicketingHooks } from "@composable-os/pack-ticketing/client";
|
|
2
|
+
import { type ComponentType } from "react";
|
|
3
|
+
/** A camera view that calls `onCode` with each code it reads, and stops reading while paused. */
|
|
4
|
+
export type CodeScanner = ComponentType<{
|
|
5
|
+
onCode: (code: string) => void;
|
|
6
|
+
paused: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
/** The device's haptics. */
|
|
9
|
+
export interface Haptics {
|
|
10
|
+
success(): void;
|
|
11
|
+
error(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function DoorScannerScreen({ ticketing, Scanner, haptics, title, }: {
|
|
14
|
+
ticketing: Pick<TicketingHooks, "useCheckIn">;
|
|
15
|
+
Scanner: CodeScanner;
|
|
16
|
+
haptics?: Haptics;
|
|
17
|
+
title?: string;
|
|
18
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { formatMoney } from "@composable-os/pack-ticketing/client";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
5
|
+
import { Button } from "../native-base/button.js";
|
|
6
|
+
import { Screen } from "../native-base/screen.js";
|
|
7
|
+
import { theme } from "../native-base/theme.js";
|
|
8
|
+
export function DoorScannerScreen({ ticketing, Scanner, haptics, title = "Door", }) {
|
|
9
|
+
const checkIn = ticketing.useCheckIn();
|
|
10
|
+
const [result, setResult] = useState(null);
|
|
11
|
+
const [letIn, setLetIn] = useState(0);
|
|
12
|
+
const [failed, setFailed] = useState(false);
|
|
13
|
+
async function scanned(code) {
|
|
14
|
+
if (checkIn.isPending || result)
|
|
15
|
+
return;
|
|
16
|
+
setFailed(false);
|
|
17
|
+
try {
|
|
18
|
+
const answer = await checkIn.mutateAsync({ code });
|
|
19
|
+
setResult(answer);
|
|
20
|
+
if (answer.accepted) {
|
|
21
|
+
setLetIn((n) => n + 1);
|
|
22
|
+
haptics?.success();
|
|
23
|
+
}
|
|
24
|
+
else
|
|
25
|
+
haptics?.error();
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
setFailed(true);
|
|
29
|
+
haptics?.error();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const owing = result?.balanceOwing;
|
|
33
|
+
return (_jsxs(Screen, { title: title, children: [_jsxs(Text, { style: styles.count, children: ["Let in on this device: ", letIn] }), _jsx(Scanner, { onCode: scanned, paused: Boolean(result) || checkIn.isPending }), result ? (_jsxs(View, { accessibilityRole: "alert", style: [styles.result, result.accepted ? styles.accepted : styles.refused], children: [_jsx(Text, { style: styles.verdict, children: result.accepted ? "Let in" : "Not valid" }), _jsx(Text, { style: styles.message, children: result.message }), owing ? (_jsxs(Text, { style: styles.message, children: ["Owing: ", formatMoney(owing.amount, owing.currency)] })) : null, _jsx(Button, { label: "Scan the next", onPress: () => setResult(null) })] })) : null, failed ? (_jsx(Text, { accessibilityRole: "alert", style: styles.message, children: "The check could not be made. Check the connection and scan again." })) : null] }));
|
|
34
|
+
}
|
|
35
|
+
const styles = StyleSheet.create({
|
|
36
|
+
count: { fontSize: theme.font.small, color: theme.color.muted, marginBottom: theme.space.sm },
|
|
37
|
+
result: { borderRadius: theme.radius, padding: theme.space.lg, marginTop: theme.space.md },
|
|
38
|
+
accepted: { backgroundColor: "#dcfce7" },
|
|
39
|
+
refused: { backgroundColor: "#fee2e2" },
|
|
40
|
+
verdict: { fontSize: theme.font.title, fontWeight: "700", color: theme.color.text },
|
|
41
|
+
message: { fontSize: theme.font.body, color: theme.color.text, marginVertical: theme.space.sm },
|
|
42
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ComponentType } from "react";
|
|
2
|
+
/** Draws a QR code of `value`. */
|
|
3
|
+
export type QrCode = ComponentType<{
|
|
4
|
+
value: string;
|
|
5
|
+
size: number;
|
|
6
|
+
}>;
|
|
7
|
+
/** The screen's brightness, from 0 to 1. */
|
|
8
|
+
export interface Brightness {
|
|
9
|
+
get(): Promise<number>;
|
|
10
|
+
set(level: number): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare function TicketScreen({ ticket, title, detail, Qr, brightness, }: {
|
|
13
|
+
ticket: {
|
|
14
|
+
code: string | null;
|
|
15
|
+
state: string | null;
|
|
16
|
+
};
|
|
17
|
+
title: string;
|
|
18
|
+
detail?: string | null;
|
|
19
|
+
Qr: QrCode;
|
|
20
|
+
brightness?: Brightness;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// One ticket with its code, for the mobile app (stage 27): a QR carrying the code alone, large on
|
|
3
|
+
// a white card, with the screen at full brightness while it is shown and as it was afterwards.
|
|
4
|
+
// The app gives the QR drawing and the brightness control it uses (for example
|
|
5
|
+
// `react-native-qrcode-svg` and `expo-brightness`), so this block needs neither package.
|
|
6
|
+
import { useEffect } from "react";
|
|
7
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
8
|
+
import { Screen } from "../native-base/screen.js";
|
|
9
|
+
import { theme } from "../native-base/theme.js";
|
|
10
|
+
export function TicketScreen({ ticket, title, detail, Qr, brightness, }) {
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!brightness)
|
|
13
|
+
return;
|
|
14
|
+
let before = null;
|
|
15
|
+
let left = false;
|
|
16
|
+
brightness
|
|
17
|
+
.get()
|
|
18
|
+
.then((level) => {
|
|
19
|
+
before = level;
|
|
20
|
+
return left ? undefined : brightness.set(1);
|
|
21
|
+
})
|
|
22
|
+
.catch(() => undefined);
|
|
23
|
+
return () => {
|
|
24
|
+
left = true;
|
|
25
|
+
if (before !== null)
|
|
26
|
+
brightness.set(before).catch(() => undefined);
|
|
27
|
+
};
|
|
28
|
+
}, [brightness]);
|
|
29
|
+
const usable = ticket.state === "valid" && ticket.code;
|
|
30
|
+
return (_jsxs(Screen, { title: title, children: [detail ? _jsx(Text, { style: styles.detail, children: detail }) : null, _jsx(View, { style: styles.card, accessible: true, accessibilityLabel: "Ticket code", children: usable ? (_jsx(Qr, { value: ticket.code, size: 240 })) : (_jsx(Text, { style: styles.detail, children: ticket.state === "used" ? "This ticket has been used." : "This ticket is not valid." })) }), ticket.code ? (_jsx(Text, { selectable: true, style: styles.code, children: ticket.code })) : null] }));
|
|
31
|
+
}
|
|
32
|
+
const styles = StyleSheet.create({
|
|
33
|
+
card: {
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
justifyContent: "center",
|
|
36
|
+
backgroundColor: "#ffffff",
|
|
37
|
+
borderRadius: theme.radius,
|
|
38
|
+
padding: theme.space.lg,
|
|
39
|
+
marginVertical: theme.space.md,
|
|
40
|
+
},
|
|
41
|
+
code: {
|
|
42
|
+
textAlign: "center",
|
|
43
|
+
fontSize: theme.font.small,
|
|
44
|
+
color: theme.color.muted,
|
|
45
|
+
letterSpacing: 1,
|
|
46
|
+
},
|
|
47
|
+
detail: { fontSize: theme.font.body, color: theme.color.muted },
|
|
48
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TicketingHooks } from "@composable-os/pack-ticketing/client";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
export declare function OrderConfirmation({ ticketing, order, children, }: {
|
|
4
|
+
ticketing: Pick<TicketingHooks, "useOrder">;
|
|
5
|
+
/** The order, and a guest's token (from the link, or kept when the order started). */
|
|
6
|
+
order: {
|
|
7
|
+
id: string;
|
|
8
|
+
token?: string | null;
|
|
9
|
+
};
|
|
10
|
+
/** Shown below, for a part-paid order: the block's BalancePayment, for one. */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { formatMoney, orderStatus } from "@composable-os/pack-ticketing/client";
|
|
3
|
+
export function OrderConfirmation({ ticketing, order, children, }) {
|
|
4
|
+
const { data, isPending, error } = ticketing.useOrder(order);
|
|
5
|
+
if (isPending)
|
|
6
|
+
return _jsx("p", { "aria-busy": "true", children: "Checking your order\u2026" });
|
|
7
|
+
if (error || !data)
|
|
8
|
+
return _jsx("p", { role: "alert", children: "We could not find this order." });
|
|
9
|
+
const status = orderStatus(data);
|
|
10
|
+
return (_jsxs("section", { className: "grid gap-3", "aria-live": "polite", children: [_jsx("h2", { className: "text-xl font-semibold", children: status.title }), status.waiting ? (_jsx("p", { "aria-busy": "true", children: "This usually takes a few seconds. You can leave this page open." })) : null, _jsx("ul", { className: "grid gap-1", children: data.lines.map((line) => (_jsxs("li", { className: "flex justify-between gap-4", children: [_jsxs("span", { children: [line.quantity, " \u00D7 ", line.title] }), _jsx("span", { children: formatMoney(line.total, data.currency) })] }, line.id))) }), _jsxs("p", { children: ["Total ", formatMoney(data.total, data.currency), " \u00B7 paid", " ", formatMoney(data.paid, data.currency)] }), status.kind === "part_paid" ? children : null] }));
|
|
11
|
+
}
|