@oneclick.dev/cms-core-modules 0.0.110 → 0.0.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Acquisition-Dt2rREU8.js → Acquisition-DgzDQH51.js} +1 -1
- package/dist/{Acquisition-DNCy8nQz.mjs → Acquisition-FV3QpaUX.mjs} +2 -2
- package/dist/{Audience-Bs7b0TNm.js → Audience-BSgNvcVb.js} +1 -1
- package/dist/{Audience-CUeMVYRy.mjs → Audience-ka0b7YPE.mjs} +2 -2
- package/dist/{ContentEditor-D9-1SJ5F.mjs → ContentEditor-pZPfo0qN.mjs} +4384 -4282
- package/dist/{ContentEditor-BprPiHMJ.js → ContentEditor-tYkh4vRV.js} +42 -42
- package/dist/{Create-89z41K73.js → Create--MOBOTA-.js} +1 -1
- package/dist/{Create-BCklc_T1.mjs → Create-BXNLRQag.mjs} +1 -1
- package/dist/DateFormatter-CSAbE3BC.js +1 -0
- package/dist/{DateFormatter-DUxlo8X8.mjs → DateFormatter-qbhRYxI_.mjs} +226 -222
- package/dist/{Detail-CNlljBfH.mjs → Detail-ChD5XurA.mjs} +1 -1
- package/dist/{Detail-C857g62L.js → Detail-RISEJJab.js} +1 -1
- package/dist/{Find-DIISO5GO.mjs → Find-zN_dKz4p.mjs} +1 -1
- package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-Baqy-rTT.js +1 -0
- package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-Dx4Bpa2m.mjs +1263 -0
- package/dist/{Overview-Di84CsR5.mjs → Overview-98nkJUWN.mjs} +162 -157
- package/dist/{Overview-C-Jb_BxY.mjs → Overview-BR_y8x3W.mjs} +1 -1
- package/dist/{Overview-DC9io1bk.js → Overview-CX-n6W7d.js} +1 -1
- package/dist/Overview-Dl8cMlsr.js +1 -0
- package/dist/{Overview-BKAti8nc.mjs → Overview-MpgkLB6m.mjs} +36 -36
- package/dist/{SeoHealth-az1YuNF2.js → SeoHealth-C5npw7mE.js} +1 -1
- package/dist/{SeoHealth-MC3lSCOY.mjs → SeoHealth-bVQj_Xgm.mjs} +29 -29
- package/dist/{TableView-DXHhJ-jm.mjs → TableView-Bf1fdJrD.mjs} +1838 -1822
- package/dist/TableView-DNcXyIMu.js +4 -0
- package/dist/{agenda-IOqtALWf.js → agenda-BaJu3-1c.js} +1 -1
- package/dist/{agenda-DcatSSYQ.mjs → agenda-BwVY_8oM.mjs} +3 -3
- package/dist/cms-core-modules.css +1 -1
- package/dist/{exceptions-CI0B4xVj.js → exceptions-B6P9UiCj.js} +1 -1
- package/dist/{exceptions-YCQkHa6a.mjs → exceptions-De9-FvdP.mjs} +67 -67
- package/dist/{index-CpzDEMeC.mjs → index-B8GvmAwh.mjs} +438 -478
- package/dist/{index-wjkEPsNx.mjs → index-BIF2RB7k.mjs} +1212 -1316
- package/dist/index-ByRsp77L.js +70 -0
- package/dist/{index-BhWvXMOp.mjs → index-CFzn2Lus.mjs} +5 -9
- package/dist/{index-BFLV54kw.mjs → index-CkVwMqpn.mjs} +1114 -1100
- package/dist/index-DL6orwdK.js +35 -0
- package/dist/index-DUlYrnXH.js +58 -0
- package/dist/index-DZV720u-.mjs +439 -0
- package/dist/index-D_nfGegA.js +184 -0
- package/dist/index-DtSvAFLL.js +54 -0
- package/dist/{index-D30apIn-.mjs → index-L54VBzwJ.mjs} +2 -3
- package/dist/{index-BzWmWCo5.mjs → index-hH3e-IYz.mjs} +267 -267
- package/dist/index.cjs.js +1 -1
- package/dist/index.mjs +15 -15
- package/dist/math-BJ-oX_IM.mjs +80 -0
- package/dist/math-emotyaF6.js +1 -0
- package/dist/{resources-CYOb5Bl6.mjs → resources-DwYxn2Vi.mjs} +1 -1
- package/dist/src/contentManager/components/content-editor/tiptap-extensions/ScopedSelectAll.d.ts +1 -2
- package/dist/src/contentManager/components/content-editor/tiptap-extensions/helpers/useFocus.d.ts +1 -0
- package/package.json +2 -2
- package/dist/DateFormatter-CYAD4GBN.js +0 -1
- package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-Ceoje52V.js +0 -1
- package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-Dh9jzvE0.mjs +0 -1255
- package/dist/Overview-UoZHUMUz.js +0 -1
- package/dist/TableView-DQW0A1oG.js +0 -4
- package/dist/array-CbATeQbk.js +0 -1
- package/dist/array-DT5pE8Gm.mjs +0 -108
- package/dist/index-A2kp8Isi.js +0 -75
- package/dist/index-B5aBwdxY.js +0 -54
- package/dist/index-BiT55eU0.js +0 -58
- package/dist/index-G7cIlnGN.js +0 -158
- package/dist/index-V78huaSJ.mjs +0 -442
- package/dist/index-vHmvbEwa.js +0 -35
|
@@ -0,0 +1,1263 @@
|
|
|
1
|
+
import { defineComponent as ue, ref as F, reactive as $e, computed as Z, watch as de, resolveComponent as y, openBlock as i, createElementBlock as p, createElementVNode as c, Fragment as Y, renderList as ee, normalizeClass as re, createVNode as a, withCtx as u, createTextVNode as R, toDisplayString as T, createCommentVNode as B, createBlock as ae, onMounted as be, onBeforeUnmount as we, nextTick as ye, unref as d, isRef as me, markRaw as Te, inject as Re } from "vue";
|
|
2
|
+
import { CalendarIcon as De, ChevronLeft as Ie, Check as Ce, ChevronRight as Ne, X as Ve, Zap as Le, Plus as xe, Pencil as Oe, Users as Fe, Tag as Pe, Trash2 as ge } from "lucide-vue-next";
|
|
3
|
+
import { useModuleRoute as Ee, useModule as Me, useFirebaseIntegration as Ue } from "@oneclick.dev/cms-kit";
|
|
4
|
+
import { c as fe } from "./utils-CanmrIWO.mjs";
|
|
5
|
+
import { e as Ae, a as _e, $ as ve } from "./DateFormatter-qbhRYxI_.mjs";
|
|
6
|
+
import { _ as Se } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
|
|
7
|
+
const ze = { class: "space-y-3" }, qe = { class: "grid gap-4 @md/modal:grid-cols-2 @2xl/modal:grid-cols-3 @4xl/modal:grid-cols-4 overflow-hidden p-1" }, je = {
|
|
8
|
+
key: 0,
|
|
9
|
+
class: "flex items-center gap-3 min-h-9"
|
|
10
|
+
}, Be = {
|
|
11
|
+
key: 0,
|
|
12
|
+
class: "italic text-xs opacity-50"
|
|
13
|
+
}, He = {
|
|
14
|
+
key: 0,
|
|
15
|
+
class: "italic text-xs opacity-50"
|
|
16
|
+
}, Qe = {
|
|
17
|
+
key: 0,
|
|
18
|
+
class: "italic text-xs opacity-50"
|
|
19
|
+
}, Ye = {
|
|
20
|
+
key: 0,
|
|
21
|
+
class: "italic text-xs opacity-50"
|
|
22
|
+
}, Ge = {
|
|
23
|
+
key: 0,
|
|
24
|
+
class: "text-red-400"
|
|
25
|
+
}, Xe = { class: "list-disc pl-4" }, We = /* @__PURE__ */ ue({
|
|
26
|
+
__name: "CustomerInformation",
|
|
27
|
+
props: {
|
|
28
|
+
agendaData: {}
|
|
29
|
+
},
|
|
30
|
+
setup(L, { expose: z }) {
|
|
31
|
+
const N = [
|
|
32
|
+
{
|
|
33
|
+
id: "firstName",
|
|
34
|
+
fieldName: "First Name",
|
|
35
|
+
fieldType: "text",
|
|
36
|
+
required: !0,
|
|
37
|
+
visible: !0
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "lastName",
|
|
41
|
+
fieldName: "Last Name",
|
|
42
|
+
fieldType: "text",
|
|
43
|
+
required: !0,
|
|
44
|
+
visible: !0
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: "phone",
|
|
48
|
+
fieldName: "Phone No",
|
|
49
|
+
fieldType: "tel",
|
|
50
|
+
required: !0,
|
|
51
|
+
visible: !0
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "email",
|
|
55
|
+
fieldName: "Email",
|
|
56
|
+
fieldType: "email",
|
|
57
|
+
required: !0,
|
|
58
|
+
visible: !0
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "birthdate",
|
|
62
|
+
fieldName: "Birthdate",
|
|
63
|
+
fieldType: "date",
|
|
64
|
+
required: !0,
|
|
65
|
+
visible: !0
|
|
66
|
+
}
|
|
67
|
+
], E = /* @__PURE__ */ new Set(["firstName", "email"]), q = L, M = F([]), S = $e({}), U = Z(() => {
|
|
68
|
+
const m = q.agendaData?.customerInformationFields, h = (Array.isArray(m) && m.length > 0 ? m : N).filter((C) => C?.id && (C.visible !== !1 || E.has(C.id))).map((C) => ({
|
|
69
|
+
...C,
|
|
70
|
+
required: E.has(C.id),
|
|
71
|
+
visible: !0
|
|
72
|
+
})), $ = N.filter((C) => E.has(C.id) && !h.some((W) => W.id === C.id)).map((C) => ({
|
|
73
|
+
...C,
|
|
74
|
+
required: !0,
|
|
75
|
+
visible: !0
|
|
76
|
+
}));
|
|
77
|
+
return [...h, ...$];
|
|
78
|
+
}), V = (m) => m.fieldName || m.id, O = (m) => m.replace(/[^A-Za-z0-9_-]/g, "-"), k = (m, D) => ["new-res-customer-info", m.id, D].filter(Boolean).map(($) => O($)).join("-"), w = (m) => m.fieldType === "email" || m.fieldType === "tel" || m.fieldType === "date" ? m.fieldType : "text", j = (m) => Array.isArray(m.options) ? m.options.filter(Boolean) : [], H = (m) => m.fieldType === "checkbox" ? !1 : "", x = (m = !1) => {
|
|
79
|
+
const D = new Set(U.value.map((h) => h.id));
|
|
80
|
+
Object.keys(S).forEach((h) => {
|
|
81
|
+
D.has(h) || delete S[h];
|
|
82
|
+
}), U.value.forEach((h) => {
|
|
83
|
+
const $ = H(h);
|
|
84
|
+
(m || S[h.id] === void 0 || typeof S[h.id] != typeof $) && (S[h.id] = $);
|
|
85
|
+
});
|
|
86
|
+
}, Q = () => {
|
|
87
|
+
const m = U.value.reduce((D, h) => {
|
|
88
|
+
const $ = S[h.id];
|
|
89
|
+
return D[h.id] = typeof $ == "string" ? $.trim() : !!$, D;
|
|
90
|
+
}, {});
|
|
91
|
+
return Object.entries(m).forEach(([D, h]) => {
|
|
92
|
+
S[D] = h;
|
|
93
|
+
}), m;
|
|
94
|
+
}, G = (m, D) => m.fieldType === "checkbox" ? D === !0 : typeof D == "string" ? D.trim().length > 0 : D != null, te = () => {
|
|
95
|
+
M.value = [], x(!0);
|
|
96
|
+
}, A = () => {
|
|
97
|
+
const m = [], D = Q();
|
|
98
|
+
return U.value.forEach((h) => {
|
|
99
|
+
const $ = D[h.id], C = V(h);
|
|
100
|
+
h.required && !G(h, $) && m.push(`Please fill in ${C}.`), h.fieldType === "email" && G(h, $) && typeof $ == "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test($) === !1 && m.push(`Please fill in a correct ${C}.`);
|
|
101
|
+
}), M.value = m, m.length === 0;
|
|
102
|
+
};
|
|
103
|
+
return de(U, () => {
|
|
104
|
+
x();
|
|
105
|
+
}, { immediate: !0 }), z({
|
|
106
|
+
getCustomerInfo: Q,
|
|
107
|
+
reset: te,
|
|
108
|
+
validateForm: A
|
|
109
|
+
}), (m, D) => {
|
|
110
|
+
const h = y("Checkbox"), $ = y("Label"), C = y("SelectValue"), W = y("SelectTrigger"), J = y("SelectItem"), se = y("SelectGroup"), oe = y("SelectContent"), K = y("Select"), r = y("RadioGroupItem"), o = y("RadioGroup"), f = y("Input");
|
|
111
|
+
return i(), p("div", ze, [
|
|
112
|
+
D[0] || (D[0] = c("h2", { class: "text-sm font-medium" }, "Customer Information", -1)),
|
|
113
|
+
c("div", qe, [
|
|
114
|
+
(i(!0), p(Y, null, ee(U.value, (e) => (i(), p("div", {
|
|
115
|
+
key: e.id,
|
|
116
|
+
class: re(["grid gap-2", e.fieldType === "checkbox" ? "@md/modal:col-span-2" : ""])
|
|
117
|
+
}, [
|
|
118
|
+
e.fieldType === "checkbox" ? (i(), p("div", je, [
|
|
119
|
+
a(h, {
|
|
120
|
+
id: k(e),
|
|
121
|
+
modelValue: S[e.id],
|
|
122
|
+
"onUpdate:modelValue": (n) => S[e.id] = n
|
|
123
|
+
}, null, 8, ["id", "modelValue", "onUpdate:modelValue"]),
|
|
124
|
+
a($, {
|
|
125
|
+
for: k(e),
|
|
126
|
+
class: "font-normal cursor-pointer"
|
|
127
|
+
}, {
|
|
128
|
+
default: u(() => [
|
|
129
|
+
R(T(V(e)) + " ", 1),
|
|
130
|
+
e.required ? B("", !0) : (i(), p("span", Be, "optional"))
|
|
131
|
+
]),
|
|
132
|
+
_: 2
|
|
133
|
+
}, 1032, ["for"])
|
|
134
|
+
])) : e.fieldType === "select" ? (i(), p(Y, { key: 1 }, [
|
|
135
|
+
a($, {
|
|
136
|
+
for: k(e)
|
|
137
|
+
}, {
|
|
138
|
+
default: u(() => [
|
|
139
|
+
R(T(V(e)) + " ", 1),
|
|
140
|
+
e.required ? B("", !0) : (i(), p("span", He, "optional"))
|
|
141
|
+
]),
|
|
142
|
+
_: 2
|
|
143
|
+
}, 1032, ["for"]),
|
|
144
|
+
a(K, {
|
|
145
|
+
modelValue: S[e.id],
|
|
146
|
+
"onUpdate:modelValue": (n) => S[e.id] = n
|
|
147
|
+
}, {
|
|
148
|
+
default: u(() => [
|
|
149
|
+
a(W, {
|
|
150
|
+
id: k(e),
|
|
151
|
+
class: "w-full"
|
|
152
|
+
}, {
|
|
153
|
+
default: u(() => [
|
|
154
|
+
a(C, {
|
|
155
|
+
placeholder: `Select ${V(e)}`
|
|
156
|
+
}, null, 8, ["placeholder"])
|
|
157
|
+
]),
|
|
158
|
+
_: 2
|
|
159
|
+
}, 1032, ["id"]),
|
|
160
|
+
a(oe, null, {
|
|
161
|
+
default: u(() => [
|
|
162
|
+
a(se, null, {
|
|
163
|
+
default: u(() => [
|
|
164
|
+
(i(!0), p(Y, null, ee(j(e), (n) => (i(), ae(J, {
|
|
165
|
+
key: n,
|
|
166
|
+
value: n
|
|
167
|
+
}, {
|
|
168
|
+
default: u(() => [
|
|
169
|
+
R(T(n), 1)
|
|
170
|
+
]),
|
|
171
|
+
_: 2
|
|
172
|
+
}, 1032, ["value"]))), 128))
|
|
173
|
+
]),
|
|
174
|
+
_: 2
|
|
175
|
+
}, 1024)
|
|
176
|
+
]),
|
|
177
|
+
_: 2
|
|
178
|
+
}, 1024)
|
|
179
|
+
]),
|
|
180
|
+
_: 2
|
|
181
|
+
}, 1032, ["modelValue", "onUpdate:modelValue"])
|
|
182
|
+
], 64)) : e.fieldType === "radio" ? (i(), p(Y, { key: 2 }, [
|
|
183
|
+
a($, null, {
|
|
184
|
+
default: u(() => [
|
|
185
|
+
R(T(V(e)) + " ", 1),
|
|
186
|
+
e.required ? B("", !0) : (i(), p("span", Qe, "optional"))
|
|
187
|
+
]),
|
|
188
|
+
_: 2
|
|
189
|
+
}, 1024),
|
|
190
|
+
a(o, {
|
|
191
|
+
modelValue: S[e.id],
|
|
192
|
+
"onUpdate:modelValue": (n) => S[e.id] = n,
|
|
193
|
+
class: "grid gap-2"
|
|
194
|
+
}, {
|
|
195
|
+
default: u(() => [
|
|
196
|
+
(i(!0), p(Y, null, ee(j(e), (n) => (i(), p("div", {
|
|
197
|
+
key: n,
|
|
198
|
+
class: "flex items-center gap-2"
|
|
199
|
+
}, [
|
|
200
|
+
a(r, {
|
|
201
|
+
id: k(e, n),
|
|
202
|
+
value: n
|
|
203
|
+
}, null, 8, ["id", "value"]),
|
|
204
|
+
a($, {
|
|
205
|
+
for: k(e, n),
|
|
206
|
+
class: "font-normal cursor-pointer"
|
|
207
|
+
}, {
|
|
208
|
+
default: u(() => [
|
|
209
|
+
R(T(n), 1)
|
|
210
|
+
]),
|
|
211
|
+
_: 2
|
|
212
|
+
}, 1032, ["for"])
|
|
213
|
+
]))), 128))
|
|
214
|
+
]),
|
|
215
|
+
_: 2
|
|
216
|
+
}, 1032, ["modelValue", "onUpdate:modelValue"])
|
|
217
|
+
], 64)) : (i(), p(Y, { key: 3 }, [
|
|
218
|
+
a($, {
|
|
219
|
+
for: k(e)
|
|
220
|
+
}, {
|
|
221
|
+
default: u(() => [
|
|
222
|
+
R(T(V(e)) + " ", 1),
|
|
223
|
+
e.required ? B("", !0) : (i(), p("span", Ye, "optional"))
|
|
224
|
+
]),
|
|
225
|
+
_: 2
|
|
226
|
+
}, 1032, ["for"]),
|
|
227
|
+
a(f, {
|
|
228
|
+
modelValue: S[e.id],
|
|
229
|
+
"onUpdate:modelValue": (n) => S[e.id] = n,
|
|
230
|
+
id: k(e),
|
|
231
|
+
type: w(e),
|
|
232
|
+
autocomplete: "off"
|
|
233
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "id", "type"])
|
|
234
|
+
], 64))
|
|
235
|
+
], 2))), 128))
|
|
236
|
+
]),
|
|
237
|
+
M.value.length > 0 ? (i(), p("div", Ge, [
|
|
238
|
+
c("ul", Xe, [
|
|
239
|
+
(i(!0), p(Y, null, ee(M.value, (e) => (i(), p("li", { key: e }, T(e), 1))), 128))
|
|
240
|
+
])
|
|
241
|
+
])) : B("", !0)
|
|
242
|
+
]);
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
function Ze(L = {}) {
|
|
247
|
+
const z = F(null), N = F(!1), E = F(!1), q = F(!1), M = F(!1), S = L.dragSpeed ?? 1.1, U = L.dragThreshold ?? 10, V = L.edgeThreshold ?? 10, O = L.ignoreDragSelector ?? 'input, select, textarea, [contenteditable="true"], [data-horizontal-scroll-ignore-drag]';
|
|
248
|
+
let k = null, w = 0, j = 0, H = !1, x = null, Q = null, G = null;
|
|
249
|
+
const te = () => {
|
|
250
|
+
x === null || typeof window > "u" || (window.clearTimeout(x), x = null);
|
|
251
|
+
}, A = () => {
|
|
252
|
+
const t = z.value;
|
|
253
|
+
if (!t) {
|
|
254
|
+
E.value = !1, q.value = !1, M.value = !1;
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const s = Math.max(t.scrollWidth - t.clientWidth, 0);
|
|
258
|
+
E.value = s > V, q.value = E.value && t.scrollLeft > V, M.value = E.value && t.scrollLeft < s - V;
|
|
259
|
+
}, m = () => {
|
|
260
|
+
ye(() => {
|
|
261
|
+
if (typeof window > "u") {
|
|
262
|
+
A();
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
window.requestAnimationFrame(() => A());
|
|
266
|
+
});
|
|
267
|
+
}, D = () => {
|
|
268
|
+
if (typeof L.scrollStep == "number") return L.scrollStep;
|
|
269
|
+
const t = z.value;
|
|
270
|
+
return t ? Math.max(Math.floor(t.clientWidth * 0.72), 180) : 240;
|
|
271
|
+
}, h = (t, s = "smooth") => {
|
|
272
|
+
const l = z.value;
|
|
273
|
+
if (l) {
|
|
274
|
+
if (l.scrollBy({ left: t, behavior: s }), s === "auto") {
|
|
275
|
+
A();
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
m();
|
|
279
|
+
}
|
|
280
|
+
}, $ = () => {
|
|
281
|
+
h(-D());
|
|
282
|
+
}, C = () => {
|
|
283
|
+
h(D());
|
|
284
|
+
}, W = () => {
|
|
285
|
+
const t = z.value;
|
|
286
|
+
k !== null && t?.hasPointerCapture?.(k) && t.releasePointerCapture(k), N.value && (H = !0, te(), typeof window < "u" && (x = window.setTimeout(() => {
|
|
287
|
+
H = !1, x = null;
|
|
288
|
+
}, 0))), k = null, N.value = !1, t && (t.style.userSelect = "", t.style.cursor = ""), A();
|
|
289
|
+
}, J = () => {
|
|
290
|
+
A();
|
|
291
|
+
}, se = (t) => {
|
|
292
|
+
const s = z.value;
|
|
293
|
+
if (!s || !E.value || Math.abs(t.deltaY) <= Math.abs(t.deltaX)) return;
|
|
294
|
+
const l = t.deltaY < 0, P = t.deltaY > 0;
|
|
295
|
+
l && !q.value || P && !M.value || (t.preventDefault(), s.scrollLeft += t.deltaY, A());
|
|
296
|
+
}, oe = (t) => t instanceof Element ? !!t.closest(O) : !1, K = (t) => {
|
|
297
|
+
const s = z.value;
|
|
298
|
+
!s || !E.value || t.pointerType !== "touch" && t.button === 0 && (oe(t.target) || (k = t.pointerId, w = t.clientX, j = s.scrollLeft, H = !1));
|
|
299
|
+
}, r = (t) => {
|
|
300
|
+
const s = z.value;
|
|
301
|
+
if (!s || k !== t.pointerId) return;
|
|
302
|
+
const l = t.clientX - w;
|
|
303
|
+
!N.value && Math.abs(l) < U || (N.value || (N.value = !0, s.style.userSelect = "none", s.style.cursor = "grabbing", s.setPointerCapture?.(t.pointerId)), t.preventDefault(), s.scrollLeft = j - l * S, A());
|
|
304
|
+
}, o = (t) => {
|
|
305
|
+
k === t.pointerId && W();
|
|
306
|
+
}, f = () => {
|
|
307
|
+
k !== null && W();
|
|
308
|
+
}, e = (t) => {
|
|
309
|
+
H && (t.preventDefault(), t.stopPropagation(), H = !1);
|
|
310
|
+
}, n = (t) => {
|
|
311
|
+
typeof ResizeObserver < "u" && (Q = new ResizeObserver(() => A()), Q.observe(t)), L.observeMutations !== !1 && typeof MutationObserver < "u" && (G = new MutationObserver(() => m()), G.observe(t, {
|
|
312
|
+
childList: !0,
|
|
313
|
+
subtree: !0,
|
|
314
|
+
characterData: !0
|
|
315
|
+
}));
|
|
316
|
+
}, b = () => {
|
|
317
|
+
Q?.disconnect(), G?.disconnect(), Q = null, G = null;
|
|
318
|
+
}, v = (t) => {
|
|
319
|
+
t.addEventListener("scroll", J), t.addEventListener("wheel", se, { passive: !1 }), t.addEventListener("pointerdown", K), t.addEventListener("pointermove", r), t.addEventListener("pointerup", o), t.addEventListener("pointercancel", f), t.addEventListener("lostpointercapture", f), t.addEventListener("click", e, !0), n(t), m();
|
|
320
|
+
}, g = (t) => {
|
|
321
|
+
t.removeEventListener("scroll", J), t.removeEventListener("wheel", se), t.removeEventListener("pointerdown", K), t.removeEventListener("pointermove", r), t.removeEventListener("pointerup", o), t.removeEventListener("pointercancel", f), t.removeEventListener("lostpointercapture", f), t.removeEventListener("click", e, !0), b();
|
|
322
|
+
};
|
|
323
|
+
return de(z, (t, s) => {
|
|
324
|
+
s && g(s), t ? v(t) : A();
|
|
325
|
+
}), be(() => {
|
|
326
|
+
m();
|
|
327
|
+
}), we(() => {
|
|
328
|
+
te(), z.value && g(z.value), H = !1, W();
|
|
329
|
+
}), {
|
|
330
|
+
canScrollLeft: Z(() => q.value),
|
|
331
|
+
canScrollRight: Z(() => M.value),
|
|
332
|
+
containerRef: z,
|
|
333
|
+
isDragging: N,
|
|
334
|
+
isScrollable: E,
|
|
335
|
+
refresh: m,
|
|
336
|
+
scrollNext: C,
|
|
337
|
+
scrollPrev: $,
|
|
338
|
+
showLeftShadow: q,
|
|
339
|
+
showRightShadow: M
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
const Je = { class: "flex items-start justify-between gap-3" }, Ke = { class: "text-sm font-medium" }, et = {
|
|
343
|
+
key: 0,
|
|
344
|
+
class: "mt-1 text-xs text-muted-foreground"
|
|
345
|
+
}, tt = { class: "grid gap-4 @md/quick-adder:grid-cols-2 @2xl/quick-adder:grid-cols-3 @4xl/quick-adder:grid-cols-4" }, nt = { class: "grid gap-2" }, st = {
|
|
346
|
+
key: 0,
|
|
347
|
+
class: "grid gap-2"
|
|
348
|
+
}, ot = {
|
|
349
|
+
key: 1,
|
|
350
|
+
class: "grid gap-2"
|
|
351
|
+
}, at = {
|
|
352
|
+
key: 2,
|
|
353
|
+
class: "grid gap-2"
|
|
354
|
+
}, rt = { class: "grid gap-2" }, lt = {
|
|
355
|
+
key: 0,
|
|
356
|
+
class: "rounded-md border border-dashed bg-muted/20 px-4 py-4 text-sm text-muted-foreground"
|
|
357
|
+
}, it = {
|
|
358
|
+
key: 1,
|
|
359
|
+
class: "relative flex items-center gap-2 overflow-hidden"
|
|
360
|
+
}, ut = { class: "relative min-w-0 flex-1 overflow-hidden" }, dt = {
|
|
361
|
+
key: 0,
|
|
362
|
+
class: "pointer-events-none absolute inset-y-0 left-0 z-10 w-10 md:w-20 bg-gradient-to-r from-background via-background/95 to-transparent"
|
|
363
|
+
}, ct = {
|
|
364
|
+
key: 1,
|
|
365
|
+
class: "pointer-events-none absolute inset-y-0 right-0 z-10 w-10 md:w-20 bg-gradient-to-l from-background via-background/95 to-transparent"
|
|
366
|
+
}, pt = {
|
|
367
|
+
key: 0,
|
|
368
|
+
class: "absolute -top-1 -right-1 flex items-center justify-center bg-primary rounded-full text-background size-4"
|
|
369
|
+
}, mt = { class: "flex flex-wrap gap-2" }, ft = ["onClick"], vt = { key: 0 }, gt = { key: 1 }, _t = { key: 2 }, ht = /* @__PURE__ */ ue({
|
|
370
|
+
__name: "QuickReservationAdder",
|
|
371
|
+
props: {
|
|
372
|
+
agendaData: {},
|
|
373
|
+
surface: { default: "card" }
|
|
374
|
+
},
|
|
375
|
+
emits: ["add"],
|
|
376
|
+
setup(L, { emit: z }) {
|
|
377
|
+
const N = L, E = z, q = new Ae("en-US", {
|
|
378
|
+
dateStyle: "long"
|
|
379
|
+
}), M = _e(ve()), S = Z(() => N.surface === "popover"), U = F(""), V = F(void 0), O = F(""), k = F(""), w = F([]), j = F(1), H = Z(() => N.agendaData?.resources?.find((g) => g.id === O.value)), x = (g) => {
|
|
380
|
+
const [t, s] = g.split(":").map(Number);
|
|
381
|
+
return t * 60 + s;
|
|
382
|
+
}, Q = (g) => {
|
|
383
|
+
const t = Math.floor(g / 60), s = g % 60;
|
|
384
|
+
return `${t.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`;
|
|
385
|
+
}, G = () => {
|
|
386
|
+
if (!H.value) return [];
|
|
387
|
+
const g = H.value.interval || 60;
|
|
388
|
+
let t = null, s = null;
|
|
389
|
+
for (const P of Object.values(H.value.openingHours || {}))
|
|
390
|
+
for (const _ of P) {
|
|
391
|
+
const X = x(_.start), ne = x(_.end);
|
|
392
|
+
(t === null || X < t) && (t = X), (s === null || ne > s) && (s = ne);
|
|
393
|
+
}
|
|
394
|
+
if (t === null || s === null) return [];
|
|
395
|
+
const l = [];
|
|
396
|
+
for (let P = t; P < s; P += g)
|
|
397
|
+
l.push(Q(P));
|
|
398
|
+
return l;
|
|
399
|
+
}, te = Z(() => V.value && O.value && k.value && w.value.length > 0), A = Z(() => G()), {
|
|
400
|
+
canScrollLeft: m,
|
|
401
|
+
canScrollRight: D,
|
|
402
|
+
containerRef: h,
|
|
403
|
+
isDragging: $,
|
|
404
|
+
isScrollable: C,
|
|
405
|
+
scrollNext: W,
|
|
406
|
+
scrollPrev: J,
|
|
407
|
+
showLeftShadow: se,
|
|
408
|
+
showRightShadow: oe
|
|
409
|
+
} = Ze(), K = (g) => w.value.includes(g), r = (g) => {
|
|
410
|
+
if (K(g)) {
|
|
411
|
+
w.value = w.value.filter((t) => t !== g);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
w.value = [...w.value, g].sort((t, s) => x(t) - x(s));
|
|
415
|
+
}, o = (g, t) => {
|
|
416
|
+
V.value = g ? Te(g) : void 0, U.value = g ? `${g}` : "", t();
|
|
417
|
+
}, f = F(""), e = F(""), n = F([]), b = () => {
|
|
418
|
+
E("add", {
|
|
419
|
+
date: V.value,
|
|
420
|
+
resourceId: O.value,
|
|
421
|
+
pricingOptionId: k.value,
|
|
422
|
+
startTimes: w.value,
|
|
423
|
+
spots: j.value
|
|
424
|
+
}), w.value = [], n.value = [], e.value = "", f.value = "";
|
|
425
|
+
}, v = () => {
|
|
426
|
+
U.value = M.toString(), V.value = M, O.value = N.agendaData?.resources?.[0]?.id || "", k.value = N.agendaData?.pricingOptions?.find((g) => g.isDefault)?.id || N.agendaData?.pricingOptions?.[0]?.id || "", w.value = [], j.value = 1, f.value = "";
|
|
427
|
+
};
|
|
428
|
+
return be(() => {
|
|
429
|
+
v();
|
|
430
|
+
}), (g, t) => {
|
|
431
|
+
const s = y("Label"), l = y("Button"), P = y("PopoverTrigger"), _ = y("Calendar"), X = y("PopoverContent"), ne = y("Popover"), le = y("DynamicSelectOption"), ie = y("DynamicSelect"), ke = y("Input");
|
|
432
|
+
return i(), p("div", {
|
|
433
|
+
class: re(d(fe)(
|
|
434
|
+
"@container/quick-adder grid gap-4 overflow-hidden bg-background",
|
|
435
|
+
d(S) ? "p-5 sm:p-6" : "rounded-md border p-4"
|
|
436
|
+
))
|
|
437
|
+
}, [
|
|
438
|
+
c("div", Je, [
|
|
439
|
+
c("div", null, [
|
|
440
|
+
c("h3", Ke, T(d(S) ? "Quick add reservations" : "Add reservations"), 1),
|
|
441
|
+
d(S) ? (i(), p("p", et, " Choose one date and add multiple timeslots in one pass. ")) : B("", !0)
|
|
442
|
+
])
|
|
443
|
+
]),
|
|
444
|
+
c("div", tt, [
|
|
445
|
+
c("div", nt, [
|
|
446
|
+
a(s, null, {
|
|
447
|
+
default: u(() => [...t[3] || (t[3] = [
|
|
448
|
+
R("Date", -1)
|
|
449
|
+
])]),
|
|
450
|
+
_: 1
|
|
451
|
+
}),
|
|
452
|
+
a(ne, null, {
|
|
453
|
+
default: u(({ close: I }) => [
|
|
454
|
+
a(P, { "as-child": "" }, {
|
|
455
|
+
default: u(() => [
|
|
456
|
+
a(l, {
|
|
457
|
+
type: "button",
|
|
458
|
+
variant: "outline",
|
|
459
|
+
class: re(d(fe)("w-full justify-start text-left font-normal", !d(V) && "text-muted-foreground"))
|
|
460
|
+
}, {
|
|
461
|
+
default: u(() => [
|
|
462
|
+
a(d(De)),
|
|
463
|
+
R(" " + T(d(V) ? d(q).format(d(V).toDate(d(ve)())) : "Pick a date"), 1)
|
|
464
|
+
]),
|
|
465
|
+
_: 1
|
|
466
|
+
}, 8, ["class"])
|
|
467
|
+
]),
|
|
468
|
+
_: 1
|
|
469
|
+
}),
|
|
470
|
+
a(X, {
|
|
471
|
+
class: "w-auto p-0",
|
|
472
|
+
align: "start"
|
|
473
|
+
}, {
|
|
474
|
+
default: u(() => [
|
|
475
|
+
a(_, {
|
|
476
|
+
"model-value": d(V),
|
|
477
|
+
"default-placeholder": d(M),
|
|
478
|
+
layout: "month-and-year",
|
|
479
|
+
"initial-focus": "",
|
|
480
|
+
"onUpdate:modelValue": (ce) => o(ce, I),
|
|
481
|
+
minValue: d(_e)(d(ve)())
|
|
482
|
+
}, null, 8, ["model-value", "default-placeholder", "onUpdate:modelValue", "minValue"])
|
|
483
|
+
]),
|
|
484
|
+
_: 2
|
|
485
|
+
}, 1024)
|
|
486
|
+
]),
|
|
487
|
+
_: 1
|
|
488
|
+
})
|
|
489
|
+
]),
|
|
490
|
+
L.agendaData.resources?.length > 1 ? (i(), p("div", st, [
|
|
491
|
+
a(s, null, {
|
|
492
|
+
default: u(() => [...t[4] || (t[4] = [
|
|
493
|
+
R("Resource", -1)
|
|
494
|
+
])]),
|
|
495
|
+
_: 1
|
|
496
|
+
}),
|
|
497
|
+
a(ie, {
|
|
498
|
+
modelValue: d(O),
|
|
499
|
+
"onUpdate:modelValue": t[0] || (t[0] = (I) => me(O) ? O.value = I : null),
|
|
500
|
+
"wrapper-class": "w-full",
|
|
501
|
+
class: "w-full",
|
|
502
|
+
placeholder: "Select resource"
|
|
503
|
+
}, {
|
|
504
|
+
default: u(() => [
|
|
505
|
+
(i(!0), p(Y, null, ee(L.agendaData.resources || [], (I) => (i(), ae(le, {
|
|
506
|
+
key: I.id,
|
|
507
|
+
value: I.id
|
|
508
|
+
}, {
|
|
509
|
+
default: u(() => [
|
|
510
|
+
R(T(I.name), 1)
|
|
511
|
+
]),
|
|
512
|
+
_: 2
|
|
513
|
+
}, 1032, ["value"]))), 128))
|
|
514
|
+
]),
|
|
515
|
+
_: 1
|
|
516
|
+
}, 8, ["modelValue"])
|
|
517
|
+
])) : B("", !0),
|
|
518
|
+
L.agendaData.pricingOptions?.length > 1 ? (i(), p("div", ot, [
|
|
519
|
+
a(s, null, {
|
|
520
|
+
default: u(() => [...t[5] || (t[5] = [
|
|
521
|
+
R("Type", -1)
|
|
522
|
+
])]),
|
|
523
|
+
_: 1
|
|
524
|
+
}),
|
|
525
|
+
a(ie, {
|
|
526
|
+
modelValue: d(k),
|
|
527
|
+
"onUpdate:modelValue": t[1] || (t[1] = (I) => me(k) ? k.value = I : null),
|
|
528
|
+
"wrapper-class": "w-full",
|
|
529
|
+
class: "w-full",
|
|
530
|
+
placeholder: "Select type"
|
|
531
|
+
}, {
|
|
532
|
+
default: u(() => [
|
|
533
|
+
(i(!0), p(Y, null, ee(L.agendaData.pricingOptions || [], (I) => (i(), ae(le, {
|
|
534
|
+
key: I.id,
|
|
535
|
+
value: I.id
|
|
536
|
+
}, {
|
|
537
|
+
default: u(() => [
|
|
538
|
+
R(T(I.name) + " (" + T(I.duration) + "min) ", 1)
|
|
539
|
+
]),
|
|
540
|
+
_: 2
|
|
541
|
+
}, 1032, ["value"]))), 128))
|
|
542
|
+
]),
|
|
543
|
+
_: 1
|
|
544
|
+
}, 8, ["modelValue"])
|
|
545
|
+
])) : B("", !0),
|
|
546
|
+
L.agendaData?.maxTicketsPerReservation > 1 ? (i(), p("div", at, [
|
|
547
|
+
a(s, null, {
|
|
548
|
+
default: u(() => [...t[6] || (t[6] = [
|
|
549
|
+
R("Spots/tickets", -1)
|
|
550
|
+
])]),
|
|
551
|
+
_: 1
|
|
552
|
+
}),
|
|
553
|
+
a(ke, {
|
|
554
|
+
modelValue: d(j),
|
|
555
|
+
"onUpdate:modelValue": t[2] || (t[2] = (I) => me(j) ? j.value = I : null),
|
|
556
|
+
modelModifiers: { number: !0 },
|
|
557
|
+
type: "number",
|
|
558
|
+
min: "1",
|
|
559
|
+
class: "no-spinner",
|
|
560
|
+
autocomplete: "off"
|
|
561
|
+
}, null, 8, ["modelValue"])
|
|
562
|
+
])) : B("", !0)
|
|
563
|
+
]),
|
|
564
|
+
c("div", rt, [
|
|
565
|
+
a(s, null, {
|
|
566
|
+
default: u(() => [...t[7] || (t[7] = [
|
|
567
|
+
R("Available hours", -1)
|
|
568
|
+
])]),
|
|
569
|
+
_: 1
|
|
570
|
+
}),
|
|
571
|
+
d(A).length === 0 ? (i(), p("div", lt, " No preset hours are available for this resource. You can still add a custom time below. ")) : (i(), p("div", it, [
|
|
572
|
+
d(m) ? (i(), ae(l, {
|
|
573
|
+
key: 0,
|
|
574
|
+
type: "button",
|
|
575
|
+
size: "icon",
|
|
576
|
+
variant: "outline",
|
|
577
|
+
class: "hidden absolute size-8 shrink-0 rounded-full shadow-sm md:inline-flex z-[11] left-0.5",
|
|
578
|
+
onClick: d(J)
|
|
579
|
+
}, {
|
|
580
|
+
default: u(() => [
|
|
581
|
+
a(d(Ie), { class: "size-4" })
|
|
582
|
+
]),
|
|
583
|
+
_: 1
|
|
584
|
+
}, 8, ["onClick"])) : B("", !0),
|
|
585
|
+
c("div", ut, [
|
|
586
|
+
d(se) ? (i(), p("div", dt)) : B("", !0),
|
|
587
|
+
d(oe) ? (i(), p("div", ct)) : B("", !0),
|
|
588
|
+
c("div", {
|
|
589
|
+
ref_key: "hourScrollContainer",
|
|
590
|
+
ref: h,
|
|
591
|
+
class: re(d(fe)(
|
|
592
|
+
"hour-scroll-track flex w-full min-w-0 gap-2 overflow-x-auto overscroll-contain py-2",
|
|
593
|
+
d(C) && !d($) && "cursor-grab",
|
|
594
|
+
d($) && "cursor-grabbing select-none"
|
|
595
|
+
))
|
|
596
|
+
}, [
|
|
597
|
+
(i(!0), p(Y, null, ee(d(A), (I) => (i(), ae(l, {
|
|
598
|
+
key: I,
|
|
599
|
+
type: "button",
|
|
600
|
+
variant: "outline",
|
|
601
|
+
class: re(["relative h-12 shrink-0", K(I) ? "border-primary!" : ""]),
|
|
602
|
+
onClick: (ce) => r(I)
|
|
603
|
+
}, {
|
|
604
|
+
default: u(() => [
|
|
605
|
+
R(T(I) + " ", 1),
|
|
606
|
+
K(I) ? (i(), p("div", pt, [
|
|
607
|
+
a(d(Ce), { class: "size-3" })
|
|
608
|
+
])) : B("", !0)
|
|
609
|
+
]),
|
|
610
|
+
_: 2
|
|
611
|
+
}, 1032, ["class", "onClick"]))), 128))
|
|
612
|
+
], 2)
|
|
613
|
+
]),
|
|
614
|
+
d(D) ? (i(), ae(l, {
|
|
615
|
+
key: 1,
|
|
616
|
+
type: "button",
|
|
617
|
+
size: "icon",
|
|
618
|
+
variant: "outline",
|
|
619
|
+
class: "hidden absolute size-8 shrink-0 rounded-full shadow-sm md:inline-flex z-[11] right-0.5",
|
|
620
|
+
onClick: d(W)
|
|
621
|
+
}, {
|
|
622
|
+
default: u(() => [
|
|
623
|
+
a(d(Ne), { class: "size-4" })
|
|
624
|
+
]),
|
|
625
|
+
_: 1
|
|
626
|
+
}, 8, ["onClick"])) : B("", !0)
|
|
627
|
+
])),
|
|
628
|
+
c("div", mt, [
|
|
629
|
+
(i(!0), p(Y, null, ee(d(n), (I) => (i(), p("div", {
|
|
630
|
+
key: I,
|
|
631
|
+
class: "relative"
|
|
632
|
+
}, [
|
|
633
|
+
a(l, {
|
|
634
|
+
type: "button",
|
|
635
|
+
variant: "outline",
|
|
636
|
+
class: "h-12 px-4 py-2"
|
|
637
|
+
}, {
|
|
638
|
+
default: u(() => [
|
|
639
|
+
R(T(I), 1)
|
|
640
|
+
]),
|
|
641
|
+
_: 2
|
|
642
|
+
}, 1024),
|
|
643
|
+
c("div", {
|
|
644
|
+
class: "absolute -top-1 -right-1 flex items-center justify-center bg-red-500 rounded-full text-white size-4 cursor-pointer",
|
|
645
|
+
onClick: (ce) => {
|
|
646
|
+
n.value = d(n).filter((pe) => pe !== I), w.value = d(w).filter((pe) => pe !== I);
|
|
647
|
+
}
|
|
648
|
+
}, [
|
|
649
|
+
a(d(Ve), { class: "size-3" })
|
|
650
|
+
], 8, ft)
|
|
651
|
+
]))), 128))
|
|
652
|
+
])
|
|
653
|
+
]),
|
|
654
|
+
c("div", null, [
|
|
655
|
+
a(l, {
|
|
656
|
+
disabled: !d(te),
|
|
657
|
+
onClick: b
|
|
658
|
+
}, {
|
|
659
|
+
default: u(() => [
|
|
660
|
+
d(w).length === 0 ? (i(), p("span", vt, "Select at least one timeslot")) : d(w).length === 1 ? (i(), p("span", gt, "Add 1 reservation")) : (i(), p("span", _t, "Add " + T(d(w).length) + " reservations", 1))
|
|
661
|
+
]),
|
|
662
|
+
_: 1
|
|
663
|
+
}, 8, ["disabled"])
|
|
664
|
+
])
|
|
665
|
+
], 2);
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
}), bt = /* @__PURE__ */ Se(ht, [["__scopeId", "data-v-c7529556"]]), yt = { class: "space-y-3" }, xt = { class: "flex flex-wrap items-center justify-between gap-3" }, St = { class: "text-xs text-muted-foreground" }, kt = { class: "flex flex-wrap items-center gap-2" }, $t = {
|
|
669
|
+
key: 0,
|
|
670
|
+
class: "rounded-md border border-dashed bg-muted/20 px-4 py-6 text-sm text-muted-foreground"
|
|
671
|
+
}, wt = {
|
|
672
|
+
key: 1,
|
|
673
|
+
class: "space-y-3"
|
|
674
|
+
}, Tt = { class: "flex items-start gap-2 p-3 md:hidden" }, Rt = ["aria-expanded", "onClick"], Dt = { class: "mt-0.5 flex size-10 shrink-0 items-center justify-center rounded-full bg-muted text-sm font-semibold text-muted-foreground" }, It = { class: "min-w-0 flex-1" }, Ct = { class: "flex items-start justify-between gap-3" }, Nt = { class: "min-w-0" }, Vt = { class: "block truncate text-base font-semibold" }, Lt = { class: "mt-1 block truncate text-xs text-muted-foreground" }, Ot = { class: "mt-1 block truncate text-xs text-muted-foreground" }, Ft = { class: "flex size-10 shrink-0 items-center justify-center rounded-xl border border-border/70 text-muted-foreground" }, Pt = { class: "mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-muted-foreground" }, Et = { class: "inline-flex items-center gap-1.5" }, Mt = { class: "inline-flex items-center gap-1.5" }, Ut = { class: "hidden items-start justify-between gap-3 p-4 pb-0 md:flex" }, At = { class: "text-sm font-medium" }, zt = { class: "text-xs text-muted-foreground" }, qt = { class: "grid gap-4 border-t pt-3 md:grid-cols-2 md:border-0 md:pt-4 xl:grid-cols-5" }, jt = { class: "grid gap-2" }, Bt = {
|
|
675
|
+
key: 0,
|
|
676
|
+
class: "text-xs text-orange-500"
|
|
677
|
+
}, Ht = { class: "grid gap-2" }, Qt = { class: "grid gap-2" }, Yt = { class: "grid gap-2" }, Gt = {
|
|
678
|
+
key: 0,
|
|
679
|
+
class: "grid gap-2"
|
|
680
|
+
}, Xt = /* @__PURE__ */ ue({
|
|
681
|
+
__name: "ReservationLines",
|
|
682
|
+
props: {
|
|
683
|
+
modelValue: {},
|
|
684
|
+
agendaData: {}
|
|
685
|
+
},
|
|
686
|
+
emits: ["add", "quick-add", "update:modelValue"],
|
|
687
|
+
setup(L, { emit: z }) {
|
|
688
|
+
const N = L, E = z, q = Z(() => N.modelValue ?? []), M = Z(() => Number(N.agendaData?.maxTicketsPerReservation) > 1), S = F(null), U = F(!1), V = Z(() => String(N.agendaData?.currency || "EUR").toUpperCase()), O = Z(() => {
|
|
689
|
+
try {
|
|
690
|
+
return new Intl.NumberFormat("en-US", {
|
|
691
|
+
style: "currency",
|
|
692
|
+
currency: V.value,
|
|
693
|
+
minimumFractionDigits: 2,
|
|
694
|
+
maximumFractionDigits: 2
|
|
695
|
+
});
|
|
696
|
+
} catch {
|
|
697
|
+
return new Intl.NumberFormat("en-US", {
|
|
698
|
+
minimumFractionDigits: 2,
|
|
699
|
+
maximumFractionDigits: 2
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
}), k = (r) => {
|
|
703
|
+
E("update:modelValue", r);
|
|
704
|
+
}, w = (r, o, f) => {
|
|
705
|
+
k(q.value.map((e) => e.id !== r ? e : o === "date" ? {
|
|
706
|
+
...e,
|
|
707
|
+
date: String(f ?? ""),
|
|
708
|
+
dateValue: f || void 0
|
|
709
|
+
} : {
|
|
710
|
+
...e,
|
|
711
|
+
[o]: f
|
|
712
|
+
}));
|
|
713
|
+
}, j = (r, o) => {
|
|
714
|
+
const f = Number(o);
|
|
715
|
+
w(r, "paid", Number.isFinite(f) ? f : 0);
|
|
716
|
+
}, H = (r, o) => {
|
|
717
|
+
const f = Number(o);
|
|
718
|
+
w(r, "spots", Number.isFinite(f) && f > 0 ? f : 1);
|
|
719
|
+
}, x = (r) => {
|
|
720
|
+
k(q.value.filter((o) => o.id !== r));
|
|
721
|
+
}, Q = (r) => {
|
|
722
|
+
E("quick-add", r), U.value = !1;
|
|
723
|
+
}, G = (r) => N.agendaData?.pricingOptions?.find((o) => o.id === r.pricingOption), te = (r) => {
|
|
724
|
+
const o = G(r);
|
|
725
|
+
return o ? o.duration ? `${o.name} (${o.duration}min)` : o.name : "Reservation";
|
|
726
|
+
}, A = (r) => N.agendaData?.resources?.find((o) => o.id === r.resourceId), m = (r) => A(r)?.name || "Unknown resource", D = (r) => {
|
|
727
|
+
if (!r.startTime) return "";
|
|
728
|
+
const o = Number(G(r)?.duration);
|
|
729
|
+
if (!Number.isFinite(o) || o <= 0) return "";
|
|
730
|
+
const [f, e] = r.startTime.split(":").map(Number);
|
|
731
|
+
if (!Number.isFinite(f) || !Number.isFinite(e)) return "";
|
|
732
|
+
const n = f * 60 + e + o, b = Math.floor(n / 60) % 24, v = n % 60;
|
|
733
|
+
return `${b.toString().padStart(2, "0")}:${v.toString().padStart(2, "0")}`;
|
|
734
|
+
}, h = (r) => {
|
|
735
|
+
if (!r.startTime) return "Select time";
|
|
736
|
+
const o = D(r);
|
|
737
|
+
return o ? `${r.startTime} - ${o}` : r.startTime;
|
|
738
|
+
}, $ = (r) => {
|
|
739
|
+
const o = Number(r);
|
|
740
|
+
if (!Number.isFinite(o)) return V.value === "EUR" ? "€0.00" : "0.00";
|
|
741
|
+
try {
|
|
742
|
+
return O.value.format(o);
|
|
743
|
+
} catch {
|
|
744
|
+
return `${o.toFixed(2)}`;
|
|
745
|
+
}
|
|
746
|
+
}, C = (r) => {
|
|
747
|
+
const o = Number(r.spots), f = Number.isFinite(o) && o > 0 ? o : 1;
|
|
748
|
+
return f === 1 ? "1 spot" : `${f} spots`;
|
|
749
|
+
}, W = (r) => {
|
|
750
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(r)) return null;
|
|
751
|
+
const [o, f, e] = r.split("-").map(Number), n = new Date(o, f - 1, e);
|
|
752
|
+
return Number.isNaN(n.getTime()) || n.getFullYear() !== o || n.getMonth() !== f - 1 || n.getDate() !== e ? null : (n.setHours(0, 0, 0, 0), n);
|
|
753
|
+
}, J = (r) => {
|
|
754
|
+
const o = W(String(r.date || "").trim());
|
|
755
|
+
if (!o) return "";
|
|
756
|
+
const f = /* @__PURE__ */ new Date();
|
|
757
|
+
if (f.setHours(0, 0, 0, 0), o < f)
|
|
758
|
+
return "This date is in the past. Double-check it before saving.";
|
|
759
|
+
const e = new Date(f);
|
|
760
|
+
return e.setFullYear(e.getFullYear() + 1), o > e ? "This date is more than a year ahead. Double-check it before saving." : "";
|
|
761
|
+
}, se = (r) => !r.date || !r.startTime || !r.resourceId || !r.pricingOption, oe = (r) => S.value === r, K = (r) => {
|
|
762
|
+
S.value = S.value === r ? null : r;
|
|
763
|
+
};
|
|
764
|
+
return de(q, (r) => {
|
|
765
|
+
const o = new Set(r.map((f) => f.id));
|
|
766
|
+
if (S.value && !o.has(S.value) && (S.value = null), !S.value) {
|
|
767
|
+
const f = r.find(se);
|
|
768
|
+
f && (S.value = f.id);
|
|
769
|
+
}
|
|
770
|
+
}, { immediate: !0 }), (r, o) => {
|
|
771
|
+
const f = y("Button"), e = y("PopoverTrigger"), n = y("PopoverContent"), b = y("Popover"), v = y("Label"), g = y("Input"), t = y("DynamicSelectOption"), s = y("DynamicSelect");
|
|
772
|
+
return i(), p("div", yt, [
|
|
773
|
+
c("div", xt, [
|
|
774
|
+
c("p", St, T(q.value.length === 1 ? "1 reservation line" : `${q.value.length} reservation lines`), 1),
|
|
775
|
+
c("div", kt, [
|
|
776
|
+
a(b, {
|
|
777
|
+
open: U.value,
|
|
778
|
+
"onUpdate:open": o[0] || (o[0] = (l) => U.value = l)
|
|
779
|
+
}, {
|
|
780
|
+
default: u(() => [
|
|
781
|
+
a(e, { "as-child": "" }, {
|
|
782
|
+
default: u(() => [
|
|
783
|
+
a(f, {
|
|
784
|
+
type: "button",
|
|
785
|
+
variant: "outline",
|
|
786
|
+
size: "sm",
|
|
787
|
+
class: "gap-2"
|
|
788
|
+
}, {
|
|
789
|
+
default: u(() => [
|
|
790
|
+
a(d(Le), { class: "size-4 text-primary" }),
|
|
791
|
+
o[2] || (o[2] = R(" Quick add ", -1))
|
|
792
|
+
]),
|
|
793
|
+
_: 1
|
|
794
|
+
})
|
|
795
|
+
]),
|
|
796
|
+
_: 1
|
|
797
|
+
}),
|
|
798
|
+
a(n, {
|
|
799
|
+
align: "end",
|
|
800
|
+
class: "max-h-[80vh] w-[min(34rem,calc(100vw-2rem))] overflow-y-auto p-0"
|
|
801
|
+
}, {
|
|
802
|
+
default: u(() => [
|
|
803
|
+
U.value ? (i(), ae(bt, {
|
|
804
|
+
key: 0,
|
|
805
|
+
surface: "popover",
|
|
806
|
+
agendaData: L.agendaData,
|
|
807
|
+
onAdd: Q
|
|
808
|
+
}, null, 8, ["agendaData"])) : B("", !0)
|
|
809
|
+
]),
|
|
810
|
+
_: 1
|
|
811
|
+
})
|
|
812
|
+
]),
|
|
813
|
+
_: 1
|
|
814
|
+
}, 8, ["open"]),
|
|
815
|
+
a(f, {
|
|
816
|
+
type: "button",
|
|
817
|
+
variant: "outline",
|
|
818
|
+
size: "sm",
|
|
819
|
+
onClick: o[1] || (o[1] = (l) => E("add"))
|
|
820
|
+
}, {
|
|
821
|
+
default: u(() => [
|
|
822
|
+
a(d(xe), { class: "size-4" }),
|
|
823
|
+
o[3] || (o[3] = R(" Add line ", -1))
|
|
824
|
+
]),
|
|
825
|
+
_: 1
|
|
826
|
+
})
|
|
827
|
+
])
|
|
828
|
+
]),
|
|
829
|
+
q.value.length === 0 ? (i(), p("div", $t, " Use Quick add to create filled reservation lines, or add an empty line manually. ")) : (i(), p("div", wt, [
|
|
830
|
+
(i(!0), p(Y, null, ee(q.value, (l, P) => (i(), p("div", {
|
|
831
|
+
key: l.id,
|
|
832
|
+
class: "rounded-xl border bg-background"
|
|
833
|
+
}, [
|
|
834
|
+
c("div", Tt, [
|
|
835
|
+
c("button", {
|
|
836
|
+
type: "button",
|
|
837
|
+
class: "flex min-w-0 flex-1 items-start gap-3 rounded-lg px-1 py-1 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring/50",
|
|
838
|
+
"aria-expanded": oe(l.id),
|
|
839
|
+
onClick: (_) => K(l.id)
|
|
840
|
+
}, [
|
|
841
|
+
c("span", Dt, T(P + 1), 1),
|
|
842
|
+
c("span", It, [
|
|
843
|
+
c("span", Ct, [
|
|
844
|
+
c("span", Nt, [
|
|
845
|
+
c("span", Vt, T(h(l)), 1),
|
|
846
|
+
c("span", Lt, T(l.date || "No date selected"), 1),
|
|
847
|
+
c("span", Ot, T(m(l)) + " · " + T(te(l)), 1)
|
|
848
|
+
]),
|
|
849
|
+
c("span", Ft, [
|
|
850
|
+
a(d(Oe), { class: "size-4" })
|
|
851
|
+
])
|
|
852
|
+
]),
|
|
853
|
+
c("span", Pt, [
|
|
854
|
+
c("span", Et, [
|
|
855
|
+
a(d(Fe), { class: "size-4" }),
|
|
856
|
+
R(" " + T(C(l)), 1)
|
|
857
|
+
]),
|
|
858
|
+
c("span", Mt, [
|
|
859
|
+
a(d(Pe), { class: "size-4" }),
|
|
860
|
+
R(" " + T($(l.paid)), 1)
|
|
861
|
+
])
|
|
862
|
+
])
|
|
863
|
+
])
|
|
864
|
+
], 8, Rt),
|
|
865
|
+
a(f, {
|
|
866
|
+
type: "button",
|
|
867
|
+
variant: "ghost",
|
|
868
|
+
size: "icon",
|
|
869
|
+
class: "mt-1 shrink-0",
|
|
870
|
+
onClick: (_) => x(l.id)
|
|
871
|
+
}, {
|
|
872
|
+
default: u(() => [
|
|
873
|
+
a(d(ge), { class: "size-4" })
|
|
874
|
+
]),
|
|
875
|
+
_: 1
|
|
876
|
+
}, 8, ["onClick"])
|
|
877
|
+
]),
|
|
878
|
+
c("div", Ut, [
|
|
879
|
+
c("div", null, [
|
|
880
|
+
c("p", At, "Reservation " + T(P + 1), 1),
|
|
881
|
+
c("p", zt, T(m(l)) + " · " + T(te(l)), 1)
|
|
882
|
+
]),
|
|
883
|
+
a(f, {
|
|
884
|
+
type: "button",
|
|
885
|
+
variant: "ghost",
|
|
886
|
+
size: "icon",
|
|
887
|
+
class: "shrink-0",
|
|
888
|
+
onClick: (_) => x(l.id)
|
|
889
|
+
}, {
|
|
890
|
+
default: u(() => [
|
|
891
|
+
a(d(ge), { class: "size-4" })
|
|
892
|
+
]),
|
|
893
|
+
_: 1
|
|
894
|
+
}, 8, ["onClick"])
|
|
895
|
+
]),
|
|
896
|
+
c("div", {
|
|
897
|
+
class: re(["px-3 pb-3 md:px-4 md:pb-4 overflow-hidden", oe(l.id) ? "block" : "hidden md:block"])
|
|
898
|
+
}, [
|
|
899
|
+
c("div", qt, [
|
|
900
|
+
c("div", jt, [
|
|
901
|
+
a(v, null, {
|
|
902
|
+
default: u(() => [...o[4] || (o[4] = [
|
|
903
|
+
R("Date", -1)
|
|
904
|
+
])]),
|
|
905
|
+
_: 1
|
|
906
|
+
}),
|
|
907
|
+
a(g, {
|
|
908
|
+
"model-value": l.date,
|
|
909
|
+
type: "date",
|
|
910
|
+
"onUpdate:modelValue": (_) => w(l.id, "date", String(_ ?? ""))
|
|
911
|
+
}, null, 8, ["model-value", "onUpdate:modelValue"]),
|
|
912
|
+
J(l) ? (i(), p("p", Bt, T(J(l)), 1)) : B("", !0)
|
|
913
|
+
]),
|
|
914
|
+
c("div", Ht, [
|
|
915
|
+
a(v, {
|
|
916
|
+
for: `new_reservation_res_line_${P}_time`
|
|
917
|
+
}, {
|
|
918
|
+
default: u(() => [...o[5] || (o[5] = [
|
|
919
|
+
R("Time", -1)
|
|
920
|
+
])]),
|
|
921
|
+
_: 1
|
|
922
|
+
}, 8, ["for"]),
|
|
923
|
+
a(g, {
|
|
924
|
+
id: `new_reservation_res_line_${P}_time`,
|
|
925
|
+
"model-value": l.startTime,
|
|
926
|
+
type: "time",
|
|
927
|
+
class: "reservation-time-input",
|
|
928
|
+
"onUpdate:modelValue": (_) => w(l.id, "startTime", String(_ ?? ""))
|
|
929
|
+
}, null, 8, ["id", "model-value", "onUpdate:modelValue"])
|
|
930
|
+
]),
|
|
931
|
+
c("div", Qt, [
|
|
932
|
+
a(v, null, {
|
|
933
|
+
default: u(() => [...o[6] || (o[6] = [
|
|
934
|
+
R("Resource", -1)
|
|
935
|
+
])]),
|
|
936
|
+
_: 1
|
|
937
|
+
}),
|
|
938
|
+
a(s, {
|
|
939
|
+
"model-value": l.resourceId,
|
|
940
|
+
"wrapper-class": "w-full",
|
|
941
|
+
class: "w-full",
|
|
942
|
+
placeholder: "Select resource",
|
|
943
|
+
"onUpdate:modelValue": (_) => w(l.id, "resourceId", String(_ ?? ""))
|
|
944
|
+
}, {
|
|
945
|
+
default: u(() => [
|
|
946
|
+
(i(!0), p(Y, null, ee(L.agendaData?.resources || [], (_) => (i(), ae(t, {
|
|
947
|
+
key: _.id,
|
|
948
|
+
value: _.id
|
|
949
|
+
}, {
|
|
950
|
+
default: u(() => [
|
|
951
|
+
R(T(_.name), 1)
|
|
952
|
+
]),
|
|
953
|
+
_: 2
|
|
954
|
+
}, 1032, ["value"]))), 128))
|
|
955
|
+
]),
|
|
956
|
+
_: 1
|
|
957
|
+
}, 8, ["model-value", "onUpdate:modelValue"])
|
|
958
|
+
]),
|
|
959
|
+
c("div", Yt, [
|
|
960
|
+
a(v, null, {
|
|
961
|
+
default: u(() => [...o[7] || (o[7] = [
|
|
962
|
+
R("Type", -1)
|
|
963
|
+
])]),
|
|
964
|
+
_: 1
|
|
965
|
+
}),
|
|
966
|
+
a(s, {
|
|
967
|
+
"model-value": l.pricingOption,
|
|
968
|
+
"wrapper-class": "w-full",
|
|
969
|
+
class: "w-full",
|
|
970
|
+
placeholder: "Select type",
|
|
971
|
+
"onUpdate:modelValue": (_) => w(l.id, "pricingOption", String(_ ?? ""))
|
|
972
|
+
}, {
|
|
973
|
+
default: u(() => [
|
|
974
|
+
(i(!0), p(Y, null, ee(L.agendaData?.pricingOptions || [], (_) => (i(), ae(t, {
|
|
975
|
+
key: _.id,
|
|
976
|
+
value: _.id
|
|
977
|
+
}, {
|
|
978
|
+
default: u(() => [
|
|
979
|
+
R(T(_.name), 1)
|
|
980
|
+
]),
|
|
981
|
+
_: 2
|
|
982
|
+
}, 1032, ["value"]))), 128))
|
|
983
|
+
]),
|
|
984
|
+
_: 1
|
|
985
|
+
}, 8, ["model-value", "onUpdate:modelValue"])
|
|
986
|
+
]),
|
|
987
|
+
c("div", {
|
|
988
|
+
class: re(["grid gap-4", M.value ? "md:grid-cols-2 xl:grid-cols-2 xl:col-span-1" : ""])
|
|
989
|
+
}, [
|
|
990
|
+
M.value ? (i(), p("div", Gt, [
|
|
991
|
+
a(v, null, {
|
|
992
|
+
default: u(() => [...o[8] || (o[8] = [
|
|
993
|
+
R("Spots", -1)
|
|
994
|
+
])]),
|
|
995
|
+
_: 1
|
|
996
|
+
}),
|
|
997
|
+
a(g, {
|
|
998
|
+
"model-value": l.spots,
|
|
999
|
+
type: "number",
|
|
1000
|
+
min: "1",
|
|
1001
|
+
class: "no-spinner",
|
|
1002
|
+
"onUpdate:modelValue": (_) => H(l.id, _)
|
|
1003
|
+
}, null, 8, ["model-value", "onUpdate:modelValue"])
|
|
1004
|
+
])) : B("", !0),
|
|
1005
|
+
c("div", {
|
|
1006
|
+
class: re(["grid gap-2", M.value ? "" : "md:col-span-2 xl:col-span-1"])
|
|
1007
|
+
}, [
|
|
1008
|
+
a(v, null, {
|
|
1009
|
+
default: u(() => [...o[9] || (o[9] = [
|
|
1010
|
+
R("Paid", -1)
|
|
1011
|
+
])]),
|
|
1012
|
+
_: 1
|
|
1013
|
+
}),
|
|
1014
|
+
a(g, {
|
|
1015
|
+
"model-value": l.paid,
|
|
1016
|
+
type: "number",
|
|
1017
|
+
min: "0",
|
|
1018
|
+
step: "1",
|
|
1019
|
+
class: "no-spinner",
|
|
1020
|
+
"onUpdate:modelValue": (_) => j(l.id, _)
|
|
1021
|
+
}, null, 8, ["model-value", "onUpdate:modelValue"])
|
|
1022
|
+
], 2)
|
|
1023
|
+
], 2)
|
|
1024
|
+
])
|
|
1025
|
+
], 2)
|
|
1026
|
+
]))), 128))
|
|
1027
|
+
]))
|
|
1028
|
+
]);
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
}), Wt = /* @__PURE__ */ Se(Xt, [["__scopeId", "data-v-9b860aae"]]), Zt = { class: "space-y-5 md:mt-5" }, Jt = { class: "space-y-3" }, Kt = { class: "mt-4 text-red-400" }, en = { class: "list-disc pl-4" }, tn = { key: 0 }, nn = { key: 1 }, he = "00:00", dn = /* @__PURE__ */ ue({
|
|
1032
|
+
__name: "NewReservationDialog",
|
|
1033
|
+
props: {
|
|
1034
|
+
agendaData: {}
|
|
1035
|
+
},
|
|
1036
|
+
setup(L) {
|
|
1037
|
+
const z = L, { params: N } = Ee(), { config: E } = Me(), { log: q, logError: M } = useLogs(), S = Ue(E.project), U = Z(() => N.value?.id ?? N.id ?? ""), V = Re("agendaData", F({})), O = Z(() => z.agendaData ?? V.value ?? {}), k = F(!1), w = F(!1), j = F([]), H = /^([01]\d|2[0-3]):[0-5]\d$/, x = F([]), Q = F(null), G = () => O.value?.resources?.[0]?.id ?? "", te = () => O.value?.pricingOptions?.find((e) => e.isDefault === !0)?.id ?? O.value?.pricingOptions?.[0]?.id ?? "", A = (e) => {
|
|
1038
|
+
let n = e?.pricingOption ?? te(), b = O.value?.pricingOptions?.find((g) => g.id === n)?.price ?? 0;
|
|
1039
|
+
typeof b == "string" && (b = Number(b));
|
|
1040
|
+
let v = e?.paid ?? b;
|
|
1041
|
+
return typeof v == "string" && (v = Number(v)), {
|
|
1042
|
+
id: `reservation_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
|
|
1043
|
+
spots: Number(e?.spots) || 1,
|
|
1044
|
+
paid: Number.isFinite(v) ? v : 0,
|
|
1045
|
+
resourceId: e?.resourceId ?? G(),
|
|
1046
|
+
pricingOption: n,
|
|
1047
|
+
date: e?.date ?? "",
|
|
1048
|
+
dateValue: e?.dateValue,
|
|
1049
|
+
startTime: e?.startTime ?? he
|
|
1050
|
+
};
|
|
1051
|
+
}, m = () => {
|
|
1052
|
+
x.value = [A()];
|
|
1053
|
+
}, D = (e) => !e.date && e.startTime === he, h = () => {
|
|
1054
|
+
const e = x.value[x.value.length - 1];
|
|
1055
|
+
x.value = [...x.value, A(e ? { ...e } : void 0)];
|
|
1056
|
+
}, $ = (e) => O.value?.pricingOptions?.find((n) => n.id === e.pricingOption), C = (e) => O.value?.resources?.find((n) => n.id === e.resourceId), W = () => {
|
|
1057
|
+
const e = Number(O.value?.maxTicketsPerReservation);
|
|
1058
|
+
return Number.isFinite(e) && e > 0 ? e : null;
|
|
1059
|
+
}, J = (e) => `Reservation ${e + 1}`, se = (e) => {
|
|
1060
|
+
const n = String(e.date || "").trim(), b = String(e.startTime || "").trim(), v = String(e.resourceId || "").trim();
|
|
1061
|
+
return !n || !b || !v ? "" : `${v}_${n}_${b}`;
|
|
1062
|
+
}, oe = () => {
|
|
1063
|
+
const e = [], n = /* @__PURE__ */ new Map(), b = W();
|
|
1064
|
+
return x.value.forEach((v, g) => {
|
|
1065
|
+
const t = J(g), s = String(v.date || "").trim(), l = String(v.startTime || "").trim(), P = String(v.resourceId || "").trim(), _ = String(v.pricingOption || "").trim(), X = Number(v.spots), ne = Number(v.paid);
|
|
1066
|
+
s || e.push(`${t}: please select a date.`), l ? H.test(l) || e.push(`${t}: please enter a valid time.`) : e.push(`${t}: please select a time.`), P ? C(v) || e.push(`${t}: the selected resource is no longer available.`) : e.push(`${t}: please select a resource.`), _ ? $(v) || e.push(`${t}: the selected type is no longer available.`) : e.push(`${t}: please select a type.`), !Number.isFinite(X) || X <= 0 ? e.push(`${t}: spots must be at least 1.`) : b !== null && X > b && e.push(`${t}: spots cannot be more than ${b}.`), (!Number.isFinite(ne) || ne < 0) && e.push(`${t}: paid amount must be 0 or higher.`);
|
|
1067
|
+
const le = se(v);
|
|
1068
|
+
if (le) {
|
|
1069
|
+
const ie = n.get(le);
|
|
1070
|
+
ie !== void 0 ? e.push(`${t}: duplicate of ${J(ie).toLowerCase()}.`) : n.set(le, g);
|
|
1071
|
+
}
|
|
1072
|
+
}), e;
|
|
1073
|
+
}, K = (e) => {
|
|
1074
|
+
const n = e.startTimes.map((b) => A({
|
|
1075
|
+
date: e.date ? `${e.date}` : "",
|
|
1076
|
+
dateValue: e.date,
|
|
1077
|
+
pricingOption: e.pricingOptionId,
|
|
1078
|
+
resourceId: e.resourceId,
|
|
1079
|
+
spots: e.spots,
|
|
1080
|
+
startTime: b
|
|
1081
|
+
}));
|
|
1082
|
+
if (n.length !== 0) {
|
|
1083
|
+
if (x.value.length === 1 && D(x.value[0])) {
|
|
1084
|
+
x.value = n;
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
x.value = [...x.value, ...n];
|
|
1088
|
+
}
|
|
1089
|
+
}, r = (e) => {
|
|
1090
|
+
if (!e.startTime || !e.pricingOption) return "";
|
|
1091
|
+
const n = $(e);
|
|
1092
|
+
if (!n?.duration) return e.startTime;
|
|
1093
|
+
const [b, v] = e.startTime.split(":").map(Number);
|
|
1094
|
+
if (isNaN(b) || isNaN(v)) return "";
|
|
1095
|
+
const g = b * 60 + v + n.duration, t = Math.floor(g / 60) % 24, s = g % 60;
|
|
1096
|
+
return `${t.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`;
|
|
1097
|
+
};
|
|
1098
|
+
de(k, async (e) => {
|
|
1099
|
+
e && (j.value = [], m(), await ye(), Q.value?.reset());
|
|
1100
|
+
});
|
|
1101
|
+
const o = () => {
|
|
1102
|
+
const e = [];
|
|
1103
|
+
j.value = [];
|
|
1104
|
+
const n = Q.value, b = n ? n.validateForm() : !1;
|
|
1105
|
+
return n || e.push("Customer information form is unavailable."), x.value.length === 0 && e.push("Please add at least one reservation."), e.push(...oe()), j.value = e, e.length === 0 && b;
|
|
1106
|
+
}, f = async () => {
|
|
1107
|
+
const e = Q.value;
|
|
1108
|
+
if (!e || !o()) return;
|
|
1109
|
+
let n = !1;
|
|
1110
|
+
try {
|
|
1111
|
+
w.value = !0;
|
|
1112
|
+
const b = e.getCustomerInfo(), v = x.value.map((s) => {
|
|
1113
|
+
const l = Number(s.paid) || 0, P = Number(s.spots) || 1, _ = $(s), X = C(s), ne = s.date;
|
|
1114
|
+
return {
|
|
1115
|
+
paidAmount: l,
|
|
1116
|
+
flattenedReservationDate: `${s.resourceId}_${ne}`,
|
|
1117
|
+
flattenedReservation: `${s.resourceId}_${ne}_${s.startTime.replace(":", "")}`,
|
|
1118
|
+
reservation: {
|
|
1119
|
+
status: "approved",
|
|
1120
|
+
totalPrice: Number(l.toFixed(2)),
|
|
1121
|
+
basePrice: Number((l / P).toFixed(2)),
|
|
1122
|
+
addOnsPrice: 0,
|
|
1123
|
+
addOns: [],
|
|
1124
|
+
date: ne,
|
|
1125
|
+
id: `res_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
|
|
1126
|
+
pricingOption: {
|
|
1127
|
+
duration: _?.duration || "",
|
|
1128
|
+
id: _?.id || "",
|
|
1129
|
+
name: _?.name || "",
|
|
1130
|
+
price: _?.price || ""
|
|
1131
|
+
},
|
|
1132
|
+
pricingOptionId: s.pricingOption,
|
|
1133
|
+
resource: {
|
|
1134
|
+
avatarLabel: X?.avatarLabel || "",
|
|
1135
|
+
color: X?.color || "",
|
|
1136
|
+
description: X?.description || "",
|
|
1137
|
+
id: X?.id || "",
|
|
1138
|
+
name: X?.name || ""
|
|
1139
|
+
},
|
|
1140
|
+
resourceId: s.resourceId,
|
|
1141
|
+
spots: P,
|
|
1142
|
+
timeslot: {
|
|
1143
|
+
startTime: s.startTime,
|
|
1144
|
+
endTime: r(s)
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
}), g = Number(v.reduce((s, l) => s + l.paidAmount, 0).toFixed(2)), t = {
|
|
1149
|
+
agendaId: U.value,
|
|
1150
|
+
customerInfo: b,
|
|
1151
|
+
metadata: {},
|
|
1152
|
+
amountPaid: g,
|
|
1153
|
+
amountDue: 0,
|
|
1154
|
+
subtotal: g,
|
|
1155
|
+
total: g,
|
|
1156
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1157
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
1158
|
+
discount: 0,
|
|
1159
|
+
flattenedReservationDates: Array.from(new Set(v.map((s) => s.flattenedReservationDate))),
|
|
1160
|
+
flattenedReservations: v.map((s) => s.flattenedReservation),
|
|
1161
|
+
paymentStatus: "paid",
|
|
1162
|
+
paymentType: "full",
|
|
1163
|
+
reservations: v.map((s) => s.reservation),
|
|
1164
|
+
status: "confirmed"
|
|
1165
|
+
};
|
|
1166
|
+
await S.add(E.reservationsCollection, t), n = !0, q(`${v.length} ${v.length > 1 ? "reservations" : "reservation"} created in Studio`, {
|
|
1167
|
+
agendaId: U.value,
|
|
1168
|
+
reservationIds: v.map((s) => s.reservation.id),
|
|
1169
|
+
amountPaid: g,
|
|
1170
|
+
reservations: v.map((s) => `${s.reservation.resource.name}: ${s.reservation.date} ${s.reservation.timeslot.startTime}`)
|
|
1171
|
+
});
|
|
1172
|
+
} catch (b) {
|
|
1173
|
+
M("Failed to create reservation in Studio", {
|
|
1174
|
+
error: b instanceof Error ? b.message : String(b),
|
|
1175
|
+
agendaId: U.value
|
|
1176
|
+
}), console.error("Error creating reservation:", b);
|
|
1177
|
+
} finally {
|
|
1178
|
+
w.value = !1, n && (k.value = !1);
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
return (e, n) => {
|
|
1182
|
+
const b = y("Button"), v = y("ResponsiveModalTrigger"), g = y("ResponsiveModalTitle"), t = y("ResponsiveModalHeader"), s = y("ResponsiveModalFooter"), l = y("ResponsiveModalScrollContent"), P = y("ResponsiveModal");
|
|
1183
|
+
return i(), ae(P, {
|
|
1184
|
+
open: k.value,
|
|
1185
|
+
"onUpdate:open": n[1] || (n[1] = (_) => k.value = _)
|
|
1186
|
+
}, {
|
|
1187
|
+
default: u(() => [
|
|
1188
|
+
a(v, { "as-child": "" }, {
|
|
1189
|
+
default: u(() => [
|
|
1190
|
+
a(b, null, {
|
|
1191
|
+
default: u(() => [
|
|
1192
|
+
a(d(xe), { class: "size-4" }),
|
|
1193
|
+
n[2] || (n[2] = R(" Add Reservation ", -1))
|
|
1194
|
+
]),
|
|
1195
|
+
_: 1
|
|
1196
|
+
})
|
|
1197
|
+
]),
|
|
1198
|
+
_: 1
|
|
1199
|
+
}),
|
|
1200
|
+
a(l, { class: "@container/modal sm:max-w-7xl" }, {
|
|
1201
|
+
default: u(() => [
|
|
1202
|
+
a(t, null, {
|
|
1203
|
+
default: u(() => [
|
|
1204
|
+
a(g, null, {
|
|
1205
|
+
default: u(() => [...n[3] || (n[3] = [
|
|
1206
|
+
R("Create new reservation", -1)
|
|
1207
|
+
])]),
|
|
1208
|
+
_: 1
|
|
1209
|
+
})
|
|
1210
|
+
]),
|
|
1211
|
+
_: 1
|
|
1212
|
+
}),
|
|
1213
|
+
c("div", Zt, [
|
|
1214
|
+
a(We, {
|
|
1215
|
+
ref_key: "customerInformationRef",
|
|
1216
|
+
ref: Q,
|
|
1217
|
+
agendaData: O.value
|
|
1218
|
+
}, null, 8, ["agendaData"]),
|
|
1219
|
+
n[5] || (n[5] = c("div", { class: "w-full h-[1px] bg-border my-8" }, null, -1)),
|
|
1220
|
+
c("div", Jt, [
|
|
1221
|
+
n[4] || (n[4] = c("div", { class: "flex items-center justify-between gap-3" }, [
|
|
1222
|
+
c("h2", { class: "text-sm font-medium" }, "Reservations")
|
|
1223
|
+
], -1)),
|
|
1224
|
+
a(Wt, {
|
|
1225
|
+
modelValue: x.value,
|
|
1226
|
+
"onUpdate:modelValue": n[0] || (n[0] = (_) => x.value = _),
|
|
1227
|
+
agendaData: O.value,
|
|
1228
|
+
onAdd: h,
|
|
1229
|
+
onQuickAdd: K
|
|
1230
|
+
}, null, 8, ["modelValue", "agendaData"])
|
|
1231
|
+
]),
|
|
1232
|
+
c("div", Kt, [
|
|
1233
|
+
c("ul", en, [
|
|
1234
|
+
(i(!0), p(Y, null, ee(j.value, (_) => (i(), p("li", { key: _ }, T(_), 1))), 128))
|
|
1235
|
+
])
|
|
1236
|
+
])
|
|
1237
|
+
]),
|
|
1238
|
+
a(s, { class: "gap-2" }, {
|
|
1239
|
+
default: u(() => [
|
|
1240
|
+
a(b, {
|
|
1241
|
+
onClick: f,
|
|
1242
|
+
disabled: w.value
|
|
1243
|
+
}, {
|
|
1244
|
+
default: u(() => [
|
|
1245
|
+
w.value ? (i(), p("span", tn, "Creating...")) : (i(), p("span", nn, T(x.value.length > 1 ? `Create ${x.value.length} reservations` : "Create reservation"), 1))
|
|
1246
|
+
]),
|
|
1247
|
+
_: 1
|
|
1248
|
+
}, 8, ["disabled"])
|
|
1249
|
+
]),
|
|
1250
|
+
_: 1
|
|
1251
|
+
})
|
|
1252
|
+
]),
|
|
1253
|
+
_: 1
|
|
1254
|
+
})
|
|
1255
|
+
]),
|
|
1256
|
+
_: 1
|
|
1257
|
+
}, 8, ["open"]);
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
export {
|
|
1262
|
+
dn as _
|
|
1263
|
+
};
|