@frigear-nu/events 0.5.5 → 0.6.0
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/dist/module.d.mts +59 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +33 -4
- package/dist/runtime/app/dashboard/MyNextTicket.d.vue.ts +3 -0
- package/dist/runtime/app/dashboard/MyNextTicket.vue +110 -0
- package/dist/runtime/app/dashboard/MyNextTicket.vue.d.ts +3 -0
- package/dist/runtime/app/grants/EventGrantField.d.vue.ts +15 -0
- package/dist/runtime/app/grants/EventGrantField.vue +87 -0
- package/dist/runtime/app/grants/EventGrantField.vue.d.ts +15 -0
- package/dist/runtime/app/pages/admin.vue +2 -0
- package/dist/runtime/app/tabs/Attendees.vue +33 -12
- package/dist/runtime/app/tabs/Details.vue +2 -1
- package/dist/runtime/app/widgets/UpcomingEvents.vue +22 -13
- package/dist/runtime/app/widgets/UpcomingEventsStat.vue +7 -2
- package/dist/runtime/campaigns-owner.d.ts +38 -0
- package/dist/runtime/campaigns-owner.js +123 -0
- package/dist/runtime/dashboard.d.ts +6 -0
- package/dist/runtime/dashboard.js +19 -0
- package/dist/runtime/i18n/lang/da.json +32 -1
- package/dist/runtime/i18n/lang/en.json +32 -1
- package/dist/runtime/server/grants/event.d.ts +3 -0
- package/dist/runtime/server/grants/event.js +38 -0
- package/dist/runtime/server/plugins/campaigns-owner.d.ts +2 -0
- package/dist/runtime/server/plugins/campaigns-owner.js +39 -0
- package/dist/runtime/server/plugins/payment-hooks.js +2 -2
- package/dist/runtime/server/routes/admin/attendees.get.js +5 -2
- package/dist/runtime/server/routes/admin/check-in.post.js +1 -0
- package/dist/runtime/server/routes/admin/event.delete.js +1 -0
- package/dist/runtime/server/utils/admin.d.ts +8 -2
- package/dist/runtime/server/utils/admin.js +20 -0
- package/dist/runtime/server/utils/tickets.js +1 -1
- package/dist/runtime/utils/grants.d.ts +18 -0
- package/dist/runtime/utils/grants.js +17 -0
- package/dist/types.d.mts +1 -1
- package/package.json +17 -7
package/dist/module.d.mts
CHANGED
|
@@ -35,10 +35,17 @@ type ModuleOptions = {
|
|
|
35
35
|
};
|
|
36
36
|
/** Minutes an unpaid ticket keeps its seat (the Stripe session expires then). Defaults to `30`. */
|
|
37
37
|
reservationMinutes?: number;
|
|
38
|
+
/**
|
|
39
|
+
* The IANA time zone the events take place in (`Europe/Copenhagen`), used to write their dates in messages (the
|
|
40
|
+
* `{{event.startsAt}}` of `@frigear-nu/campaigns`). Unset follows the app's (`appConfig.frigearUi.timeZone`), else UTC.
|
|
41
|
+
*/
|
|
42
|
+
timeZone?: string;
|
|
38
43
|
};
|
|
39
44
|
};
|
|
40
45
|
type EventsRuntimeConfig = {
|
|
41
46
|
reservationMinutes: number;
|
|
47
|
+
/** The IANA zone event dates are written in, in messages (`settings.timeZone`); unset follows the app's. */
|
|
48
|
+
timeZone?: string;
|
|
42
49
|
};
|
|
43
50
|
type PublicModuleOptions = {
|
|
44
51
|
pages: {
|
|
@@ -290,6 +297,49 @@ type MembershipOptionsContext = {
|
|
|
290
297
|
};
|
|
291
298
|
type TicketHookContext = {
|
|
292
299
|
ticket: TicketDto;
|
|
300
|
+
/** The ticket's holder. */
|
|
301
|
+
userId: number;
|
|
302
|
+
};
|
|
303
|
+
/** Context of `events:ticket:checked-in`: a paid ticket was scanned in for the first time. */
|
|
304
|
+
type TicketCheckedInContext = TicketHookContext & {
|
|
305
|
+
/** The staff member who scanned it. */
|
|
306
|
+
checkedInBy: number;
|
|
307
|
+
};
|
|
308
|
+
/** A date of an event that changed, with its value before and after (ISO strings, `null` when unset). */
|
|
309
|
+
type EventDateChange = {
|
|
310
|
+
from: string | null;
|
|
311
|
+
to: string | null;
|
|
312
|
+
};
|
|
313
|
+
/** Context of `events:updated`: an event's own fields changed (staff route or MCP tool). */
|
|
314
|
+
type EventUpdatedContext = {
|
|
315
|
+
event: AdminEventDto;
|
|
316
|
+
/** The event as it was before. */
|
|
317
|
+
previous: AdminEventDto;
|
|
318
|
+
/** The dates that changed (`startsAt`, `endsAt`); empty when none did. */
|
|
319
|
+
changedDates: Partial<Record<'startsAt' | 'endsAt', EventDateChange>>;
|
|
320
|
+
};
|
|
321
|
+
/** Context of `events:status-changed`: an event was published, unpublished (back to `draft`) or archived. */
|
|
322
|
+
type EventStatusChangedContext = {
|
|
323
|
+
event: AdminEventDto;
|
|
324
|
+
from: EventStatus;
|
|
325
|
+
to: EventStatus;
|
|
326
|
+
};
|
|
327
|
+
/** Context of `events:deleted`: an event (without paid tickets) was deleted. */
|
|
328
|
+
type EventDeletedContext = {
|
|
329
|
+
/** The event as it was. */
|
|
330
|
+
event: AdminEventDto;
|
|
331
|
+
};
|
|
332
|
+
/** Which of an event's paid tickets an `event` grant admits: all of them, or only those (not) checked in. */
|
|
333
|
+
type EventGrantStatus = 'paid' | 'checked-in' | 'not-checked-in';
|
|
334
|
+
/**
|
|
335
|
+
* The `event` grant kind (`@frigear-nu/auth`): the holders of a paid ticket to `eventId`, narrowed to those checked in
|
|
336
|
+
* or not (`status`, default `paid`) and to some ticket types (`ticketTypeIds`, default all).
|
|
337
|
+
*/
|
|
338
|
+
type EventGrant = {
|
|
339
|
+
kind: 'event';
|
|
340
|
+
eventId: string;
|
|
341
|
+
status?: EventGrantStatus;
|
|
342
|
+
ticketTypeIds?: string[];
|
|
293
343
|
};
|
|
294
344
|
|
|
295
345
|
declare module '@nuxt/schema' {
|
|
@@ -323,9 +373,17 @@ declare module 'nitropack' {
|
|
|
323
373
|
'events:ticket:paid': (ctx: TicketHookContext) => void | Promise<void>;
|
|
324
374
|
/** A paid ticket was fully refunded. */
|
|
325
375
|
'events:ticket:refunded': (ctx: TicketHookContext) => void | Promise<void>;
|
|
376
|
+
/** A paid ticket was checked in (its first scan; a repeated scan calls nothing). */
|
|
377
|
+
'events:ticket:checked-in': (ctx: TicketCheckedInContext) => void | Promise<void>;
|
|
378
|
+
/** An event's own fields were saved (staff route or MCP tool); `changedDates` names the dates that moved. */
|
|
379
|
+
'events:updated': (ctx: EventUpdatedContext) => void | Promise<void>;
|
|
380
|
+
/** An event's status changed (published, back to draft, archived). Called after `events:updated`. */
|
|
381
|
+
'events:status-changed': (ctx: EventStatusChangedContext) => void | Promise<void>;
|
|
382
|
+
/** An event was deleted (only one without paid tickets can be). */
|
|
383
|
+
'events:deleted': (ctx: EventDeletedContext) => void | Promise<void>;
|
|
326
384
|
}
|
|
327
385
|
}
|
|
328
386
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
329
387
|
|
|
330
388
|
export { _default as default };
|
|
331
|
-
export type { AddonDto, AddonGroupDto, AdminAddonDto, AdminAddonGroupDto, AdminEventDetailDto, AdminEventDto, AdminTicketTypeDto, AttendeeDto, CheckInResponse, EventDetailDto, EventStatus, EventSummaryDto, EventsListFilterContext, EventsRuntimeConfig, MembershipCheckContext, MembershipOption, MembershipOptionsContext, MembershipOptionsDto, MembershipRequirement, ModuleOptions, PublicModuleOptions, PurchaseBeforeContext, PurchaseBody, PurchaseResponse, TicketDto, TicketHookContext, TicketStatus, TicketTypeDto, UpcomingEventsDto };
|
|
389
|
+
export type { AddonDto, AddonGroupDto, AdminAddonDto, AdminAddonGroupDto, AdminEventDetailDto, AdminEventDto, AdminTicketTypeDto, AttendeeDto, CheckInResponse, EventDateChange, EventDeletedContext, EventDetailDto, EventGrant, EventGrantStatus, EventStatus, EventStatusChangedContext, EventSummaryDto, EventUpdatedContext, EventsListFilterContext, EventsRuntimeConfig, MembershipCheckContext, MembershipOption, MembershipOptionsContext, MembershipOptionsDto, MembershipRequirement, ModuleOptions, PublicModuleOptions, PurchaseBeforeContext, PurchaseBody, PurchaseResponse, TicketCheckedInContext, TicketDto, TicketHookContext, TicketStatus, TicketTypeDto, UpcomingEventsDto };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, hasNuxtModule, addServerImportsDir, addNitroPlugin, addImports, addComponentsDir } from '@nuxt/kit';
|
|
2
2
|
import { registerModule, registerTailwindSource, registerLocales, resolvePagePath, resolveDashboardHubPath, joinPagePath, isPathUnder, addPageRedirects, registerDatabaseTable, addModuleRoutes, registerPreloadProvider, inlineModuleRuntime, addModulePages, addOptionalMenuSource } from '@frigear-nu/module-kit/utils';
|
|
3
3
|
import { adminRoute, extendAdminDashboard } from '@frigear-nu/admin/utils';
|
|
4
|
-
import { registerAccess } from '@frigear-nu/auth/utils';
|
|
4
|
+
import { registerAccess, extendGrants } from '@frigear-nu/auth/utils';
|
|
5
5
|
import { eventsAccess } from '../dist/runtime/access.js';
|
|
6
6
|
import { addMcpDefinitions } from '@frigear-nu/mcp/utils';
|
|
7
|
+
import { eventsCampaignOwner } from '../dist/runtime/campaigns-owner.js';
|
|
8
|
+
import { eventsHubDashboardItems } from '../dist/runtime/dashboard.js';
|
|
7
9
|
|
|
8
10
|
const MODULE_NAME = "@frigear-nu/events";
|
|
9
11
|
const ACCOUNT_TICKETS_PATH = "/account/tickets";
|
|
@@ -27,6 +29,8 @@ const module$1 = defineNuxtModule({
|
|
|
27
29
|
"@frigear-nu/subscriptions": { version: ">=0.0.1", optional: true },
|
|
28
30
|
"@frigear-nu/menu": { version: ">=0.0.1", optional: true },
|
|
29
31
|
"@frigear-nu/widget": { version: ">=0.0.0", optional: true },
|
|
32
|
+
// "My next ticket" on the signed-in hub's dashboard (`runtime/dashboard.ts`).
|
|
33
|
+
"@frigear-nu/dashboard": { version: ">=0.0.0", optional: true },
|
|
30
34
|
// Provides the admin route and shell the admin pages live in; the page components come from `@frigear-nu/ui`.
|
|
31
35
|
"@frigear-nu/admin": { version: ">=0.0.0", optional: true }
|
|
32
36
|
},
|
|
@@ -46,7 +50,8 @@ const module$1 = defineNuxtModule({
|
|
|
46
50
|
const adminPath = withAdmin ? resolvePagePath(settings.pages?.admin, adminRoute(nuxt, "events")) : void 0;
|
|
47
51
|
const adminEventPath = withAdmin ? resolvePagePath(settings.pages?.adminEvent, adminRoute(nuxt, "events", ":id")) : void 0;
|
|
48
52
|
nuxt.options.runtimeConfig.events = {
|
|
49
|
-
reservationMinutes: settings.reservationMinutes ?? 30
|
|
53
|
+
reservationMinutes: settings.reservationMinutes ?? 30,
|
|
54
|
+
...settings.timeZone ? { timeZone: settings.timeZone } : {}
|
|
50
55
|
};
|
|
51
56
|
nuxt.options.runtimeConfig.public.events = {
|
|
52
57
|
pages: { events: eventsPath, event: eventPath, tickets: ticketsPath, admin: adminPath, adminEvent: adminEventPath },
|
|
@@ -99,10 +104,26 @@ const module$1 = defineNuxtModule({
|
|
|
99
104
|
inlineModuleRuntime(nuxt, resolver);
|
|
100
105
|
if (settings.mcp === true) addMcpDefinitions(nuxt, resolver.resolve("./runtime/server/mcp"));
|
|
101
106
|
addNitroPlugin(resolver.resolve("./runtime/server/plugins/payment-hooks"));
|
|
107
|
+
extendGrants(nuxt, {
|
|
108
|
+
kind: "event",
|
|
109
|
+
label: "Event",
|
|
110
|
+
labelKey: "events.grants.event",
|
|
111
|
+
icon: "i-lucide-ticket",
|
|
112
|
+
server: resolver.resolve("./runtime/server/grants/event"),
|
|
113
|
+
field: resolver.resolve("./runtime/app/grants/EventGrantField.vue"),
|
|
114
|
+
defaults: { eventId: "" },
|
|
115
|
+
order: 40
|
|
116
|
+
});
|
|
117
|
+
nuxt.hook("campaigns:owners", (owners) => {
|
|
118
|
+
owners.push(eventsCampaignOwner());
|
|
119
|
+
});
|
|
102
120
|
nuxt.hook("modules:done", () => {
|
|
103
121
|
if (hasNuxtModule("@frigear-nu/subscriptions", nuxt)) {
|
|
104
122
|
addNitroPlugin(resolver.resolve("./runtime/server/plugins/subscriptions-membership"));
|
|
105
123
|
}
|
|
124
|
+
if (hasNuxtModule("@frigear-nu/campaigns", nuxt)) {
|
|
125
|
+
addNitroPlugin(resolver.resolve("./runtime/server/plugins/campaigns-owner"));
|
|
126
|
+
}
|
|
106
127
|
});
|
|
107
128
|
addImports([
|
|
108
129
|
{ name: "useEvents", from: resolver.resolve("./runtime/app/composables/useEvents") },
|
|
@@ -138,17 +159,25 @@ const module$1 = defineNuxtModule({
|
|
|
138
159
|
title: "Upcoming events",
|
|
139
160
|
titleKey: "events.admin.dashboard.upcomingStat",
|
|
140
161
|
order: 11,
|
|
141
|
-
size: { cols: 1, maxCols: 2 }
|
|
162
|
+
size: { cols: 1, maxCols: 2 },
|
|
163
|
+
// Shown to staff who may manage events (the route checks it too).
|
|
164
|
+
permission: eventsAccess.permissions.manage
|
|
142
165
|
}, "top");
|
|
143
166
|
extendAdminDashboard(nuxt, {
|
|
144
167
|
id: "events-upcoming",
|
|
145
168
|
component: resolver.resolve("./runtime/app/widgets/UpcomingEvents.vue"),
|
|
146
169
|
title: "Next events",
|
|
170
|
+
icon: "i-lucide-calendar-days",
|
|
147
171
|
titleKey: "events.admin.dashboard.upcoming",
|
|
148
172
|
order: 30,
|
|
149
|
-
size: { cols: 2, minCols: 1 }
|
|
173
|
+
size: { cols: 2, minCols: 1 },
|
|
174
|
+
permission: eventsAccess.permissions.manage
|
|
150
175
|
}, "side");
|
|
151
176
|
}
|
|
177
|
+
if (hasNuxtModule("@frigear-nu/dashboard")) {
|
|
178
|
+
const { extendHubDashboard } = await import('@frigear-nu/dashboard/utils');
|
|
179
|
+
extendHubDashboard(nuxt, eventsHubDashboardItems((path) => resolver.resolve(path)));
|
|
180
|
+
}
|
|
152
181
|
addOptionalMenuSource(nuxt, { file: resolver.resolve("./runtime/menus"), menu: "account" });
|
|
153
182
|
}
|
|
154
183
|
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, surfaceClass, useAction, useDashboardItem, useEventLinks, useEventsTranslate, useFormat, useModuleT, useMyTickets, watchEffect } from "#imports";
|
|
3
|
+
defineOptions({ name: "EventsMyNextTicketItem" });
|
|
4
|
+
const t = useModuleT("events");
|
|
5
|
+
const tr = useEventsTranslate();
|
|
6
|
+
const format = useFormat();
|
|
7
|
+
const links = useEventLinks();
|
|
8
|
+
const item = useDashboardItem();
|
|
9
|
+
const { tickets, loading, error, refresh, pay } = useMyTickets();
|
|
10
|
+
const { run, busy: paying } = useAction();
|
|
11
|
+
const GRACE_MS = 12 * 60 * 60 * 1e3;
|
|
12
|
+
const upcoming = computed(() => {
|
|
13
|
+
const now = Date.now();
|
|
14
|
+
return tickets.value.filter((ticket) => (ticket.status === "paid" || ticket.status === "pending") && Date.parse(ticket.startsAt) + GRACE_MS > now).sort((a, b) => Date.parse(a.startsAt) - Date.parse(b.startsAt));
|
|
15
|
+
});
|
|
16
|
+
const next = computed(() => upcoming.value[0]);
|
|
17
|
+
const more = computed(() => Math.max(0, upcoming.value.length - 1));
|
|
18
|
+
watchEffect(() => {
|
|
19
|
+
item.loading.value = loading.value && !tickets.value.length;
|
|
20
|
+
item.error.value = tickets.value.length ? null : error.value;
|
|
21
|
+
if (item.empty) item.empty.value = !loading.value && !error.value && !next.value;
|
|
22
|
+
if (item.link) item.link.value = next.value ? { to: links.tickets(), label: t("dashboard.allTickets", "All tickets") } : null;
|
|
23
|
+
});
|
|
24
|
+
item.onRefresh(refresh);
|
|
25
|
+
const month = computed(() => next.value ? format.date(next.value.startsAt, { month: "short", dateStyle: void 0 }) : "");
|
|
26
|
+
const day = computed(() => next.value ? format.date(next.value.startsAt, { day: "numeric", dateStyle: void 0 }) : "");
|
|
27
|
+
const when = computed(() => next.value ? format.dateTime(next.value.startsAt, { dateStyle: "full", timeStyle: "short" }) : "");
|
|
28
|
+
const started = computed(() => !!next.value && Date.parse(next.value.startsAt) <= Date.now());
|
|
29
|
+
const daysAway = computed(() => next.value ? Math.max(0, Math.round((Date.parse(next.value.startsAt) - Date.now()) / 864e5)) : 0);
|
|
30
|
+
const countdown = computed(() => {
|
|
31
|
+
if (started.value || daysAway.value === 0) return t("dashboard.ticketToday", "Today");
|
|
32
|
+
if (daysAway.value === 1) return t("dashboard.ticketTomorrow", "Tomorrow");
|
|
33
|
+
return t("dashboard.ticketInDays", "In {count} days", { count: daysAway.value });
|
|
34
|
+
});
|
|
35
|
+
function payNext() {
|
|
36
|
+
const ticket = next.value;
|
|
37
|
+
if (ticket) return run(() => pay(ticket.id));
|
|
38
|
+
}
|
|
39
|
+
const details = computed(() => next.value ? [next.value.ticketTypeName, ...next.value.addons.map((addon) => addon.label)].map((value) => tr(value)).filter(Boolean).join(" \xB7 ") : "");
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<section
|
|
44
|
+
v-if="next"
|
|
45
|
+
:class="[surfaceClass, 'flex h-full flex-col gap-4 p-4']"
|
|
46
|
+
data-events-next-ticket
|
|
47
|
+
>
|
|
48
|
+
<div class="flex items-start gap-4">
|
|
49
|
+
<!-- A calendar leaf: the month over the day. -->
|
|
50
|
+
<div
|
|
51
|
+
class="bg-primary/10 ring-primary/25 text-primary flex w-14 shrink-0 flex-col items-center rounded-lg py-1.5 ring ring-inset"
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
>
|
|
54
|
+
<span class="text-xs font-medium uppercase">{{ month }}</span>
|
|
55
|
+
<span class="text-highlighted text-2xl leading-tight font-semibold tabular-nums">{{ day }}</span>
|
|
56
|
+
</div>
|
|
57
|
+
<div class="flex min-w-0 flex-1 flex-col gap-1">
|
|
58
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
59
|
+
<NuxtLink
|
|
60
|
+
:to="links.event(next.eventSlug)"
|
|
61
|
+
class="text-highlighted truncate text-base font-semibold hover:underline"
|
|
62
|
+
>
|
|
63
|
+
{{ tr(next.eventName) }}
|
|
64
|
+
</NuxtLink>
|
|
65
|
+
<UBadge
|
|
66
|
+
:color="started || daysAway <= 1 ? 'success' : 'neutral'"
|
|
67
|
+
variant="subtle"
|
|
68
|
+
size="sm"
|
|
69
|
+
:label="countdown"
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
<span class="text-default text-sm">{{ when }}</span>
|
|
73
|
+
<span
|
|
74
|
+
v-if="details"
|
|
75
|
+
class="text-muted truncate text-xs"
|
|
76
|
+
>{{ details }}</span>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<UAlert
|
|
81
|
+
v-if="next.status === 'pending'"
|
|
82
|
+
color="warning"
|
|
83
|
+
variant="subtle"
|
|
84
|
+
icon="i-lucide-credit-card"
|
|
85
|
+
:title="t('dashboard.ticketUnpaid', 'This ticket is not paid yet')"
|
|
86
|
+
:description="t('dashboard.ticketUnpaidHint', 'Pay for it to keep your place.')"
|
|
87
|
+
/>
|
|
88
|
+
|
|
89
|
+
<div class="mt-auto flex flex-wrap items-center gap-2">
|
|
90
|
+
<UButton
|
|
91
|
+
v-if="next.status === 'pending'"
|
|
92
|
+
icon="i-lucide-credit-card"
|
|
93
|
+
:label="t('dashboard.payTicket', 'Pay for the ticket')"
|
|
94
|
+
:loading="paying"
|
|
95
|
+
@click="payNext"
|
|
96
|
+
/>
|
|
97
|
+
<UButton
|
|
98
|
+
v-else
|
|
99
|
+
:to="links.tickets()"
|
|
100
|
+
icon="i-lucide-qr-code"
|
|
101
|
+
trailing-icon="i-lucide-arrow-right"
|
|
102
|
+
:label="t('dashboard.showTicket', 'Show my ticket')"
|
|
103
|
+
/>
|
|
104
|
+
<span
|
|
105
|
+
v-if="more"
|
|
106
|
+
class="text-muted text-xs"
|
|
107
|
+
>{{ t("dashboard.moreTickets", "{count} more upcoming", { count: more }) }}</span>
|
|
108
|
+
</div>
|
|
109
|
+
</section>
|
|
110
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EventGrant } from '../../../types.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
};
|
|
5
|
+
type __VLS_ModelProps = {
|
|
6
|
+
modelValue: EventGrant;
|
|
7
|
+
};
|
|
8
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
|
+
"update:modelValue": (value: EventGrant) => any;
|
|
11
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
12
|
+
"onUpdate:modelValue"?: ((value: EventGrant) => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref, useFetch, useModuleT } from "#imports";
|
|
3
|
+
import { eventsApi } from "../../utils/api";
|
|
4
|
+
import { useEventsTranslate } from "../composables/useEvents";
|
|
5
|
+
defineOptions({ name: "EventGrantField" });
|
|
6
|
+
defineProps({
|
|
7
|
+
disabled: { type: Boolean, required: false }
|
|
8
|
+
});
|
|
9
|
+
const model = defineModel({ type: Object, ...{ required: true } });
|
|
10
|
+
const t = useModuleT("events");
|
|
11
|
+
const tr = useEventsTranslate();
|
|
12
|
+
const search = ref("");
|
|
13
|
+
const { data: events, status: eventsStatus } = useFetch(eventsApi.admin.events, {
|
|
14
|
+
key: "events:grant-options",
|
|
15
|
+
query: computed(() => ({ pageSize: 100, ...search.value.trim() ? { q: search.value.trim() } : {} })),
|
|
16
|
+
server: false,
|
|
17
|
+
lazy: true,
|
|
18
|
+
default: () => ({ items: [] })
|
|
19
|
+
});
|
|
20
|
+
const { data: detail } = useFetch(() => model.value.eventId ? eventsApi.admin.event(model.value.eventId) : "", {
|
|
21
|
+
key: computed(() => `events:grant-event:${model.value.eventId}`),
|
|
22
|
+
immediate: !!model.value.eventId,
|
|
23
|
+
watch: [() => model.value.eventId],
|
|
24
|
+
server: false,
|
|
25
|
+
lazy: true,
|
|
26
|
+
default: () => null
|
|
27
|
+
});
|
|
28
|
+
const eventItems = computed(() => {
|
|
29
|
+
const known = (events.value?.items ?? []).map((event) => ({ label: tr(event.name), value: event.id }));
|
|
30
|
+
const current = model.value.eventId;
|
|
31
|
+
return current && !known.some((item) => item.value === current) ? [...known, { label: detail.value ? tr(detail.value.name) : current, value: current }] : known;
|
|
32
|
+
});
|
|
33
|
+
const statusItems = computed(() => [
|
|
34
|
+
{ label: t("grants.statuses.paid", "Every ticket holder"), value: "paid" },
|
|
35
|
+
{ label: t("grants.statuses.checkedIn", "Checked in"), value: "checked-in" },
|
|
36
|
+
{ label: t("grants.statuses.notCheckedIn", "Not checked in"), value: "not-checked-in" }
|
|
37
|
+
]);
|
|
38
|
+
const ticketTypeItems = computed(() => (detail.value?.ticketTypes ?? []).map((type) => ({ label: tr(type.name), value: type.id })));
|
|
39
|
+
const setEvent = (eventId) => {
|
|
40
|
+
model.value = { kind: "event", eventId, ...model.value.status ? { status: model.value.status } : {} };
|
|
41
|
+
};
|
|
42
|
+
const setStatus = (status) => {
|
|
43
|
+
const { status: _previous, ...rest } = model.value;
|
|
44
|
+
model.value = status === "paid" ? rest : { ...rest, status };
|
|
45
|
+
};
|
|
46
|
+
const setTicketTypes = (ids) => {
|
|
47
|
+
const { ticketTypeIds: _previous, ...rest } = model.value;
|
|
48
|
+
model.value = ids.length ? { ...rest, ticketTypeIds: ids } : rest;
|
|
49
|
+
};
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<template>
|
|
53
|
+
<div class="flex flex-col gap-2 sm:flex-row">
|
|
54
|
+
<USelectMenu
|
|
55
|
+
v-model:search-term="search"
|
|
56
|
+
:model-value="model.eventId"
|
|
57
|
+
:items="eventItems"
|
|
58
|
+
value-key="value"
|
|
59
|
+
ignore-filter
|
|
60
|
+
:loading="eventsStatus === 'pending'"
|
|
61
|
+
class="w-full"
|
|
62
|
+
:disabled="disabled"
|
|
63
|
+
:placeholder="t('grants.choose', 'Choose an event')"
|
|
64
|
+
:search-input="{ placeholder: t('grants.search', 'Search events') }"
|
|
65
|
+
@update:model-value="(value) => setEvent(value)"
|
|
66
|
+
/>
|
|
67
|
+
<USelect
|
|
68
|
+
:model-value="model.status ?? 'paid'"
|
|
69
|
+
:items="statusItems"
|
|
70
|
+
value-key="value"
|
|
71
|
+
class="w-full sm:w-48"
|
|
72
|
+
:disabled="disabled"
|
|
73
|
+
:aria-label="t('grants.status', 'Which ticket holders')"
|
|
74
|
+
@update:model-value="(value) => setStatus(value)"
|
|
75
|
+
/>
|
|
76
|
+
<USelectMenu
|
|
77
|
+
:model-value="model.ticketTypeIds ?? []"
|
|
78
|
+
:items="ticketTypeItems"
|
|
79
|
+
value-key="value"
|
|
80
|
+
multiple
|
|
81
|
+
class="w-full"
|
|
82
|
+
:disabled="disabled || !model.eventId"
|
|
83
|
+
:placeholder="t('grants.allTicketTypes', 'Every ticket type')"
|
|
84
|
+
@update:model-value="(value) => setTicketTypes(value)"
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
</template>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EventGrant } from '../../../types.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
};
|
|
5
|
+
type __VLS_ModelProps = {
|
|
6
|
+
modelValue: EventGrant;
|
|
7
|
+
};
|
|
8
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
|
+
"update:modelValue": (value: EventGrant) => any;
|
|
11
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
12
|
+
"onUpdate:modelValue"?: ((value: EventGrant) => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
@@ -59,6 +59,8 @@ const columns = computed(() => [
|
|
|
59
59
|
>
|
|
60
60
|
<template #actions>
|
|
61
61
|
<TooltipButton
|
|
62
|
+
:kbds="['meta', 'enter']"
|
|
63
|
+
shortcut-level="page"
|
|
62
64
|
icon="i-lucide-plus"
|
|
63
65
|
:label="t('admin.create', 'New event')"
|
|
64
66
|
:tooltip="t('admin.createHint', 'Create a draft event; it stays hidden until you publish it')"
|
|
@@ -14,17 +14,27 @@ const { run } = useAction();
|
|
|
14
14
|
const page = ref(1);
|
|
15
15
|
const pageSize = ref(50);
|
|
16
16
|
const search = ref("");
|
|
17
|
+
const onlyCheckedIn = ref(false);
|
|
17
18
|
const q = refDebounced(search, 300);
|
|
18
|
-
watch([q, pageSize], () => {
|
|
19
|
+
watch([q, pageSize, onlyCheckedIn], () => {
|
|
19
20
|
page.value = 1;
|
|
20
21
|
});
|
|
21
|
-
const query = computed(() => ({
|
|
22
|
+
const query = computed(() => ({
|
|
23
|
+
page: page.value,
|
|
24
|
+
pageSize: pageSize.value,
|
|
25
|
+
q: q.value.trim() || void 0,
|
|
26
|
+
checkedIn: onlyCheckedIn.value ? "true" : void 0
|
|
27
|
+
}));
|
|
22
28
|
const { data, status, error, refresh } = await useFetch(() => eventsApi.admin.attendees(props.event.id), { query });
|
|
23
29
|
const rows = computed(() => data.value?.items ?? []);
|
|
24
30
|
const loading = computed(() => status.value === "pending" && !data.value);
|
|
25
31
|
const refreshing = computed(() => status.value === "pending" && !!data.value);
|
|
26
32
|
const typeName = (ticketTypeId) => tr(props.event.ticketTypes.find((item) => item.id === ticketTypeId)?.name);
|
|
27
33
|
const who = (ticket) => ticket.userName || ticket.userEmail || "";
|
|
34
|
+
const checkIn = (ticket, code) => run(async () => {
|
|
35
|
+
await $fetch(eventsApi.admin.checkIn, { method: "POST", body: { code } });
|
|
36
|
+
await refresh();
|
|
37
|
+
}, { success: t("admin.attendeeCheckedIn", "{name} checked in.", { name: who(ticket) }) });
|
|
28
38
|
const ticketAction = async (ticket, action) => {
|
|
29
39
|
const confirmed = await confirmAction({
|
|
30
40
|
title: action === "refund" ? t("admin.confirmRefund", "Refund this ticket?") : t("admin.confirmCancel", "Cancel this ticket?"),
|
|
@@ -39,13 +49,17 @@ const ticketAction = async (ticket, action) => {
|
|
|
39
49
|
}, { success: action === "refund" ? t("admin.refunded", "Refunded.") : t("admin.cancelled", "Cancelled.") });
|
|
40
50
|
};
|
|
41
51
|
const menu = (ticket) => {
|
|
52
|
+
const code = ticket.code;
|
|
53
|
+
const admission = ticket.status === "paid" && !ticket.checkedInAt && code ? [{ label: t("admin.checkInAttendee", "Check in attendee"), icon: "i-lucide-check", onSelect: () => {
|
|
54
|
+
void checkIn(ticket, code);
|
|
55
|
+
} }] : [];
|
|
42
56
|
const refund = ticket.status === "paid" && ticket.paymentId ? [{ label: t("admin.refund", "Refund ticket"), icon: "i-lucide-undo-2", onSelect: () => {
|
|
43
57
|
void ticketAction(ticket, "refund");
|
|
44
58
|
} }] : [];
|
|
45
59
|
const cancel = ticket.status === "paid" || ticket.status === "pending" ? [{ label: t("admin.cancelTicket", "Cancel ticket"), icon: "i-lucide-ban", color: "error", onSelect: () => {
|
|
46
60
|
void ticketAction(ticket, "cancel");
|
|
47
61
|
} }] : [];
|
|
48
|
-
return [refund, cancel].filter((group) => group.length);
|
|
62
|
+
return [admission, refund, cancel].filter((group) => group.length);
|
|
49
63
|
};
|
|
50
64
|
const TableIdentity = resolveComponent("TableIdentity");
|
|
51
65
|
const StatusBadge = resolveComponent("StatusBadge");
|
|
@@ -89,14 +103,21 @@ const columns = computed(() => [
|
|
|
89
103
|
:refreshing="refreshing"
|
|
90
104
|
>
|
|
91
105
|
<template #actions>
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
<div class="flex flex-wrap items-center gap-3">
|
|
107
|
+
<USwitch
|
|
108
|
+
v-model="onlyCheckedIn"
|
|
109
|
+
size="sm"
|
|
110
|
+
:label="t('admin.onlyCheckedIn', 'Checked in only')"
|
|
111
|
+
/>
|
|
112
|
+
<UInput
|
|
113
|
+
v-model="search"
|
|
114
|
+
icon="i-lucide-search"
|
|
115
|
+
size="sm"
|
|
116
|
+
:placeholder="t('admin.searchAttendees', 'Search name or email')"
|
|
117
|
+
:aria-label="t('admin.searchAttendees', 'Search name or email')"
|
|
118
|
+
class="w-full sm:max-w-xs"
|
|
119
|
+
/>
|
|
120
|
+
</div>
|
|
100
121
|
</template>
|
|
101
122
|
<UEmpty
|
|
102
123
|
v-if="error && !data"
|
|
@@ -116,7 +137,7 @@ const columns = computed(() => [
|
|
|
116
137
|
<UEmpty
|
|
117
138
|
variant="naked"
|
|
118
139
|
icon="i-lucide-users"
|
|
119
|
-
:title="t('admin.noAttendees', 'No tickets yet.')"
|
|
140
|
+
:title="onlyCheckedIn ? t('admin.noCheckedInAttendees', 'No checked-in attendees found.') : t('admin.noAttendees', 'No tickets yet.')"
|
|
120
141
|
/>
|
|
121
142
|
</template>
|
|
122
143
|
</UTable>
|
|
@@ -144,9 +144,10 @@ async function save(event) {
|
|
|
144
144
|
</UForm>
|
|
145
145
|
<template #footer>
|
|
146
146
|
<div class="flex justify-end gap-2">
|
|
147
|
-
<
|
|
147
|
+
<TooltipButton
|
|
148
148
|
type="submit"
|
|
149
149
|
form="admin-event-details"
|
|
150
|
+
:kbds="['meta', 'enter']"
|
|
150
151
|
:loading="busy"
|
|
151
152
|
:label="t('admin.saveEvent', 'Save event')"
|
|
152
153
|
/>
|
|
@@ -15,28 +15,37 @@ const { data, status } = useLazyFetch(eventsApi.admin.upcoming, { key: "admin-ev
|
|
|
15
15
|
<template>
|
|
16
16
|
<ListCard
|
|
17
17
|
:title="framed ? void 0 : t('admin.upcoming.title', 'Upcoming events')"
|
|
18
|
-
:loading="status === 'pending' && !data"
|
|
18
|
+
:loading="(status === 'pending' || status === 'idle') && !data"
|
|
19
19
|
:is-empty="!data?.items.length"
|
|
20
|
-
:empty="t('admin.upcoming.empty', 'No upcoming events.')"
|
|
20
|
+
:empty="status === 'error' ? t('admin.upcoming.error', 'Could not load the upcoming events.') : t('admin.upcoming.empty', 'No upcoming events.')"
|
|
21
21
|
:to="links.admin()"
|
|
22
22
|
:to-label="t('admin.upcoming.all', 'All events')"
|
|
23
23
|
>
|
|
24
24
|
<li
|
|
25
25
|
v-for="item in data?.items"
|
|
26
26
|
:key="item.id"
|
|
27
|
-
class="min-w-0"
|
|
27
|
+
class="flex min-w-0 items-center gap-3"
|
|
28
28
|
>
|
|
29
|
-
<
|
|
30
|
-
:
|
|
31
|
-
class="text-
|
|
29
|
+
<time
|
|
30
|
+
:datetime="item.startsAt"
|
|
31
|
+
class="bg-primary/10 text-primary flex size-10 shrink-0 flex-col items-center justify-center rounded-md leading-none"
|
|
32
32
|
>
|
|
33
|
-
{{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
<span class="text-[10px] font-medium uppercase">{{ format.date(item.startsAt, { dateStyle: void 0, month: "short" }) }}</span>
|
|
34
|
+
<span class="text-sm font-semibold tabular-nums">{{ format.date(item.startsAt, { dateStyle: void 0, day: "numeric" }) }}</span>
|
|
35
|
+
</time>
|
|
36
|
+
<div class="min-w-0 flex-1">
|
|
37
|
+
<NuxtLink
|
|
38
|
+
:to="links.adminEvent(item.id)"
|
|
39
|
+
class="text-highlighted block truncate font-medium hover:underline"
|
|
40
|
+
>
|
|
41
|
+
{{ tr(item.name) }}
|
|
42
|
+
</NuxtLink>
|
|
43
|
+
<p class="text-muted truncate text-xs">
|
|
44
|
+
{{ format.time(item.startsAt) }}<template v-if="item.location">
|
|
45
|
+
· {{ tr(item.location) }}
|
|
46
|
+
</template>
|
|
47
|
+
</p>
|
|
48
|
+
</div>
|
|
40
49
|
</li>
|
|
41
50
|
</ListCard>
|
|
42
51
|
</template>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { eventsApi } from "../../utils/api";
|
|
3
|
-
import { useEventLinks, useLazyFetch, useModuleT } from "#imports";
|
|
3
|
+
import { computed, useEventLinks, useEventsTranslate, useFormat, useLazyFetch, useModuleT } from "#imports";
|
|
4
4
|
defineOptions({ name: "EventsUpcomingStat" });
|
|
5
5
|
defineProps({
|
|
6
6
|
framed: { type: Boolean, required: false }
|
|
7
7
|
});
|
|
8
8
|
const t = useModuleT("events");
|
|
9
|
+
const tr = useEventsTranslate();
|
|
10
|
+
const format = useFormat();
|
|
9
11
|
const links = useEventLinks();
|
|
10
12
|
const { data, status } = useLazyFetch(eventsApi.admin.upcoming, { key: "admin-events-upcoming" });
|
|
13
|
+
const next = computed(() => data.value?.items[0]);
|
|
11
14
|
</script>
|
|
12
15
|
|
|
13
16
|
<template>
|
|
@@ -16,6 +19,8 @@ const { data, status } = useLazyFetch(eventsApi.admin.upcoming, { key: "admin-ev
|
|
|
16
19
|
icon="i-lucide-calendar-days"
|
|
17
20
|
:to="links.admin()"
|
|
18
21
|
:value="data?.total"
|
|
19
|
-
:
|
|
22
|
+
:hint="next ? t('admin.upcoming.next', 'Next: {name}, {date}', { name: tr(next.name), date: format.shortDate(next.startsAt) }) : data ? t('admin.upcoming.none', 'Nothing planned yet') : void 0"
|
|
23
|
+
:loading="(status === 'pending' || status === 'idle') && !data"
|
|
24
|
+
:empty="t('admin.upcoming.error', 'Could not load the upcoming events.')"
|
|
20
25
|
/>
|
|
21
26
|
</template>
|