@oneclick.dev/cms-core-modules 0.0.102 → 0.0.104

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