@oneclick.dev/cms-core-modules 0.0.117 → 0.0.118

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.
@@ -1,1245 +0,0 @@
1
- import { defineComponent as ve, inject as Xe, computed as P, ref as j, onMounted as Je, nextTick as Ge, onUnmounted as Ke, watch as Q, openBlock as i, createElementBlock as M, resolveComponent as R, withModifiers as Qe, createElementVNode as d, Fragment as ue, createVNode as c, unref as t, normalizeStyle as be, toDisplayString as $, createCommentVNode as Z, createBlock as A, isRef as ne, withCtx as b, createTextVNode as Y, renderList as De, normalizeClass as ie, withDirectives as Ze, vModelText as et, provide as tt } from "vue";
2
- import { useModuleRoute as $e, useModule as Me, useFirebaseIntegration as Re, useModulePermissions as at } from "@oneclick.dev/cms-kit";
3
- import { _ as st } from "./EditLayout.vue_vue_type_script_setup_true_lang-pDO9b4Pv.mjs";
4
- import { f as _e, q as ot, p as nt, E as pe, Z as Se, _ as rt, B as Ae, Q as Ee, u as fe, I as ze, $ as lt, a0 as it, a1 as ct, n as dt, h as ut, K as mt, J as pt, P as ft } from "./index-Bnn9LahC.mjs";
5
- import { componentToString as Oe, ChartTooltipContent as Pe } from "@oneclick.dev/cms-kit/charts";
6
- import { Layers as we, ChevronDown as vt, ChevronLeft as gt, ChevronRight as ht, CalendarIcon as xt, Users as je, RefreshCw as yt, Search as bt, X as kt, Eye as ge, EyeOff as he, Clock as Dt } from "lucide-vue-next";
7
- import { u as _t } from "./index-hMp4p5qA.mjs";
8
- import { X as St, b as He, a as wt, c as Ct, r as $t, D as xe, $ as Be, O as ye, z as Ne, A as We } from "./index-cC_2cw31.mjs";
9
- import { _ as Mt } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
10
- import { u as Rt, F as Vt, _ as Tt, a as It, b as At } from "./OrderDetailDialog.vue_vue_type_script_setup_true_lang-DwAUYR8p.mjs";
11
- import { _ as Et } from "./NewReservationDialog.vue_vue_type_script_setup_true_lang-BXTkYCm_.mjs";
12
- function zt({ x: f, y: h, w: s, h: x, tl: v = !1, tr: y = !1, bl: k = !1, br: r = !1, r: n = 0 }) {
13
- let l;
14
- l = `M${f + n},${h}h${s - 2 * n}`;
15
- let o = y ? n : 0, u = y ? 0 : n;
16
- return l += `a${o},${o} 0 0 1 ${o},${o}`, l += `h${u}v${u}`, l += `v${x - 2 * n}`, o = r ? n : 0, u = r ? 0 : n, l += `a${o},${o} 0 0 1 ${-o},${o}`, l += `v${u}h${-u}`, l += `h${2 * n - s}`, o = k ? n : 0, u = k ? 0 : n, l += `a${o},${o} 0 0 1 ${-o},${-o}`, l += `h${-u}v${-u}`, l += `v${2 * n - x}`, o = v ? n : 0, u = v ? 0 : n, l += `a${o},${o} 0 0 1 ${o},${-o}`, l += `v${-u}h${u}`, l += "z", l;
17
- }
18
- const Ot = Object.assign(Object.assign({}, St), { color: void 0, groupMaxWidth: void 0, groupWidth: void 0, dataStep: void 0, groupPadding: 0.05, barPadding: 0, roundedCorners: 2, barMinHeight: 2, cursor: null, orientation: He.Vertical }), Ue = _e`
19
- label: grouped-bar-component;
20
- `, Pt = ot`
21
- :root {
22
- --vis-grouped-bar-cursor: default;
23
- --vis-grouped-bar-fill-color: var(--vis-color-main);
24
- --vis-grouped-bar-stroke-color: none;
25
- --vis-grouped-bar-stroke-width: 0px;
26
- --vis-grouped-bar-hover-stroke-width: 1px;
27
- --vis-grouped-bar-hover-stroke-color: none;
28
-
29
-
30
- /* Dark Theme */
31
- --vis-dark-grouped-bar-stroke-color: none;
32
- }
33
-
34
- body.theme-dark ${`.${Ue}`} {
35
- --vis-grouped-bar-stroke-color: var(--vis-dark-grouped-bar-stroke-color);
36
- }
37
- `, ke = _e`
38
- label: bar;
39
- fill: var(--vis-grouped-bar-fill-color);
40
- stroke: var(--vis-grouped-bar-stroke-color);
41
- stroke-width: var(--vis-grouped-bar-stroke-width);
42
- cursor: var(--vis-grouped-bar-cursor);
43
-
44
- &:hover {
45
- stroke-width: var(--vis-grouped-bar-hover-stroke-width);
46
- stroke: var(--vis-grouped-bar-hover-stroke-color);
47
- }
48
- `, Ce = _e`
49
- label: barGroup;
50
- `, qe = _e`
51
- label: barGroupExit;
52
- `, jt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
53
- __proto__: null,
54
- bar: ke,
55
- barGroup: Ce,
56
- barGroupExit: qe,
57
- globalStyles: Pt,
58
- root: Ue
59
- }, Symbol.toStringTag, { value: "Module" }));
60
- class Ye extends wt {
61
- constructor(h) {
62
- super(), this._defaultConfig = Ot, this.config = this._defaultConfig, this.getAccessors = () => nt(this.config.y) ? this.config.y : [this.config.y], this.events = {}, this._barData = [], h && this.setConfig(h);
63
- }
64
- get bleed() {
65
- if (this._barData = this._getVisibleData(), this._barData.length === 0)
66
- return { top: 0, bottom: 0, left: 0, right: 0 };
67
- const h = !this.isVertical() && this.dataScale.range()[0] > this.dataScale.range()[1], s = this.dataScale.domain(), x = this._getGroupWidth() / 2, v = this._barData.map((_, O) => pe(_, this.config.x, O)), y = Se(v), k = rt(v), r = this.dataScale(y), n = this.dataScale(k), l = this.dataScale.invert(r + (h ? x : -x)), o = this.dataScale.invert(n + (h ? -x : x)), u = l <= s[0] ? this.dataScale(s[0]) - this.dataScale(l) : 0, V = o > s[1] ? this.dataScale(o) - this.dataScale(s[1]) : 0;
68
- return {
69
- top: this.isVertical() ? 0 : h ? -V : u,
70
- bottom: this.isVertical() ? 0 : h ? -u : V,
71
- left: this.isVertical() ? u : 0,
72
- right: this.isVertical() ? V : 0
73
- };
74
- }
75
- get dataScale() {
76
- return this.isVertical() ? this.xScale : this.yScale;
77
- }
78
- get valueScale() {
79
- return this.isVertical() ? this.yScale : this.xScale;
80
- }
81
- isVertical() {
82
- return this.config.orientation === He.Vertical;
83
- }
84
- _render(h) {
85
- const { config: s } = this, x = Ae(h) ? h : s.duration, v = this._getGroupWidth(), y = this.getAccessors(), k = [-v / 2, v / 2], r = Ct().domain($t(y.length)).range(k).paddingInner(s.barPadding).paddingOuter(s.barPadding), n = this.g.selectAll(`.${Ce}`).data(this._barData, (B, E) => {
86
- var L;
87
- return `${(L = Ee(B, s.id, E)) !== null && L !== void 0 ? L : E}`;
88
- }), l = (B, E) => {
89
- const L = this.dataScale(pe(B, s.x, E)), z = this.isVertical() ? L : 0, q = this.isVertical() ? 0 : L;
90
- return `translate(${z},${q})`;
91
- }, u = n.enter().append("g").attr("class", Ce).attr("transform", l).style("opacity", 1).merge(n);
92
- fe(u, x).attr("transform", l).style("opacity", 1);
93
- const V = n.exit().attr("class", qe);
94
- fe(V, x).style("opacity", 0).remove(), fe(V.selectAll(`.${ke}`), x).attr("transform", (B, E, L) => this.isVertical() ? `translate(0,${this.yScale(0)}) scale(1,0)` : `translate(${this.xScale(0)},0) scale(0,1)`);
95
- const _ = r.bandwidth(), O = u.selectAll(`.${ke}`).data((B) => y.map(() => B)), T = this._getValueAxisDirection(), te = O.enter().append("path").attr("class", ke).attr("d", (B, E) => {
96
- const L = r(E), z = this.valueScale(0), q = _;
97
- return this._getBarPath(L, z, q, 0, !1, T);
98
- }).style("fill", (B, E) => ze(B, s.color, E)).merge(O);
99
- fe(te, x).attr("d", (B, E) => {
100
- const L = r(E), z = _, q = pe(B, y[E]), g = q < 0;
101
- let N = g ? this.valueScale(0) : this.valueScale(q || 0), ae = Math.abs(this.valueScale(0) - this.valueScale(q)) || 0;
102
- if (ae < s.barMinHeight) {
103
- const ce = T === xe.North ? -1 : 1;
104
- N = this.valueScale(0) + ce * s.barMinHeight, ae = s.barMinHeight;
105
- }
106
- return this._getBarPath(L, N, z, ae, g, T);
107
- }).style("fill", (B, E) => ze(B, s.color, E)).style("cursor", (B, E) => Ee(B, s.cursor, E)), fe(O.exit(), x).remove();
108
- }
109
- _getValueAxisDirection() {
110
- return this.valueScale.range()[0] > this.valueScale.range()[1] ? xe.North : xe.South;
111
- }
112
- _getVisibleData() {
113
- const { config: h, datamodel: { data: s } } = this, x = this._getGroupWidth(), v = s.length < 2 ? 0 : x / 2, y = this.dataScale, k = Math.abs(y.invert(v) - y.invert(0));
114
- return s?.filter((n, l) => {
115
- const o = pe(n, h.x, l), u = y.domain(), V = +u[0], _ = +u[1];
116
- return o >= V - k && o <= _ + k;
117
- });
118
- }
119
- _getBarPath(h, s, x, v, y, k) {
120
- const { config: r } = this, n = r.roundedCorners ? Ae(r.roundedCorners) ? +r.roundedCorners : x / 2 : 0, l = ut(n, 0, Math.min(v, x) / 2), o = k === xe.North, u = this.isVertical() && y !== o, V = this.isVertical() && y === o, _ = !this.isVertical() && y, O = !this.isVertical() && !y;
121
- return zt({
122
- x: this.isVertical() ? h : s + (o ? 0 : -v),
123
- y: this.isVertical() ? s + (o ? 0 : -v) : h,
124
- w: this.isVertical() ? x : v,
125
- h: this.isVertical() ? v : x,
126
- tl: u || _,
127
- tr: u || O,
128
- bl: V || _,
129
- br: V || O,
130
- r: l
131
- });
132
- }
133
- _getGroupWidth() {
134
- const { config: h, datamodel: { data: s } } = this;
135
- if (lt(s))
136
- return 0;
137
- if (h.groupWidth)
138
- return Se([h.groupWidth, h.groupMaxWidth]);
139
- const x = this.dataScale.bandwidth, v = this.dataScale.domain ? this.dataScale.domain() : [];
140
- let k = 1 + (x ? v.length : v[1] - v[0]) / h.dataStep || !x && s.filter((l, o) => {
141
- const u = pe(l, h.x, o);
142
- return u >= v[0] && u <= v[1];
143
- }).length || s.length;
144
- !x && k >= 2 && (k += 1);
145
- const n = (k < 2 ? 1 : 1 - h.groupPadding) * (this.isVertical() ? this._width : this._height) / k;
146
- return Se([n, h.groupMaxWidth]);
147
- }
148
- getValueScaleExtent(h) {
149
- const { datamodel: s } = this, x = this.getAccessors(), v = h ? this._getVisibleData() : s.data, y = it(v, ...x), k = ct(v, ...x);
150
- return [y > 0 ? 0 : y, k < 0 ? 0 : k];
151
- }
152
- getDataScaleExtent() {
153
- const { config: h, datamodel: s } = this;
154
- return dt(s.data, h.x);
155
- }
156
- getYDataExtent(h) {
157
- return this.isVertical() ? this.getValueScaleExtent(h) : this.getDataScaleExtent();
158
- }
159
- getXDataExtent() {
160
- return this.isVertical() ? this.getDataScaleExtent() : this.getValueScaleExtent(!1);
161
- }
162
- }
163
- Ye.selectors = jt;
164
- const Bt = { "data-vis-component": "" }, Fe = /* @__PURE__ */ ve({
165
- __name: "index",
166
- props: {
167
- color: {},
168
- groupWidth: {},
169
- groupMaxWidth: {},
170
- dataStep: {},
171
- groupPadding: {},
172
- barPadding: {},
173
- roundedCorners: { type: [Number, Boolean] },
174
- barMinHeight: {},
175
- cursor: {},
176
- orientation: {},
177
- x: {},
178
- y: {},
179
- id: { type: Function },
180
- xScale: { type: [Object, Function] },
181
- yScale: { type: [Object, Function] },
182
- excludeFromDomainCalculation: { type: Boolean },
183
- duration: {},
184
- events: {},
185
- attributes: {},
186
- data: {}
187
- },
188
- setup(f, { expose: h }) {
189
- const s = Xe(mt), x = f, v = P(() => s.data.value ?? x.data), y = pt(x), k = j();
190
- return Je(() => {
191
- Ge(() => {
192
- var r;
193
- k.value = new Ye(y.value), (r = k.value) == null || r.setData(v.value), s.update(k.value);
194
- });
195
- }), Ke(() => {
196
- var r;
197
- (r = k.value) == null || r.destroy(), s.destroy();
198
- }), Q(y, (r, n) => {
199
- var l;
200
- ft(r, n) || (l = k.value) == null || l.setConfig(y.value);
201
- }), Q(v, () => {
202
- var r;
203
- (r = k.value) == null || r.setData(v.value);
204
- }), h({
205
- component: k
206
- }), (r, n) => (i(), M("div", Bt));
207
- }
208
- }), Nt = { class: "flex flex-col sm:flex-row" }, Wt = ["data-active"], Ft = { class: "flex items-center gap-2" }, Lt = { class: "block text-muted-foreground text-xs mr-2 max-w-[120px] truncate" }, Gt = { class: "block text-lg leading-none font-bold sm:text-3xl" }, Ht = { class: "mx-auto w-full max-w-sm mt-2 mb-8" }, Ut = { class: "text-muted-foreground" }, qt = { class: "text-muted-foreground" }, Yt = { class: "grid" }, Xt = { class: "flex gap-1 overflow-hidden max-w-80" }, Jt = { class: "truncate" }, Kt = /* @__PURE__ */ ve({
209
- __name: "ResourceSelector",
210
- props: {
211
- resources: {
212
- type: Array,
213
- required: !0
214
- },
215
- totals: {
216
- type: Object,
217
- required: !0
218
- },
219
- viewMode: {
220
- type: String,
221
- required: !0
222
- },
223
- activeChart: {
224
- type: String,
225
- required: !1
226
- }
227
- },
228
- emits: ["update:viewMode", "update:activeChart"],
229
- setup(f, { emit: h }) {
230
- const s = f, x = h, v = P({
231
- get: () => s.viewMode,
232
- set: (l) => {
233
- x("update:viewMode", l);
234
- }
235
- }), y = P({
236
- get: () => s.activeChart,
237
- set: (l) => {
238
- x("update:activeChart", l);
239
- }
240
- }), { width: k } = _t(), r = P(() => k.value < 640), n = j(!1);
241
- return (l, o) => {
242
- const u = R("DrawerTitle"), V = R("DrawerDescription"), _ = R("DrawerHeader"), O = R("Button"), T = R("DrawerFooter"), J = R("DrawerContent"), te = R("Drawer"), B = R("DropdownMenuTrigger"), E = R("DropdownMenuLabel"), L = R("DropdownMenuItem"), z = R("DropdownMenuContent"), q = R("DropdownMenu");
243
- return i(), M("div", Nt, [
244
- f.resources.length > 1 ? (i(), M("button", {
245
- key: 0,
246
- "data-active": f.viewMode === "stacked",
247
- class: "hover:bg-muted/50 flex flex-1 flex-col justify-center gap-2 border-t px-4 py-3 text-left sm:border-t-0 sm:border-l sm:px-6 sm:py-6 cursor-pointer select-none",
248
- onClick: o[0] || (o[0] = (g) => n.value = !0),
249
- onContextmenu: o[1] || (o[1] = Qe((g) => n.value = !0, ["prevent"]))
250
- }, [
251
- d("div", Ft, [
252
- f.viewMode === "stacked" ? (i(), M(ue, { key: 0 }, [
253
- c(t(we), { class: "size-3 text-muted-foreground" }),
254
- o[6] || (o[6] = d("span", { class: "block text-muted-foreground text-xs mr-2 max-w-[120px] truncate" }, "All Resources", -1))
255
- ], 64)) : (i(), M(ue, { key: 1 }, [
256
- d("div", {
257
- class: "size-3 rounded-full mr-2",
258
- style: be({ backgroundColor: f.resources.find((g) => g.id === f.activeChart)?.color || "#6b7280" })
259
- }, null, 4),
260
- d("span", Lt, $(f.resources.find((g) => g.id === f.activeChart)?.name || "Select Resource"), 1)
261
- ], 64)),
262
- c(t(vt), { class: "ml-auto size-4" })
263
- ]),
264
- d("span", Gt, $(f.viewMode === "stacked" ? Object.values(f.totals).reduce((g, N) => g + N, 0).toLocaleString() : (f.totals[f.activeChart] || 0).toLocaleString()), 1)
265
- ], 40, Wt)) : Z("", !0),
266
- t(r) ? (i(), A(te, {
267
- key: 1,
268
- open: t(n),
269
- "onUpdate:open": o[3] || (o[3] = (g) => ne(n) ? n.value = g : null)
270
- }, {
271
- default: b(() => [
272
- c(J, null, {
273
- default: b(() => [
274
- d("div", Ht, [
275
- c(_, null, {
276
- default: b(() => [
277
- c(u, null, {
278
- default: b(() => [...o[7] || (o[7] = [
279
- Y("Resources", -1)
280
- ])]),
281
- _: 1
282
- }),
283
- c(V, null, {
284
- default: b(() => [...o[8] || (o[8] = [
285
- Y("Select the resources to display on the timeline.", -1)
286
- ])]),
287
- _: 1
288
- })
289
- ]),
290
- _: 1
291
- }),
292
- c(T, null, {
293
- default: b(() => [
294
- c(O, {
295
- onClick: o[2] || (o[2] = (g) => {
296
- v.value = "stacked", y.value = "", n.value = !1;
297
- }),
298
- variant: f.viewMode === "stacked" ? "secondary" : "outline"
299
- }, {
300
- default: b(() => [
301
- c(t(we), { class: "size-3 text-muted-foreground" }),
302
- d("span", Ut, " All Resources (" + $(Object.values(f.totals).reduce((g, N) => g + N, 0).toLocaleString()) + ") ", 1)
303
- ]),
304
- _: 1
305
- }, 8, ["variant"]),
306
- (i(!0), M(ue, null, De(f.resources, (g) => (i(), A(O, {
307
- key: g.id,
308
- onClick: (N) => {
309
- v.value = "single", y.value = g.id, n.value = !1;
310
- },
311
- variant: f.viewMode === "single" && f.activeChart === g.id ? "secondary" : "outline"
312
- }, {
313
- default: b(() => [
314
- d("div", {
315
- class: "size-3 rounded-full",
316
- style: be({ backgroundColor: g.color || "#6b7280" })
317
- }, null, 4),
318
- d("span", qt, $(g.name) + " (" + $((f.totals[g.id] || 0).toLocaleString()) + ") ", 1)
319
- ]),
320
- _: 2
321
- }, 1032, ["onClick", "variant"]))), 128))
322
- ]),
323
- _: 1
324
- })
325
- ])
326
- ]),
327
- _: 1
328
- })
329
- ]),
330
- _: 1
331
- }, 8, ["open"])) : (i(), A(q, {
332
- key: 2,
333
- open: t(n),
334
- "onUpdate:open": o[5] || (o[5] = (g) => ne(n) ? n.value = g : null)
335
- }, {
336
- default: b(() => [
337
- c(B, { "as-child": "" }, {
338
- default: b(() => [...o[9] || (o[9] = [
339
- d("button", {
340
- tabindex: "-1",
341
- class: "size-0 opacity-0 self-end"
342
- }, null, -1)
343
- ])]),
344
- _: 1
345
- }),
346
- c(z, { align: "end" }, {
347
- default: b(() => [
348
- c(E, null, {
349
- default: b(() => [...o[10] || (o[10] = [
350
- Y("Resources", -1)
351
- ])]),
352
- _: 1
353
- }),
354
- d("div", Yt, [
355
- c(L, {
356
- onClick: o[4] || (o[4] = (g) => {
357
- v.value = "stacked", y.value = "", n.value = !1;
358
- }),
359
- class: ie(f.viewMode === "stacked" ? "bg-input" : "")
360
- }, {
361
- default: b(() => [
362
- c(t(we), { class: "size-3 text-muted-foreground" }),
363
- d("span", null, " All Resources (" + $(Object.values(f.totals).reduce((g, N) => g + N, 0).toLocaleString()) + ") ", 1)
364
- ]),
365
- _: 1
366
- }, 8, ["class"]),
367
- (i(!0), M(ue, null, De(f.resources, (g) => (i(), A(L, {
368
- key: g.id,
369
- onClick: (N) => {
370
- v.value = "single", y.value = g.id, n.value = !1;
371
- },
372
- class: ie(f.viewMode === "single" && f.activeChart === g.id ? "bg-input" : "")
373
- }, {
374
- default: b(() => [
375
- d("div", {
376
- class: "size-3 rounded-full",
377
- style: be({ backgroundColor: g.color || "#6b7280" })
378
- }, null, 4),
379
- d("span", Xt, [
380
- d("span", Jt, $(g.name), 1),
381
- d("span", null, "(" + $((f.totals[g.id] || 0).toLocaleString()) + ")", 1)
382
- ])
383
- ]),
384
- _: 2
385
- }, 1032, ["onClick", "class"]))), 128))
386
- ])
387
- ]),
388
- _: 1
389
- })
390
- ]),
391
- _: 1
392
- }, 8, ["open"]))
393
- ]);
394
- };
395
- }
396
- }), Qt = { class: "flex flex-1 flex-col justify-center gap-1 px-6 py-5 sm:py-6" }, Zt = { class: "flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3" }, ea = { class: "flex items-center gap-1" }, ta = { class: "timeline-date-trigger" }, aa = {
397
- key: 1,
398
- class: "flex items-center justify-center px-6 py-4 text-muted-foreground text-sm"
399
- }, sa = {
400
- key: 0,
401
- class: "flex items-center justify-center h-[250px]"
402
- }, oa = {
403
- key: 1,
404
- class: "flex items-center justify-center h-[250px]"
405
- }, Le = "#61616180", na = /* @__PURE__ */ ve({
406
- __name: "Timeline",
407
- props: {
408
- modelValue: {},
409
- selectedResource: {},
410
- viewMode: {},
411
- agendaData: {},
412
- resources: {}
413
- },
414
- emits: ["update:modelValue", "update:selectedResource", "update:viewMode"],
415
- setup(f, { emit: h }) {
416
- const s = f, x = h, { params: v } = $e(), { config: y } = Me(), k = Re(y.project), r = j([]), n = j([]), l = j(!0), o = j(s.viewMode || "stacked"), u = j(s.selectedResource || "");
417
- Q(o, (e) => {
418
- x("update:viewMode", e);
419
- }, { immediate: !0 }), Q(u, (e) => {
420
- x("update:selectedResource", o.value === "single" ? e : null);
421
- }), Q(o, (e) => {
422
- x("update:selectedResource", e === "single" ? u.value : null);
423
- }), Q(() => s.selectedResource, (e) => {
424
- o.value === "single" && e !== u.value && (u.value = e || "");
425
- });
426
- const V = /* @__PURE__ */ new Date(), _ = j(s.modelValue || /* @__PURE__ */ new Date()), O = j(null);
427
- Q(() => s.modelValue, (e) => {
428
- e && e.getTime() !== _.value.getTime() && (_.value = e);
429
- }), Q(_, (e) => {
430
- x("update:modelValue", e);
431
- }, { immediate: !0 });
432
- const T = P({
433
- get: () => G(_.value),
434
- set: (e) => {
435
- if (!e) {
436
- _.value = /* @__PURE__ */ new Date();
437
- return;
438
- }
439
- _.value = /* @__PURE__ */ new Date(`${e}T00:00:00`);
440
- }
441
- }), J = () => {
442
- const e = O.value;
443
- if (e) {
444
- if (typeof e.showPicker == "function") {
445
- e.showPicker();
446
- return;
447
- }
448
- e.focus(), e.click();
449
- }
450
- }, te = P(() => {
451
- const e = new Date(V);
452
- e.setDate(V.getDate() - 1);
453
- const m = new Date(V);
454
- return m.setDate(V.getDate() + 1), _.value.toDateString() === V.toDateString() ? "Today" : _.value.toDateString() === e.toDateString() ? "Yesterday" : _.value.toDateString() === m.toDateString() ? "Tomorrow" : _.value.toLocaleDateString("en-US", {
455
- weekday: "long",
456
- month: "long",
457
- day: "numeric",
458
- year: "numeric"
459
- });
460
- }), B = () => {
461
- const e = new Date(_.value);
462
- e.setDate(e.getDate() - 1), _.value = e;
463
- }, E = () => {
464
- const e = new Date(_.value);
465
- e.setDate(e.getDate() + 1), _.value = e;
466
- }, L = () => {
467
- _.value = /* @__PURE__ */ new Date();
468
- }, z = P(() => (s.resources?.length || 0) === 0 ? 10 : Math.max(...(s.resources || []).map((e) => e.capacity || 10))), q = P(() => (s.resources?.length || 0) === 0 ? 10 : (s.resources || []).reduce((e, m) => e + (m.capacity || 10), 0)), g = P(() => (s.resources?.length || 0) === 0 ? 60 : Math.min(...(s.resources || []).map((e) => e.interval || 60))), N = P(() => {
469
- const e = {
470
- total: {
471
- label: "Total Reservations",
472
- color: void 0
473
- }
474
- };
475
- return (s.resources || []).forEach((m, S) => {
476
- e[m.id] = {
477
- label: m.name,
478
- color: m.color || `var(--chart-${S % 5 + 1})`
479
- };
480
- }), e;
481
- });
482
- Q(() => s.resources, (e) => {
483
- (e?.length || 0) > 0 && !u.value && (u.value = e[0].id);
484
- }, { immediate: !0 });
485
- const ae = P(() => [...s.resources || []].sort((e, m) => {
486
- const S = ee.value[e.id] || 0;
487
- return (ee.value[m.id] || 0) - S;
488
- })), ce = P(() => {
489
- const e = [];
490
- return g.value, r.value.forEach((m, S) => {
491
- m.time.endsWith(":00") && e.push(S);
492
- }), e;
493
- }), ee = P(() => {
494
- const e = {};
495
- return s.resources?.forEach((m) => {
496
- e[m.id] = n.value.filter((S) => S.resourceId === m.id).reduce((S, w) => S + (w.reserved || 0), 0);
497
- }), e;
498
- }), Ve = P(() => r.value.reduce((e, m) => Math.max(e, m.total || 0), 0)), p = P(() => Math.max(q.value, Ve.value, 1)), a = (e, m) => {
499
- const S = e[m];
500
- return typeof S == "number" ? S : 0;
501
- }, I = (e, m) => {
502
- const S = ae.value[m];
503
- return !S || a(e, S.id) <= 0 ? 0 : ae.value.slice(m).reduce((w, H) => w + a(e, H.id), 0);
504
- }, G = (e) => {
505
- const m = e.getFullYear(), S = String(e.getMonth() + 1).padStart(2, "0"), w = String(e.getDate()).padStart(2, "0");
506
- return `${m}-${S}-${w}`;
507
- }, W = (e) => {
508
- const [m, S] = e.split(":").map(Number);
509
- return m * 60 + S;
510
- }, F = (e, m) => (s.agendaData?.exceptions || []).find((w) => m >= w.startDate && m <= w.endDate ? w.resourceIds === null ? !0 : w.resourceIds?.includes(e) : !1) || null, se = P(() => {
511
- const e = G(_.value), m = _.value.getDay();
512
- let S = 1440, w = 0;
513
- if ((s.resources || []).forEach((oe) => {
514
- const U = F(oe.id, e);
515
- if (U) {
516
- if (U.isClosed)
517
- return;
518
- U.timeslots.forEach((K) => {
519
- const D = W(K.startTime), C = W(K.endTime);
520
- S = Math.min(S, D), w = Math.max(w, C);
521
- });
522
- } else
523
- (oe.openingHours?.[m] || []).forEach((D) => {
524
- const C = W(D.start), X = W(D.end);
525
- S = Math.min(S, C), w = Math.max(w, X);
526
- });
527
- }), S >= w)
528
- return { startMinutes: 540, endMinutes: 1020 };
529
- const H = Math.floor(S / 60) * 60, le = Math.ceil(w / 60) * 60;
530
- return { startMinutes: H, endMinutes: le };
531
- }), re = () => {
532
- const e = [], m = g.value, { startMinutes: S, endMinutes: w } = se.value;
533
- for (let H = S; H < w; H += m) {
534
- const le = Math.floor(H / 60), oe = H % 60, U = `${String(le).padStart(2, "0")}:${String(oe).padStart(2, "0")}`, K = {
535
- time: U,
536
- label: U,
537
- total: 0
538
- };
539
- s.resources?.forEach((D) => {
540
- K[D.id] = 0;
541
- }), e.push(K);
542
- }
543
- return e;
544
- }, me = async () => {
545
- l.value = !0;
546
- try {
547
- const e = v.value.id, m = G(_.value), S = `${e}_${m}`, w = await k.get(y.reservedSpotsCollection, S);
548
- n.value = [];
549
- for (const U of s.resources || []) {
550
- const K = w?.[U.id] || {};
551
- Object.entries(K).forEach(([D, C]) => {
552
- const [X, de] = D.split("-");
553
- n.value.push({
554
- resourceId: U.id,
555
- startTime: X,
556
- endTime: de,
557
- reserved: C
558
- });
559
- });
560
- }
561
- const H = re(), le = g.value, { startMinutes: oe } = se.value;
562
- n.value.forEach((U) => {
563
- const K = W(U.startTime), D = W(U.endTime);
564
- for (let C = K; C < D; C += le) {
565
- const X = Math.floor((C - oe) / le);
566
- if (X >= 0 && X < H.length) {
567
- const de = H[X][U.resourceId];
568
- if (typeof de == "number") {
569
- const Ie = Number(U.reserved) || 0;
570
- H[X][U.resourceId] = de + Ie, H[X].total += Ie;
571
- }
572
- }
573
- }
574
- }), r.value = H;
575
- } catch (e) {
576
- console.error("Error loading reservation data:", e), r.value = re(), n.value = [];
577
- } finally {
578
- l.value = !1;
579
- }
580
- };
581
- return (async () => await me())(), Q(_, () => {
582
- me();
583
- }), Q(() => s.resources, () => {
584
- (s.resources?.length || 0) > 0 && me();
585
- }), (e, m) => {
586
- const S = R("CardTitle"), w = R("Button"), H = R("CardDescription"), le = R("CardHeader"), oe = R("ChartContainer"), U = R("CardContent"), K = R("Card");
587
- return i(), A(K, { class: "py-4 sm:py-0" }, {
588
- default: b(() => [
589
- c(le, { class: "flex flex-col items-stretch border-b !p-0 sm:flex-row" }, {
590
- default: b(() => [
591
- d("div", Qt, [
592
- d("div", Zt, [
593
- c(S, null, {
594
- default: b(() => [...m[3] || (m[3] = [
595
- Y("Reservations", -1)
596
- ])]),
597
- _: 1
598
- }),
599
- d("div", ea, [
600
- c(w, {
601
- variant: "outline",
602
- size: "icon",
603
- class: "size-8",
604
- onClick: B
605
- }, {
606
- default: b(() => [
607
- c(t(gt), { size: 16 })
608
- ]),
609
- _: 1
610
- }),
611
- c(w, {
612
- variant: "outline",
613
- size: "sm",
614
- class: "h-8 px-3 text-xs",
615
- onClick: L
616
- }, {
617
- default: b(() => [...m[4] || (m[4] = [
618
- Y(" Today ", -1)
619
- ])]),
620
- _: 1
621
- }),
622
- c(w, {
623
- variant: "outline",
624
- size: "icon",
625
- class: "size-8",
626
- onClick: E
627
- }, {
628
- default: b(() => [
629
- c(t(ht), { size: 16 })
630
- ]),
631
- _: 1
632
- })
633
- ])
634
- ]),
635
- c(H, null, {
636
- default: b(() => [
637
- d("div", ta, [
638
- c(w, {
639
- type: "button",
640
- variant: "outline",
641
- onClick: J
642
- }, {
643
- default: b(() => [
644
- c(t(xt), { class: "size-4" }),
645
- Y(" " + $(t(te)), 1)
646
- ]),
647
- _: 1
648
- }),
649
- Ze(d("input", {
650
- ref_key: "dateInputRef",
651
- ref: O,
652
- "onUpdate:modelValue": m[0] || (m[0] = (D) => ne(T) ? T.value = D : null),
653
- type: "date",
654
- class: "timeline-date-picker",
655
- "aria-label": "Select reservation date"
656
- }, null, 512), [
657
- [et, t(T)]
658
- ])
659
- ])
660
- ]),
661
- _: 1
662
- })
663
- ]),
664
- f.resources.length > 0 ? (i(), A(Kt, {
665
- key: 0,
666
- resources: f.resources,
667
- totals: t(ee),
668
- viewMode: t(o),
669
- "onUpdate:viewMode": m[1] || (m[1] = (D) => ne(o) ? o.value = D : null),
670
- activeChart: t(u),
671
- "onUpdate:activeChart": m[2] || (m[2] = (D) => ne(u) ? u.value = D : null)
672
- }, null, 8, ["resources", "totals", "viewMode", "activeChart"])) : (i(), M("div", aa, " No resources configured "))
673
- ]),
674
- _: 1
675
- }),
676
- c(U, { class: "px-2 sm:p-6" }, {
677
- default: b(() => [
678
- t(l) ? (i(), M("div", sa, [...m[5] || (m[5] = [
679
- d("div", { class: "text-muted-foreground" }, "Loading...", -1)
680
- ])])) : f.resources.length === 0 ? (i(), M("div", oa, [...m[6] || (m[6] = [
681
- d("div", { class: "text-muted-foreground" }, "No resources to display", -1)
682
- ])])) : t(o) === "stacked" ? (i(), A(oe, {
683
- key: 2,
684
- config: t(N),
685
- class: "aspect-auto h-[250px] w-full",
686
- cursor: ""
687
- }, {
688
- default: b(() => [
689
- c(t(Be), {
690
- data: t(r),
691
- margin: { left: -24 },
692
- "y-domain": [0, t(p)]
693
- }, {
694
- default: b(() => [
695
- (i(!0), M(ue, null, De(t(ae), (D, C) => (i(), A(t(Fe), {
696
- key: D.id,
697
- x: (X, de) => de,
698
- y: (X) => I(X, C),
699
- color: (X) => a(X, D.id) > 0 ? t(N)[D.id]?.color : Le,
700
- "bar-padding": 0.1,
701
- "rounded-corners": 2
702
- }, null, 8, ["x", "y", "color"]))), 128)),
703
- c(t(ye), {
704
- type: "x",
705
- x: (D, C) => C,
706
- "tick-line": !1,
707
- "domain-line": !1,
708
- "grid-line": !1,
709
- "tick-values": t(ce),
710
- "tick-format": (D) => t(r)[D]?.time || ""
711
- }, null, 8, ["x", "tick-values", "tick-format"]),
712
- c(t(ye), {
713
- type: "y",
714
- "num-ticks": 3,
715
- "tick-line": !1,
716
- "domain-line": !1
717
- }),
718
- c(t(Ne)),
719
- c(t(We), {
720
- template: t(Oe)(t(N), t(Pe), {
721
- labelFormatter(D) {
722
- const C = Math.round(D);
723
- return C >= 0 && C < t(r).length && t(r)[C]?.time || "";
724
- }
725
- }),
726
- color: "#0000"
727
- }, null, 8, ["template"])
728
- ]),
729
- _: 1
730
- }, 8, ["data", "y-domain"])
731
- ]),
732
- _: 1
733
- }, 8, ["config"])) : (i(), A(oe, {
734
- key: t(u),
735
- config: t(N),
736
- class: "aspect-auto h-[250px] w-full",
737
- cursor: ""
738
- }, {
739
- default: b(() => [
740
- c(t(Be), {
741
- data: t(r),
742
- margin: { left: -24 },
743
- "y-domain": [0, t(z)]
744
- }, {
745
- default: b(() => [
746
- c(t(Fe), {
747
- x: (D, C) => C,
748
- y: (D) => D[t(u)] || 0,
749
- color: (D) => D[t(u)] > 0 ? t(N)[t(u)]?.color : Le,
750
- "bar-padding": 0.1,
751
- "rounded-corners": !1
752
- }, null, 8, ["x", "y", "color"]),
753
- c(t(ye), {
754
- type: "x",
755
- x: (D, C) => C,
756
- "tick-line": !1,
757
- "domain-line": !1,
758
- "grid-line": !1,
759
- "tick-values": t(ce),
760
- "tick-format": (D) => t(r)[D]?.time || ""
761
- }, null, 8, ["x", "tick-values", "tick-format"]),
762
- c(t(ye), {
763
- type: "y",
764
- "num-ticks": 3,
765
- "tick-line": !1,
766
- "domain-line": !1
767
- }),
768
- c(t(Ne)),
769
- c(t(We), {
770
- template: t(Oe)(t(N), t(Pe), {
771
- labelFormatter(D) {
772
- const C = Math.round(D);
773
- return C >= 0 && C < t(r).length && t(r)[C]?.time || "";
774
- }
775
- }),
776
- color: "#0000"
777
- }, null, 8, ["template"])
778
- ]),
779
- _: 1
780
- }, 8, ["data", "y-domain"])
781
- ]),
782
- _: 1
783
- }, 8, ["config"]))
784
- ]),
785
- _: 1
786
- })
787
- ]),
788
- _: 1
789
- });
790
- };
791
- }
792
- }), ra = /* @__PURE__ */ Mt(na, [["__scopeId", "data-v-dd90f6b3"]]), la = { class: "flex flex-row items-center justify-between gap-2" }, ia = { class: "relative mb-4" }, ca = { class: "flex gap-1 mb-4 flex-wrap select-none" }, da = {
793
- key: 0,
794
- class: "mb-3 text-sm text-muted-foreground"
795
- }, ua = {
796
- key: 1,
797
- class: "flex items-center justify-center py-8"
798
- }, ma = {
799
- key: 2,
800
- class: "flex flex-col items-center gap-2 text-center py-8 text-muted-foreground"
801
- }, pa = {
802
- key: 3,
803
- class: "text-center py-8 text-muted-foreground"
804
- }, fa = {
805
- key: 4,
806
- class: "space-y-2"
807
- }, va = ["onClick"], ga = { class: "flex items-start justify-between" }, ha = { class: "flex-1" }, xa = { class: "font-medium" }, ya = { class: "text-sm text-muted-foreground" }, ba = { class: "text-sm text-muted-foreground" }, ka = { class: "flex items-center gap-4 flex-wrap" }, Da = { class: "flex items-center gap-2 mt-1 text-xs text-muted-foreground" }, _a = { class: "flex items-center gap-2 mt-1 text-xs text-muted-foreground" }, Sa = {
808
- key: 0,
809
- class: "flex items-center gap-1 mt-1 text-xs text-muted-foreground"
810
- }, wa = { class: "text-right" }, Ca = {
811
- key: 0,
812
- class: "inline-block px-2 py-1 text-xs rounded-full bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"
813
- }, $a = {
814
- key: 1,
815
- class: "inline-block px-2 py-1 text-xs rounded-full bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400"
816
- }, Ma = {
817
- key: 2,
818
- class: "inline-block px-2 py-1 text-xs rounded-full bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400"
819
- }, Ra = {
820
- key: 3,
821
- class: "inline-block px-2 py-1 text-xs rounded-full bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400"
822
- }, Va = {
823
- key: 4,
824
- class: "inline-block px-2 py-1 text-xs rounded-full bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"
825
- }, Ta = {
826
- key: 5,
827
- class: "text-sm font-medium mt-1"
828
- }, Ia = /* @__PURE__ */ ve({
829
- __name: "BookingsList",
830
- props: {
831
- agendaData: {},
832
- activeDate: {},
833
- selectedResource: {},
834
- resources: {}
835
- },
836
- emits: ["resetSelectedResource"],
837
- setup(f, { emit: h }) {
838
- const s = f, x = h, { params: v } = $e(), { config: y } = Me(), k = Re(y.project), r = j([]), n = j(!0), l = j(""), o = j(null), u = j(null), V = P(() => v.value?.id ?? v.id ?? s.agendaData?.id ?? ""), { metadataSchema: _ } = Rt(V), O = P(() => ({
839
- date: T(s.activeDate),
840
- resource: null
841
- }));
842
- tt("event", O);
843
- const T = (p) => {
844
- const a = p.getFullYear(), I = String(p.getMonth() + 1).padStart(2, "0"), G = String(p.getDate()).padStart(2, "0");
845
- return `${a}-${I}-${G}`;
846
- }, J = P(() => {
847
- let p = r.value;
848
- return s.selectedResource && (p = p.filter((a) => a.resourceId === s.selectedResource)), l.value.trim() && (p = new Vt(p, {
849
- keys: [
850
- "customerInfo.firstName",
851
- "customerInfo.lastName",
852
- "customerInfo.email",
853
- "customerInfo.phone",
854
- "resourceName"
855
- ],
856
- threshold: 0.3,
857
- ignoreLocation: !0
858
- }).search(l.value).map((I) => I.item)), p;
859
- }), te = P(() => J.value.filter((p) => z.value.includes(p.reservationStatus))), B = P(() => {
860
- let p = JSON.parse(JSON.stringify(r.value));
861
- return s.selectedResource && (p = p.filter((a) => a.resourceId === s.selectedResource)), p.some((a) => a.reservationStatus === "approved" || a.reservationStatus === "needs_approval");
862
- }), E = P(() => {
863
- const p = r.value.filter((a) => a.reservationStatus === "approved" || a.reservationStatus === "needs_approval");
864
- return {
865
- spots: p.reduce((a, I) => a + (I.spots || 0), 0),
866
- bookings: p.length
867
- };
868
- }), L = () => {
869
- l.value = "";
870
- }, z = j(["needs_approval", "approved"]), q = (p) => {
871
- z.value.includes(p) ? z.value = z.value.filter((a) => a !== p) : z.value.push(p);
872
- }, g = (p, a, I = a.date) => {
873
- const G = s.resources.find((F) => F.id === a.resourceId), W = p.id || p.orderId || a.orderId || "";
874
- return {
875
- customerInfo: p.customerInfo,
876
- amountDue: p.amountDue,
877
- amountPaid: p.amountPaid,
878
- status: p.status,
879
- reservationStatus: a.status,
880
- subtotal: p.subtotal,
881
- total: p.total,
882
- discount: p.discount,
883
- id: W,
884
- res_id: a.id,
885
- resourceId: a.resourceId,
886
- spots: a.spots,
887
- date: I,
888
- createdAt: p.createdAt,
889
- startTime: a.timeslot?.startTime,
890
- endTime: a.timeslot?.endTime,
891
- reservationPrice: a.totalPrice,
892
- reservationBasePrice: a.basePrice,
893
- reservationAddOnsPrice: a.addOnsPrice,
894
- pricingOptionId: a.pricingOptionId,
895
- pricingOption: a.pricingOption,
896
- resourceName: G?.name,
897
- resourceColor: G?.color,
898
- metadata: p.metadata || {},
899
- reservationMetadata: a.metadata || {},
900
- refundStatus: a.refundStatus,
901
- refundedAt: a.refundedAt,
902
- refundedAmount: a.refundedAmount,
903
- refunds: Array.isArray(a.refunds) ? a.refunds : [],
904
- adjustments: p.adjustments || [],
905
- reservationAdjustments: a.adjustments || []
906
- };
907
- }, N = async () => {
908
- await Ge(), await new Promise((p) => {
909
- if (typeof requestAnimationFrame == "function") {
910
- requestAnimationFrame(() => p());
911
- return;
912
- }
913
- p();
914
- });
915
- }, ae = async (p) => {
916
- const a = await k.get(y.reservationsCollection, p);
917
- if (!a) return;
918
- const I = { ...a, id: a.id || p }, G = (I.reservations || []).map((W) => g(I, W));
919
- G.length && (await N(), u.value?.openDialog({
920
- id: I.id,
921
- customerInfo: I.customerInfo,
922
- status: I.status,
923
- createdAt: I.createdAt,
924
- metadata: I.metadata || {},
925
- reservations: G,
926
- adjustments: I.adjustments || [],
927
- totalPrice: typeof I.total == "number" ? I.total : G.reduce((W, F) => W + (F.reservationPrice || 0), 0),
928
- totalSpots: G.reduce((W, F) => W + (F.spots || 0), 0)
929
- }));
930
- }, ce = async (p) => {
931
- await N(), o.value?.openDialog(p);
932
- }, ee = async () => {
933
- n.value = !0, r.value = [];
934
- try {
935
- const p = v.value.id, a = T(s.activeDate), I = /* @__PURE__ */ new Set();
936
- s.resources?.forEach((F) => {
937
- const se = `${F.id}_${a}`;
938
- I.add(se);
939
- });
940
- const G = await k.find(y.reservationsCollection, {
941
- filters: [
942
- { field: "agendaId", operator: "==", value: p },
943
- { field: "status", operator: "==", value: "confirmed" },
944
- { field: "flattenedReservationDates", operator: "array-contains-any", value: Array.from(I) }
945
- ]
946
- });
947
- let W = [];
948
- G.forEach((F) => {
949
- (F.reservations?.filter((re) => re.date === a) || []).forEach((re) => {
950
- W.push(g(F, re, a));
951
- });
952
- }), r.value = W.sort((F, se) => F.startTime?.localeCompare(se.startTime || "") || 0);
953
- } catch (p) {
954
- console.error("Error loading orders:", p), r.value = [];
955
- } finally {
956
- n.value = !1;
957
- }
958
- };
959
- return (async () => await ee())(), Q(() => s.activeDate, () => {
960
- ee();
961
- }), (p, a) => {
962
- const I = R("Badge"), G = R("CardTitle"), W = R("CardDescription"), F = R("Button"), se = R("CardHeader"), re = R("Input"), me = R("CardContent"), Te = R("Card");
963
- return i(), A(Te, null, {
964
- default: b(() => [
965
- c(se, null, {
966
- default: b(() => [
967
- d("div", la, [
968
- d("div", null, [
969
- c(G, { class: "flex items-center gap-2" }, {
970
- default: b(() => [
971
- a[9] || (a[9] = Y(" Bookings ", -1)),
972
- t(E).bookings > 0 ? (i(), A(I, {
973
- key: 0,
974
- variant: "secondary"
975
- }, {
976
- default: b(() => [
977
- Y($(t(E).bookings), 1)
978
- ]),
979
- _: 1
980
- })) : Z("", !0)
981
- ]),
982
- _: 1
983
- }),
984
- c(W, { class: "flex items-center gap-2 mt-1" }, {
985
- default: b(() => [
986
- c(t(je), { size: 14 }),
987
- d("span", null, $(t(E).spots) + " total spots", 1)
988
- ]),
989
- _: 1
990
- })
991
- ]),
992
- c(F, {
993
- variant: "ghost",
994
- size: "icon",
995
- onClick: ee,
996
- disabled: t(n)
997
- }, {
998
- default: b(() => [
999
- c(t(yt), {
1000
- size: 16,
1001
- class: ie({ "animate-spin": t(n) })
1002
- }, null, 8, ["class"])
1003
- ]),
1004
- _: 1
1005
- }, 8, ["disabled"])
1006
- ])
1007
- ]),
1008
- _: 1
1009
- }),
1010
- c(me, null, {
1011
- default: b(() => [
1012
- d("div", ia, [
1013
- c(t(bt), {
1014
- size: 16,
1015
- class: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"
1016
- }),
1017
- c(re, {
1018
- modelValue: t(l),
1019
- "onUpdate:modelValue": a[0] || (a[0] = (e) => ne(l) ? l.value = e : null),
1020
- placeholder: "Search by name, email, or phone...",
1021
- class: "pl-9 pr-9"
1022
- }, null, 8, ["modelValue"]),
1023
- t(l) ? (i(), A(F, {
1024
- key: 0,
1025
- variant: "ghost",
1026
- size: "icon",
1027
- class: "absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7",
1028
- onClick: L
1029
- }, {
1030
- default: b(() => [
1031
- c(t(kt), { size: 14 })
1032
- ]),
1033
- _: 1
1034
- })) : Z("", !0)
1035
- ]),
1036
- d("div", ca, [
1037
- f.agendaData.needsApproval ? (i(), M("button", {
1038
- key: 0,
1039
- onClick: a[1] || (a[1] = (e) => q("needs_approval")),
1040
- class: ie(["flex gap-1.5 items-center px-3 py-1.5 rounded-full text-sm bg-muted", { "opacity-50 hover:opacity-75": !t(z).includes("needs_approval") }])
1041
- }, [
1042
- t(z).includes("needs_approval") ? (i(), A(t(ge), {
1043
- key: 0,
1044
- size: 12
1045
- })) : (i(), A(t(he), {
1046
- key: 1,
1047
- size: 12
1048
- })),
1049
- Y(" Needs Approval (" + $(t(r).filter((e) => e.reservationStatus === "needs_approval").length) + ") ", 1)
1050
- ], 2)) : Z("", !0),
1051
- d("button", {
1052
- onClick: a[2] || (a[2] = (e) => q("approved")),
1053
- class: ie(["flex gap-1.5 items-center px-3 py-1.5 rounded-full text-sm bg-muted", { "opacity-50 hover:opacity-75": !t(z).includes("approved") }])
1054
- }, [
1055
- t(z).includes("approved") ? (i(), A(t(ge), {
1056
- key: 0,
1057
- size: 12
1058
- })) : (i(), A(t(he), {
1059
- key: 1,
1060
- size: 12
1061
- })),
1062
- Y(" Approved (" + $(t(r).filter((e) => e.reservationStatus === "approved").length) + ") ", 1)
1063
- ], 2),
1064
- f.agendaData.needsApproval ? (i(), M("button", {
1065
- key: 1,
1066
- onClick: a[3] || (a[3] = (e) => q("rejected")),
1067
- class: ie(["flex gap-1.5 items-center px-3 py-1.5 rounded-full text-sm bg-muted", { "opacity-50 hover:opacity-75": !t(z).includes("rejected") }])
1068
- }, [
1069
- t(z).includes("rejected") ? (i(), A(t(ge), {
1070
- key: 0,
1071
- size: 12
1072
- })) : (i(), A(t(he), {
1073
- key: 1,
1074
- size: 12
1075
- })),
1076
- Y(" Rejected (" + $(t(r).filter((e) => e.reservationStatus === "rejected").length) + ") ", 1)
1077
- ], 2)) : Z("", !0),
1078
- d("button", {
1079
- onClick: a[4] || (a[4] = (e) => q("cancelled")),
1080
- class: ie(["flex gap-1.5 items-center px-3 py-1.5 rounded-full text-sm bg-muted", { "opacity-50 hover:opacity-75": !t(z).includes("cancelled") }])
1081
- }, [
1082
- t(z).includes("cancelled") ? (i(), A(t(ge), {
1083
- key: 0,
1084
- size: 12
1085
- })) : (i(), A(t(he), {
1086
- key: 1,
1087
- size: 12
1088
- })),
1089
- Y(" Cancelled (" + $(t(r).filter((e) => e.reservationStatus === "cancelled").length) + ") ", 1)
1090
- ], 2)
1091
- ]),
1092
- t(l) ? (i(), M("div", da, " Showing " + $(t(te).length) + " of " + $(t(r).length) + " bookings ", 1)) : Z("", !0),
1093
- t(n) ? (i(), M("div", ua, [...a[10] || (a[10] = [
1094
- d("div", { class: "animate-spin rounded-full h-8 w-8 border-b-2 border-primary" }, null, -1)
1095
- ])])) : t(te).length === 0 ? (i(), M("div", ma, [
1096
- a[13] || (a[13] = Y(" No bookings for this day ", -1)),
1097
- t(B) ? (i(), A(F, {
1098
- key: 0,
1099
- onClick: a[5] || (a[5] = (e) => {
1100
- z.value = ["needs_approval", "approved"], l.value = "";
1101
- })
1102
- }, {
1103
- default: b(() => [...a[11] || (a[11] = [
1104
- Y("Reset filters", -1)
1105
- ])]),
1106
- _: 1
1107
- })) : Z("", !0),
1108
- f.selectedResource !== null ? (i(), A(F, {
1109
- key: 1,
1110
- onClick: a[6] || (a[6] = (e) => x("resetSelectedResource"))
1111
- }, {
1112
- default: b(() => [...a[12] || (a[12] = [
1113
- Y("Reset resource filter", -1)
1114
- ])]),
1115
- _: 1
1116
- })) : Z("", !0)
1117
- ])) : t(te).length === 0 ? (i(), M("div", pa, " No bookings match your search ")) : (i(), M("div", fa, [
1118
- (i(!0), M(ue, null, De(t(te), (e) => (i(), M("div", {
1119
- key: e.res_id || e.id,
1120
- class: "p-3 border rounded-lg hover:bg-muted/50 transition-colors cursor-pointer",
1121
- onClick: (m) => t(o)?.openDialog(e)
1122
- }, [
1123
- d("div", ga, [
1124
- d("div", ha, [
1125
- d("div", xa, $(e.customerInfo.firstName + " " + e.customerInfo.lastName || "Unknown Customer"), 1),
1126
- d("div", ya, $(e.customerInfo?.email), 1),
1127
- d("div", ba, $(e.customerInfo?.phone), 1),
1128
- d("div", ka, [
1129
- d("div", Da, [
1130
- c(t(Dt), { size: 12 }),
1131
- d("span", null, $(e.startTime) + " - " + $(e.endTime), 1)
1132
- ]),
1133
- d("div", _a, [
1134
- c(t(je), { size: 12 }),
1135
- d("span", null, $(e.spots) + " " + $(e.spots === 1 ? "spot" : "spots"), 1)
1136
- ]),
1137
- e.resourceName ? (i(), M("div", Sa, [
1138
- d("div", {
1139
- class: "w-3 h-3 rounded-full",
1140
- style: be({ backgroundColor: e.resourceColor || "#6b7280" })
1141
- }, null, 4),
1142
- d("span", null, $(e.resourceName), 1)
1143
- ])) : Z("", !0)
1144
- ]),
1145
- c(Tt, {
1146
- metadata: { ...e.metadata, ...e.reservationMetadata },
1147
- schema: t(_),
1148
- "display-filter": ["highlight", "badge"],
1149
- compact: "",
1150
- class: "mt-1"
1151
- }, null, 8, ["metadata", "schema"])
1152
- ]),
1153
- d("div", wa, [
1154
- e.reservationStatus === "needs_approval" ? (i(), M("span", Ca, "Needs Approval")) : e.reservationStatus === "approved" ? (i(), M("span", $a, "Approved")) : e.reservationStatus === "rejected" ? (i(), M("span", Ma, "Rejected")) : e.reservationStatus === "cancelled" ? (i(), M("span", Ra, "Cancelled")) : (i(), M("span", Va, "Pending")),
1155
- e.reservationPrice || e.reservationPrice === 0 ? (i(), M("div", Ta, " €" + $(e.reservationPrice.toFixed(2)), 1)) : Z("", !0)
1156
- ])
1157
- ])
1158
- ], 8, va))), 128))
1159
- ]))
1160
- ]),
1161
- _: 1
1162
- }),
1163
- c(It, {
1164
- ref_key: "reservationDetailDialog",
1165
- ref: o,
1166
- agendaData: f.agendaData,
1167
- resources: f.resources,
1168
- "show-order-link": "",
1169
- onCancelled: ee,
1170
- onConfirmed: ee,
1171
- onRejected: ee,
1172
- onTransferred: ee,
1173
- onOpenOrder: a[7] || (a[7] = (e) => ae(e))
1174
- }, null, 8, ["agendaData", "resources"]),
1175
- c(At, {
1176
- ref_key: "orderDetailDialog",
1177
- ref: u,
1178
- agendaData: f.agendaData,
1179
- resources: f.resources,
1180
- onOpenReservation: a[8] || (a[8] = (e) => ce(e))
1181
- }, null, 8, ["agendaData", "resources"])
1182
- ]),
1183
- _: 1
1184
- });
1185
- };
1186
- }
1187
- }), Aa = { class: "space-y-6" }, Ea = { class: "flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4" }, za = { class: "text-2xl font-semibold tracking-tight" }, Oa = { class: "flex flex-col md:flex-row gap-2" }, Pa = { class: "grid gap-6 md:grid-cols-2 lg:grid-cols-3" }, ja = { class: "md:col-span-2 lg:col-span-3" }, Ja = /* @__PURE__ */ ve({
1188
- __name: "index",
1189
- setup(f) {
1190
- const { hasPermission: h } = at(), { params: s, resolvePath: x } = $e(), { config: v } = Me(), y = Re(v.project), k = j(""), r = j(!0), n = j(/* @__PURE__ */ new Date()), l = j(null), o = j("stacked"), u = j(null), V = j([]);
1191
- return (async () => {
1192
- try {
1193
- const O = await y.get(v.agendaCollection, s.value.id);
1194
- k.value = O?.serviceName || "", u.value = O, V.value = O?.resources?.filter((T) => T.isActive) || [];
1195
- } catch (O) {
1196
- console.error("Error loading data:", O);
1197
- } finally {
1198
- r.value = !1;
1199
- }
1200
- })(), (O, T) => (i(), A(st, null, {
1201
- default: b(() => [
1202
- d("div", Aa, [
1203
- d("div", Ea, [
1204
- d("div", null, [
1205
- d("h1", za, $(t(k) || "Dashboard"), 1),
1206
- T[4] || (T[4] = d("p", { class: "text-muted-foreground text-sm mt-1" }, " Overview and analytics for your booking service ", -1))
1207
- ]),
1208
- d("div", Oa, [
1209
- t(h)("manage-reservations") ? (i(), A(Et, {
1210
- key: 0,
1211
- "agenda-data": t(u)
1212
- }, null, 8, ["agenda-data"])) : Z("", !0)
1213
- ])
1214
- ]),
1215
- c(ra, {
1216
- modelValue: t(n),
1217
- "onUpdate:modelValue": T[0] || (T[0] = (J) => ne(n) ? n.value = J : null),
1218
- "view-mode": t(o),
1219
- "onUpdate:viewMode": T[1] || (T[1] = (J) => ne(o) ? o.value = J : null),
1220
- "selected-resource": t(l),
1221
- "onUpdate:selectedResource": T[2] || (T[2] = (J) => ne(l) ? l.value = J : null),
1222
- "agenda-data": t(u),
1223
- resources: t(V)
1224
- }, null, 8, ["modelValue", "view-mode", "selected-resource", "agenda-data", "resources"]),
1225
- d("div", Pa, [
1226
- d("div", ja, [
1227
- t(V).length > 0 ? (i(), A(Ia, {
1228
- key: 0,
1229
- "agenda-data": t(u),
1230
- "active-date": t(n),
1231
- "selected-resource": t(l),
1232
- resources: t(V),
1233
- onResetSelectedResource: T[3] || (T[3] = (J) => l.value = null)
1234
- }, null, 8, ["agenda-data", "active-date", "selected-resource", "resources"])) : Z("", !0)
1235
- ])
1236
- ])
1237
- ])
1238
- ]),
1239
- _: 1
1240
- }));
1241
- }
1242
- });
1243
- export {
1244
- Ja as default
1245
- };