@frigear-nu/events 0.5.4 → 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/README.md +15 -1
- package/dist/module.d.mts +78 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +52 -10
- package/dist/runtime/app/components/EventAdminAddonGroups.vue +2 -1
- 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 +4 -1
- package/dist/runtime/app/tabs/Attendees.vue +33 -12
- package/dist/runtime/app/tabs/Details.vue +2 -1
- package/dist/runtime/app/tabs/Tickets.vue +4 -2
- package/dist/runtime/app/widgets/UpcomingEvents.d.vue.ts +4 -1
- package/dist/runtime/app/widgets/UpcomingEvents.vue +26 -14
- package/dist/runtime/app/widgets/UpcomingEvents.vue.d.ts +4 -1
- package/dist/runtime/app/widgets/UpcomingEventsStat.d.vue.ts +4 -1
- package/dist/runtime/app/widgets/UpcomingEventsStat.vue +11 -3
- package/dist/runtime/app/widgets/UpcomingEventsStat.vue.d.ts +4 -1
- 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 +41 -2
- package/dist/runtime/i18n/lang/en.json +41 -2
- package/dist/runtime/server/grants/event.d.ts +3 -0
- package/dist/runtime/server/grants/event.js +38 -0
- package/dist/runtime/server/mcp/tools/admin/list-all-events.js +2 -1
- 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/{bootstrap → preload}/my-tickets.d.ts +1 -1
- 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/routes/admin/events.get.js +4 -3
- package/dist/runtime/server/routes/admin/upcoming.get.js +7 -2
- package/dist/runtime/server/routes/me/tickets.get.js +1 -1
- package/dist/runtime/server/utils/admin.d.ts +16 -2
- package/dist/runtime/server/utils/admin.js +25 -0
- package/dist/runtime/server/utils/tickets.js +1 -1
- package/dist/runtime/utils/api.d.ts +1 -1
- package/dist/runtime/utils/api.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 +28 -14
- /package/dist/runtime/server/{bootstrap → preload}/my-tickets.js +0 -0
package/README.md
CHANGED
|
@@ -31,7 +31,9 @@ export default defineNuxtConfig({
|
|
|
31
31
|
Policies on `events:manage` and `events:refund` (`definePolicy`) receive the event row (`typeof schema.events.$inferSelect`)
|
|
32
32
|
as their `record`, on every route and MCP tool: also when the action is on a ticket type, add-on group, add-on or ticket,
|
|
33
33
|
the policy gets the event it belongs to (never the child row). Checks without a record (listing, creating an event) run
|
|
34
|
-
the policy only with `withoutRecord
|
|
34
|
+
the policy only with `withoutRecord`, so a record policy does not filter the staff event lists (the admin list, the
|
|
35
|
+
dashboard's upcoming events, the `list-all-events` MCP tool). Give them the same rule in the `events:list:filter` hook,
|
|
36
|
+
which ANDs your conditions on `schema.events` into those queries.
|
|
35
37
|
|
|
36
38
|
```ts
|
|
37
39
|
// server/policies.ts: youth coordinators manage the `youth-*` events only
|
|
@@ -41,6 +43,18 @@ export default [
|
|
|
41
43
|
]
|
|
42
44
|
```
|
|
43
45
|
|
|
46
|
+
```ts [server/plugins/events-list.ts]
|
|
47
|
+
import { like } from 'drizzle-orm'
|
|
48
|
+
import { schema } from '@nuxthub/db'
|
|
49
|
+
|
|
50
|
+
// The same rule on the staff lists, which check without a record and so run no policy.
|
|
51
|
+
export default defineNitroPlugin((nitro) => {
|
|
52
|
+
nitro.hooks.hook('events:list:filter', async ({ event, principal, where }) => {
|
|
53
|
+
if ((await getEffectiveRoles(event, principal.user)).includes('youth')) where.push(like(schema.events.slug, 'youth-%'))
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
|
|
44
58
|
Tickets (`tickets:read`, `tickets:write`) are self-service: every signed-in user holds them. The named scope `tickets`
|
|
45
59
|
offers both to API tokens and OAuth clients.
|
|
46
60
|
|
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { H3Event } from 'h3';
|
|
3
|
+
import { SQL } from 'drizzle-orm';
|
|
4
|
+
import { AuthPrincipal } from '@frigear-nu/auth/utils';
|
|
3
5
|
import { Translated } from '@frigear-nu/ui/translated';
|
|
4
6
|
export { Translated } from '@frigear-nu/ui/translated';
|
|
5
7
|
import { Schedule } from '@frigear-nu/module-kit/schedule';
|
|
@@ -33,10 +35,17 @@ type ModuleOptions = {
|
|
|
33
35
|
};
|
|
34
36
|
/** Minutes an unpaid ticket keeps its seat (the Stripe session expires then). Defaults to `30`. */
|
|
35
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;
|
|
36
43
|
};
|
|
37
44
|
};
|
|
38
45
|
type EventsRuntimeConfig = {
|
|
39
46
|
reservationMinutes: number;
|
|
47
|
+
/** The IANA zone event dates are written in, in messages (`settings.timeZone`); unset follows the app's. */
|
|
48
|
+
timeZone?: string;
|
|
40
49
|
};
|
|
41
50
|
type PublicModuleOptions = {
|
|
42
51
|
pages: {
|
|
@@ -259,6 +268,18 @@ type MembershipOption = {
|
|
|
259
268
|
value: string;
|
|
260
269
|
label: string;
|
|
261
270
|
};
|
|
271
|
+
/**
|
|
272
|
+
* Context of the `events:list:filter` hook, called by every staff list of events (the admin list, the dashboard's
|
|
273
|
+
* upcoming events and the `list-all-events` MCP tool). Those lists check `events:manage` without a record, so record
|
|
274
|
+
* policies never run for them: a host that narrows `events:manage` with a policy pushes the same rule here.
|
|
275
|
+
*/
|
|
276
|
+
type EventsListFilterContext = {
|
|
277
|
+
event: H3Event;
|
|
278
|
+
/** The caller, as `authorize(event, 'events:manage')` returned it. */
|
|
279
|
+
principal: AuthPrincipal;
|
|
280
|
+
/** Conditions on `schema.events`, ANDed into the list query. Push to narrow; never remove another listener's. */
|
|
281
|
+
where: SQL[];
|
|
282
|
+
};
|
|
262
283
|
/** Context of the `events:membership:check` hook. */
|
|
263
284
|
type MembershipCheckContext = {
|
|
264
285
|
userId: number;
|
|
@@ -276,6 +297,49 @@ type MembershipOptionsContext = {
|
|
|
276
297
|
};
|
|
277
298
|
type TicketHookContext = {
|
|
278
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[];
|
|
279
343
|
};
|
|
280
344
|
|
|
281
345
|
declare module '@nuxt/schema' {
|
|
@@ -298,15 +362,28 @@ declare module 'nitropack' {
|
|
|
298
362
|
'events:membership:check': (ctx: MembershipCheckContext) => void | Promise<void>;
|
|
299
363
|
/** Membership provider: set `ctx.available = true` and add the selectable memberships to `ctx.options`. */
|
|
300
364
|
'events:membership:options': (ctx: MembershipOptionsContext) => void | Promise<void>;
|
|
365
|
+
/**
|
|
366
|
+
* Narrow the staff lists of events: push conditions on `schema.events` to `ctx.where`. Mirror here any policy a
|
|
367
|
+
* host adds on `events:manage`, since lists check without a record and so run no record policy.
|
|
368
|
+
*/
|
|
369
|
+
'events:list:filter': (ctx: EventsListFilterContext) => void | Promise<void>;
|
|
301
370
|
/** Policy hook: throw to deny a purchase. */
|
|
302
371
|
'events:purchase:before': (ctx: PurchaseBeforeContext) => void | Promise<void>;
|
|
303
372
|
/** A ticket became `paid` (free tickets immediately, paid ones after the Stripe event). Send confirmations here. */
|
|
304
373
|
'events:ticket:paid': (ctx: TicketHookContext) => void | Promise<void>;
|
|
305
374
|
/** A paid ticket was fully refunded. */
|
|
306
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>;
|
|
307
384
|
}
|
|
308
385
|
}
|
|
309
386
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
310
387
|
|
|
311
388
|
export { _default as default };
|
|
312
|
-
export type { AddonDto, AddonGroupDto, AdminAddonDto, AdminAddonGroupDto, AdminEventDetailDto, AdminEventDto, AdminTicketTypeDto, AttendeeDto, CheckInResponse, EventDetailDto, EventStatus, EventSummaryDto, 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
|
-
import { registerModule, registerTailwindSource, registerLocales, resolvePagePath, resolveDashboardHubPath, joinPagePath, isPathUnder, addPageRedirects, registerDatabaseTable, addModuleRoutes,
|
|
3
|
-
import { adminRoute } from '@frigear-nu/admin/utils';
|
|
4
|
-
import { registerAccess } from '@frigear-nu/auth/utils';
|
|
2
|
+
import { registerModule, registerTailwindSource, registerLocales, resolvePagePath, resolveDashboardHubPath, joinPagePath, isPathUnder, addPageRedirects, registerDatabaseTable, addModuleRoutes, registerPreloadProvider, inlineModuleRuntime, addModulePages, addOptionalMenuSource } from '@frigear-nu/module-kit/utils';
|
|
3
|
+
import { adminRoute, extendAdminDashboard } from '@frigear-nu/admin/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 },
|
|
@@ -67,10 +72,10 @@ const module$1 = defineNuxtModule({
|
|
|
67
72
|
{ method: "get", path: ":slug", file: "public/event.get" },
|
|
68
73
|
{ method: "post", path: ":slug/purchase", file: "public/purchase.post" }
|
|
69
74
|
], { base: "/api/events" });
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
registerPreloadProvider(nuxt, {
|
|
76
|
+
area: "account",
|
|
72
77
|
key: "events:tickets:mine",
|
|
73
|
-
handler: resolver.resolve("./runtime/server/
|
|
78
|
+
handler: resolver.resolve("./runtime/server/preload/my-tickets")
|
|
74
79
|
});
|
|
75
80
|
addModuleRoutes(resolver, [
|
|
76
81
|
{ method: "get", path: "", file: "admin/events.get" },
|
|
@@ -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") },
|
|
@@ -132,9 +153,30 @@ const module$1 = defineNuxtModule({
|
|
|
132
153
|
]);
|
|
133
154
|
}
|
|
134
155
|
if (adminPath && hasNuxtModule("@frigear-nu/widget")) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
156
|
+
extendAdminDashboard(nuxt, {
|
|
157
|
+
id: "events-upcoming-stat",
|
|
158
|
+
component: resolver.resolve("./runtime/app/widgets/UpcomingEventsStat.vue"),
|
|
159
|
+
title: "Upcoming events",
|
|
160
|
+
titleKey: "events.admin.dashboard.upcomingStat",
|
|
161
|
+
order: 11,
|
|
162
|
+
size: { cols: 1, maxCols: 2 },
|
|
163
|
+
// Shown to staff who may manage events (the route checks it too).
|
|
164
|
+
permission: eventsAccess.permissions.manage
|
|
165
|
+
}, "top");
|
|
166
|
+
extendAdminDashboard(nuxt, {
|
|
167
|
+
id: "events-upcoming",
|
|
168
|
+
component: resolver.resolve("./runtime/app/widgets/UpcomingEvents.vue"),
|
|
169
|
+
title: "Next events",
|
|
170
|
+
icon: "i-lucide-calendar-days",
|
|
171
|
+
titleKey: "events.admin.dashboard.upcoming",
|
|
172
|
+
order: 30,
|
|
173
|
+
size: { cols: 2, minCols: 1 },
|
|
174
|
+
permission: eventsAccess.permissions.manage
|
|
175
|
+
}, "side");
|
|
176
|
+
}
|
|
177
|
+
if (hasNuxtModule("@frigear-nu/dashboard")) {
|
|
178
|
+
const { extendHubDashboard } = await import('@frigear-nu/dashboard/utils');
|
|
179
|
+
extendHubDashboard(nuxt, eventsHubDashboardItems((path) => resolver.resolve(path)));
|
|
138
180
|
}
|
|
139
181
|
addOptionalMenuSource(nuxt, { file: resolver.resolve("./runtime/menus"), menu: "account" });
|
|
140
182
|
}
|
|
@@ -60,12 +60,13 @@ const catalog = useEventCatalogActions({ onChanged: () => emit("refresh") });
|
|
|
60
60
|
</p>
|
|
61
61
|
</div>
|
|
62
62
|
<div>
|
|
63
|
-
<
|
|
63
|
+
<TooltipButton
|
|
64
64
|
icon="i-lucide-plus"
|
|
65
65
|
color="neutral"
|
|
66
66
|
variant="outline"
|
|
67
67
|
size="xs"
|
|
68
68
|
:label="t('admin.addGroup', 'Add add-on group')"
|
|
69
|
+
:tooltip="t('admin.addGroupHint', 'Give buyers a set of extras to choose from with this ticket')"
|
|
69
70
|
@click="catalog.openGroup(ticketType)"
|
|
70
71
|
/>
|
|
71
72
|
</div>
|
|
@@ -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;
|
|
@@ -58,9 +58,12 @@ const columns = computed(() => [
|
|
|
58
58
|
:description="t('admin.listDescription', 'Events, their ticket types and attendees.')"
|
|
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')"
|
|
66
|
+
:tooltip="t('admin.createHint', 'Create a draft event; it stays hidden until you publish it')"
|
|
64
67
|
@click="actions.create()"
|
|
65
68
|
/>
|
|
66
69
|
</template>
|
|
@@ -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
|
/>
|