@oneclick.dev/cms-core-modules 0.0.122 → 0.0.123
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/{ContentEditor-CoJjsV-m.js → ContentEditor-C-Wm48ai.js} +63 -59
- package/dist/{ContentEditor-DIwqplfB.mjs → ContentEditor-MDGolnIP.mjs} +27596 -26138
- package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-bZidw6RT.mjs → NewReservationDialog.vue_vue_type_script_setup_true_lang-8I_Z9cD_.mjs} +530 -530
- package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-BVE_uURZ.js +1 -0
- package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-BdFa-xNf.mjs +3566 -0
- package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-DzPOadcU.js +925 -0
- package/dist/TableCalculationWidget-CkQPrVUd.js +59 -0
- package/dist/TableCalculationWidget-CrqcLGfU.mjs +254 -0
- package/dist/TableDataWidget-7qvC3Egd.js +1 -0
- package/dist/TableDataWidget-DMTSoGRO.mjs +121 -0
- package/dist/TableOverviewCard-AFq-puJs.js +1 -0
- package/dist/TableOverviewCard-Ci0d4o4w.mjs +391 -0
- package/dist/TableResultView.vue_vue_type_script_setup_true_lang-CBn-Oxl9.mjs +534 -0
- package/dist/TableResultView.vue_vue_type_script_setup_true_lang-C_Lv-SmJ.js +1 -0
- package/dist/TableRowActionCard-BhdnnPaq.mjs +266 -0
- package/dist/TableRowActionCard-IzB6tNN-.js +1 -0
- package/dist/TableView-BkwoKREo.js +4 -0
- package/dist/TableView-C4Zyp8d7.mjs +8228 -0
- package/dist/{agenda-BCKDYOeF.mjs → agenda-DWdbWUbb.mjs} +10 -9
- package/dist/agenda-r9Gl85GL.js +1 -0
- package/dist/dateRangePresets-B-l5b_wR.mjs +48 -0
- package/dist/dateRangePresets-CPWqst_x.js +1 -0
- package/dist/fuse-Deb-Iq39.mjs +1473 -0
- package/dist/fuse-_CGUd5Zq.js +1 -0
- package/dist/{index-DU3Ib10Z.mjs → index-B_qaX29C.mjs} +7 -6
- package/dist/{index-Bk3yLv_G.js → index-yHLT6gaZ.js} +3 -3
- package/dist/index.cjs.js +1 -1
- package/dist/index.mjs +419 -109
- package/dist/{orders-CElKNc1v.mjs → orders-BfTLIm7U.mjs} +10 -9
- package/dist/orders-DUa2PVoa.js +1 -0
- package/dist/reports-ChCsd1Gk.mjs +1107 -0
- package/dist/reports-DmJPm8uP.js +158 -0
- package/dist/row-item-C1dUyimV.mjs +204 -0
- package/dist/row-item-Cyo3m3MZ.js +1 -0
- package/dist/src/appointments/components/edit/EventDialog/BookingsList.vue.d.ts +9 -3
- package/dist/src/appointments/components/edit/EventDialog/OrderDetailDialog.vue.d.ts +2 -0
- package/dist/src/appointments/components/edit/EventDialog/ReservationDetailDialog.vue.d.ts +4 -2
- package/dist/src/appointments/components/edit/dashboard/BookingsList.vue.d.ts +9 -3
- package/dist/src/appointments/pages/edit/orders.vue.d.ts +9 -3
- package/dist/src/appointments/pages/edit/reports.vue.d.ts +229 -1
- package/dist/src/table/chat-components/TableCalculationWidget.vue.d.ts +15 -0
- package/dist/src/table/chat-components/TableDataWidget.vue.d.ts +15 -0
- package/dist/src/table/chat-components/TableOverviewCard.vue.d.ts +61 -0
- package/dist/src/table/chat-components/TableResultView.vue.d.ts +48 -0
- package/dist/src/table/chat-components/TableRowActionCard.vue.d.ts +15 -0
- package/dist/src/table/components/filters/DialogTableFilterOptionItem.vue.d.ts +16 -0
- package/dist/src/table/components/filters/NumberComparisonFilter.vue.d.ts +12 -0
- package/dist/src/table/components/filters/NumberComparisonFilterSettings.vue.d.ts +12 -0
- package/dist/src/table/components/filters/NumberRangeFilter.vue.d.ts +12 -0
- package/dist/src/table/components/filters/NumberRangeFilterSettings.vue.d.ts +12 -0
- package/dist/src/table/components/filters/filter-utils.d.ts +14 -0
- package/dist/src/table/composables/useTableAgentTools.d.ts +33 -0
- package/dist/src/table/index.d.ts +339 -0
- package/dist/src/table/tool-sandbox.d.ts +13 -0
- package/dist/src/table/tool-utils.d.ts +11 -0
- package/dist/src/table/tools.d.ts +333 -1
- package/dist/src/table/types.d.ts +79 -0
- package/dist/tool-sandbox-DdkMLkDK.mjs +182 -0
- package/dist/tool-sandbox-DoF1PsyS.js +115 -0
- package/dist/useTableAgentTools-D5mzGf3A.js +1 -0
- package/dist/useTableAgentTools-DcN3kYRL.mjs +131 -0
- package/package.json +17 -17
- package/src/table/tools.ts +304 -1
- package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-BdZbcubW.js +0 -1
- package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-BYSeUW_V.js +0 -925
- package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-DwAUYR8p.mjs +0 -5021
- package/dist/TableView-Ctnep-Qu.mjs +0 -6247
- package/dist/TableView-DJqyJL9L.js +0 -4
- package/dist/agenda-B54F8cEr.js +0 -1
- package/dist/orders-BMosTk6r.js +0 -1
- package/dist/reports-BQT_GZzU.js +0 -158
- package/dist/reports-DksZCTOw.mjs +0 -837
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as De, ref as
|
|
1
|
+
import { defineComponent as De, ref as P, reactive as Ue, computed as ie, watch as Re, resolveComponent as h, openBlock as i, createElementBlock as p, createElementVNode as f, Fragment as ee, renderList as pe, normalizeClass as he, createVNode as r, withCtx as c, createTextVNode as N, toDisplayString as R, createCommentVNode as H, createBlock as be, onMounted as Fe, onBeforeUnmount as ze, nextTick as Le, unref as g, isRef as we, markRaw as Be, inject as qe } from "vue";
|
|
2
2
|
import { CalendarIcon as je, ChevronLeft as He, Check as Qe, ChevronRight as Ye, X as We, Zap as Ge, Plus as Pe, Pencil as Xe, Users as Ze, Tag as Je, Trash2 as Me } from "lucide-vue-next";
|
|
3
3
|
import { useModuleRoute as Ke, useModule as et, useLogs as tt, useFirebaseIntegration as nt } from "@oneclick.dev/cms-kit";
|
|
4
4
|
import { c as Oe } from "./utils-CanmrIWO.mjs";
|
|
@@ -27,8 +27,8 @@ const ot = { class: "space-y-3" }, rt = { class: "grid gap-4 @md/modal:grid-cols
|
|
|
27
27
|
props: {
|
|
28
28
|
agendaData: {}
|
|
29
29
|
},
|
|
30
|
-
setup(
|
|
31
|
-
const
|
|
30
|
+
setup(U, { expose: G }) {
|
|
31
|
+
const E = [
|
|
32
32
|
{
|
|
33
33
|
id: "firstName",
|
|
34
34
|
fieldName: "First Name",
|
|
@@ -64,109 +64,109 @@ const ot = { class: "space-y-3" }, rt = { class: "grid gap-4 @md/modal:grid-cols
|
|
|
64
64
|
required: !0,
|
|
65
65
|
visible: !0
|
|
66
66
|
}
|
|
67
|
-
], Q = /* @__PURE__ */ new Set(["firstName", "email"]),
|
|
68
|
-
const
|
|
69
|
-
...
|
|
70
|
-
required:
|
|
67
|
+
], Q = /* @__PURE__ */ new Set(["firstName", "email"]), le = /* @__PURE__ */ new Set(["firstName"]), j = U, Z = P([]), T = Ue({}), F = ie(() => {
|
|
68
|
+
const _ = j.agendaData?.customerInformationFields, S = (Array.isArray(_) && _.length > 0 ? _ : E).filter((M) => M?.id && (M.visible !== !1 || Q.has(M.id))).map((M) => ({
|
|
69
|
+
...M,
|
|
70
|
+
required: le.has(M.id),
|
|
71
71
|
visible: !0
|
|
72
|
-
})),
|
|
73
|
-
...
|
|
74
|
-
required:
|
|
72
|
+
})), k = E.filter((M) => Q.has(M.id) && !S.some((ue) => ue.id === M.id)).map((M) => ({
|
|
73
|
+
...M,
|
|
74
|
+
required: le.has(M.id),
|
|
75
75
|
visible: !0
|
|
76
76
|
}));
|
|
77
|
-
return [...
|
|
78
|
-
}),
|
|
79
|
-
const
|
|
80
|
-
Object.keys(
|
|
81
|
-
|
|
82
|
-
}), F.value.forEach((
|
|
83
|
-
const
|
|
84
|
-
(
|
|
77
|
+
return [...S, ...k];
|
|
78
|
+
}), V = (_) => _.fieldName || _.id, L = (_) => _.replace(/[^A-Za-z0-9_-]/g, "-"), I = (_, O) => ["new-res-customer-info", _.id, O].filter(Boolean).map((k) => L(k)).join("-"), Y = (_) => _.fieldType === "email" || _.fieldType === "tel" || _.fieldType === "date" ? _.fieldType : "text", z = (_) => Array.isArray(_.options) ? _.options.filter(Boolean) : [], B = (_) => _.fieldType === "checkbox" ? !1 : "", J = (_ = !1) => {
|
|
79
|
+
const O = new Set(F.value.map((S) => S.id));
|
|
80
|
+
Object.keys(T).forEach((S) => {
|
|
81
|
+
O.has(S) || delete T[S];
|
|
82
|
+
}), F.value.forEach((S) => {
|
|
83
|
+
const k = B(S);
|
|
84
|
+
(_ || T[S.id] === void 0 || typeof T[S.id] != typeof k) && (T[S.id] = k);
|
|
85
85
|
});
|
|
86
|
-
},
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
return
|
|
86
|
+
}, w = () => {
|
|
87
|
+
const _ = F.value.reduce((O, S) => {
|
|
88
|
+
const k = T[S.id];
|
|
89
|
+
return O[S.id] = typeof k == "string" ? k.trim() : !!k, O;
|
|
90
90
|
}, {});
|
|
91
|
-
return Object.entries(
|
|
92
|
-
O
|
|
93
|
-
}),
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
},
|
|
97
|
-
const
|
|
98
|
-
return F.value.forEach((
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
}),
|
|
91
|
+
return Object.entries(_).forEach(([O, S]) => {
|
|
92
|
+
T[O] = S;
|
|
93
|
+
}), _;
|
|
94
|
+
}, se = (_, O) => _.fieldType === "checkbox" ? O === !0 : typeof O == "string" ? O.trim().length > 0 : O != null, X = () => {
|
|
95
|
+
Z.value = [], J(!0);
|
|
96
|
+
}, ae = () => {
|
|
97
|
+
const _ = [], O = w();
|
|
98
|
+
return F.value.forEach((S) => {
|
|
99
|
+
const k = O[S.id], M = V(S);
|
|
100
|
+
S.required && !se(S, k) && _.push(`Please fill in ${M}.`), S.fieldType === "email" && se(S, k) && typeof k == "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k) === !1 && _.push(`Please fill in a correct ${M}.`);
|
|
101
|
+
}), Z.value = _, _.length === 0;
|
|
102
102
|
};
|
|
103
103
|
return Re(F, () => {
|
|
104
|
-
|
|
105
|
-
}, { immediate: !0 }),
|
|
106
|
-
getCustomerInfo:
|
|
107
|
-
reset:
|
|
108
|
-
validateForm:
|
|
109
|
-
}), (
|
|
110
|
-
const
|
|
104
|
+
J();
|
|
105
|
+
}, { immediate: !0 }), G({
|
|
106
|
+
getCustomerInfo: w,
|
|
107
|
+
reset: X,
|
|
108
|
+
validateForm: ae
|
|
109
|
+
}), (_, O) => {
|
|
110
|
+
const S = h("Checkbox"), k = h("Label"), M = h("SelectValue"), ue = h("SelectTrigger"), ye = h("SelectItem"), me = h("SelectGroup"), de = h("SelectContent"), fe = h("Select"), oe = h("RadioGroupItem"), ge = h("RadioGroup"), ve = h("Input");
|
|
111
111
|
return i(), p("div", ot, [
|
|
112
|
-
|
|
112
|
+
O[0] || (O[0] = f("h2", { class: "text-sm font-medium" }, "Customer Information", -1)),
|
|
113
113
|
f("div", rt, [
|
|
114
|
-
(i(!0), p(
|
|
115
|
-
key:
|
|
116
|
-
class: he(["grid gap-2",
|
|
114
|
+
(i(!0), p(ee, null, pe(F.value, (v) => (i(), p("div", {
|
|
115
|
+
key: v.id,
|
|
116
|
+
class: he(["grid gap-2", v.fieldType === "checkbox" ? "@md/modal:col-span-2" : ""])
|
|
117
117
|
}, [
|
|
118
|
-
|
|
119
|
-
r(
|
|
120
|
-
id:
|
|
121
|
-
modelValue:
|
|
122
|
-
"onUpdate:modelValue": (
|
|
118
|
+
v.fieldType === "checkbox" ? (i(), p("div", it, [
|
|
119
|
+
r(S, {
|
|
120
|
+
id: I(v),
|
|
121
|
+
modelValue: T[v.id],
|
|
122
|
+
"onUpdate:modelValue": ($) => T[v.id] = $
|
|
123
123
|
}, null, 8, ["id", "modelValue", "onUpdate:modelValue"]),
|
|
124
|
-
r(
|
|
125
|
-
for:
|
|
124
|
+
r(k, {
|
|
125
|
+
for: I(v),
|
|
126
126
|
class: "font-normal cursor-pointer"
|
|
127
127
|
}, {
|
|
128
128
|
default: c(() => [
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
N(R(V(v)) + " ", 1),
|
|
130
|
+
v.required ? H("", !0) : (i(), p("span", lt, "optional"))
|
|
131
131
|
]),
|
|
132
132
|
_: 2
|
|
133
133
|
}, 1032, ["for"])
|
|
134
|
-
])) :
|
|
135
|
-
r(
|
|
136
|
-
for:
|
|
134
|
+
])) : v.fieldType === "select" ? (i(), p(ee, { key: 1 }, [
|
|
135
|
+
r(k, {
|
|
136
|
+
for: I(v)
|
|
137
137
|
}, {
|
|
138
138
|
default: c(() => [
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
N(R(V(v)) + " ", 1),
|
|
140
|
+
v.required ? H("", !0) : (i(), p("span", ut, "optional"))
|
|
141
141
|
]),
|
|
142
142
|
_: 2
|
|
143
143
|
}, 1032, ["for"]),
|
|
144
|
-
r(
|
|
145
|
-
modelValue:
|
|
146
|
-
"onUpdate:modelValue": (
|
|
144
|
+
r(fe, {
|
|
145
|
+
modelValue: T[v.id],
|
|
146
|
+
"onUpdate:modelValue": ($) => T[v.id] = $
|
|
147
147
|
}, {
|
|
148
148
|
default: c(() => [
|
|
149
|
-
r(
|
|
150
|
-
id:
|
|
149
|
+
r(ue, {
|
|
150
|
+
id: I(v),
|
|
151
151
|
class: "w-full"
|
|
152
152
|
}, {
|
|
153
153
|
default: c(() => [
|
|
154
|
-
r(
|
|
155
|
-
placeholder: `Select ${
|
|
154
|
+
r(M, {
|
|
155
|
+
placeholder: `Select ${V(v)}`
|
|
156
156
|
}, null, 8, ["placeholder"])
|
|
157
157
|
]),
|
|
158
158
|
_: 2
|
|
159
159
|
}, 1032, ["id"]),
|
|
160
|
-
r(
|
|
160
|
+
r(de, null, {
|
|
161
161
|
default: c(() => [
|
|
162
|
-
r(
|
|
162
|
+
r(me, null, {
|
|
163
163
|
default: c(() => [
|
|
164
|
-
(i(!0), p(
|
|
165
|
-
key:
|
|
166
|
-
value:
|
|
164
|
+
(i(!0), p(ee, null, pe(z(v), ($) => (i(), be(ye, {
|
|
165
|
+
key: $,
|
|
166
|
+
value: $
|
|
167
167
|
}, {
|
|
168
168
|
default: c(() => [
|
|
169
|
-
|
|
169
|
+
N(R($), 1)
|
|
170
170
|
]),
|
|
171
171
|
_: 2
|
|
172
172
|
}, 1032, ["value"]))), 128))
|
|
@@ -179,34 +179,34 @@ const ot = { class: "space-y-3" }, rt = { class: "grid gap-4 @md/modal:grid-cols
|
|
|
179
179
|
]),
|
|
180
180
|
_: 2
|
|
181
181
|
}, 1032, ["modelValue", "onUpdate:modelValue"])
|
|
182
|
-
], 64)) :
|
|
183
|
-
r(
|
|
182
|
+
], 64)) : v.fieldType === "radio" ? (i(), p(ee, { key: 2 }, [
|
|
183
|
+
r(k, null, {
|
|
184
184
|
default: c(() => [
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
N(R(V(v)) + " ", 1),
|
|
186
|
+
v.required ? H("", !0) : (i(), p("span", dt, "optional"))
|
|
187
187
|
]),
|
|
188
188
|
_: 2
|
|
189
189
|
}, 1024),
|
|
190
|
-
r(
|
|
191
|
-
modelValue:
|
|
192
|
-
"onUpdate:modelValue": (
|
|
190
|
+
r(ge, {
|
|
191
|
+
modelValue: T[v.id],
|
|
192
|
+
"onUpdate:modelValue": ($) => T[v.id] = $,
|
|
193
193
|
class: "grid gap-2"
|
|
194
194
|
}, {
|
|
195
195
|
default: c(() => [
|
|
196
|
-
(i(!0), p(
|
|
197
|
-
key:
|
|
196
|
+
(i(!0), p(ee, null, pe(z(v), ($) => (i(), p("div", {
|
|
197
|
+
key: $,
|
|
198
198
|
class: "flex items-center gap-2"
|
|
199
199
|
}, [
|
|
200
|
-
r(
|
|
201
|
-
id:
|
|
202
|
-
value:
|
|
200
|
+
r(oe, {
|
|
201
|
+
id: I(v, $),
|
|
202
|
+
value: $
|
|
203
203
|
}, null, 8, ["id", "value"]),
|
|
204
|
-
r(
|
|
205
|
-
for:
|
|
204
|
+
r(k, {
|
|
205
|
+
for: I(v, $),
|
|
206
206
|
class: "font-normal cursor-pointer"
|
|
207
207
|
}, {
|
|
208
208
|
default: c(() => [
|
|
209
|
-
|
|
209
|
+
N(R($), 1)
|
|
210
210
|
]),
|
|
211
211
|
_: 2
|
|
212
212
|
}, 1032, ["for"])
|
|
@@ -214,129 +214,129 @@ const ot = { class: "space-y-3" }, rt = { class: "grid gap-4 @md/modal:grid-cols
|
|
|
214
214
|
]),
|
|
215
215
|
_: 2
|
|
216
216
|
}, 1032, ["modelValue", "onUpdate:modelValue"])
|
|
217
|
-
], 64)) : (i(), p(
|
|
218
|
-
r(
|
|
219
|
-
for:
|
|
217
|
+
], 64)) : (i(), p(ee, { key: 3 }, [
|
|
218
|
+
r(k, {
|
|
219
|
+
for: I(v)
|
|
220
220
|
}, {
|
|
221
221
|
default: c(() => [
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
N(R(V(v)) + " ", 1),
|
|
223
|
+
v.required ? H("", !0) : (i(), p("span", ct, "optional"))
|
|
224
224
|
]),
|
|
225
225
|
_: 2
|
|
226
226
|
}, 1032, ["for"]),
|
|
227
|
-
r(
|
|
228
|
-
modelValue:
|
|
229
|
-
"onUpdate:modelValue": (
|
|
230
|
-
id:
|
|
231
|
-
type:
|
|
227
|
+
r(ve, {
|
|
228
|
+
modelValue: T[v.id],
|
|
229
|
+
"onUpdate:modelValue": ($) => T[v.id] = $,
|
|
230
|
+
id: I(v),
|
|
231
|
+
type: Y(v),
|
|
232
232
|
autocomplete: "off"
|
|
233
233
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "id", "type"])
|
|
234
234
|
], 64))
|
|
235
235
|
], 2))), 128))
|
|
236
236
|
]),
|
|
237
|
-
|
|
237
|
+
Z.value.length > 0 ? (i(), p("div", pt, [
|
|
238
238
|
f("ul", mt, [
|
|
239
|
-
(i(!0), p(
|
|
239
|
+
(i(!0), p(ee, null, pe(Z.value, (v) => (i(), p("li", { key: v }, R(v), 1))), 128))
|
|
240
240
|
])
|
|
241
|
-
])) :
|
|
241
|
+
])) : H("", !0)
|
|
242
242
|
]);
|
|
243
243
|
};
|
|
244
244
|
}
|
|
245
245
|
});
|
|
246
|
-
function gt(
|
|
247
|
-
const
|
|
248
|
-
let
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
},
|
|
252
|
-
const a =
|
|
246
|
+
function gt(U = {}) {
|
|
247
|
+
const G = P(null), E = P(!1), Q = P(!1), le = P(!1), j = P(!1), Z = U.dragSpeed ?? 1.1, T = U.dragThreshold ?? 10, F = U.edgeThreshold ?? 10, V = U.ignoreDragSelector ?? 'input, select, textarea, [contenteditable="true"], [data-horizontal-scroll-ignore-drag]';
|
|
248
|
+
let L = null, I = 0, Y = 0, z = !1, B = null, J = null, w = null;
|
|
249
|
+
const se = () => {
|
|
250
|
+
B === null || typeof window > "u" || (window.clearTimeout(B), B = null);
|
|
251
|
+
}, X = () => {
|
|
252
|
+
const a = G.value;
|
|
253
253
|
if (!a) {
|
|
254
|
-
Q.value = !1,
|
|
254
|
+
Q.value = !1, le.value = !1, j.value = !1;
|
|
255
255
|
return;
|
|
256
256
|
}
|
|
257
257
|
const l = Math.max(a.scrollWidth - a.clientWidth, 0);
|
|
258
|
-
Q.value = l >
|
|
259
|
-
},
|
|
258
|
+
Q.value = l > F, le.value = Q.value && a.scrollLeft > F, j.value = Q.value && a.scrollLeft < l - F;
|
|
259
|
+
}, ae = () => {
|
|
260
260
|
Le(() => {
|
|
261
261
|
if (typeof window > "u") {
|
|
262
|
-
|
|
262
|
+
X();
|
|
263
263
|
return;
|
|
264
264
|
}
|
|
265
|
-
window.requestAnimationFrame(() =>
|
|
265
|
+
window.requestAnimationFrame(() => X());
|
|
266
266
|
});
|
|
267
|
-
},
|
|
268
|
-
if (typeof
|
|
269
|
-
const a =
|
|
267
|
+
}, _ = () => {
|
|
268
|
+
if (typeof U.scrollStep == "number") return U.scrollStep;
|
|
269
|
+
const a = G.value;
|
|
270
270
|
return a ? Math.max(Math.floor(a.clientWidth * 0.72), 180) : 240;
|
|
271
|
-
},
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
274
|
-
if (
|
|
275
|
-
|
|
271
|
+
}, O = (a, l = "smooth") => {
|
|
272
|
+
const D = G.value;
|
|
273
|
+
if (D) {
|
|
274
|
+
if (D.scrollBy({ left: a, behavior: l }), l === "auto") {
|
|
275
|
+
X();
|
|
276
276
|
return;
|
|
277
277
|
}
|
|
278
|
-
|
|
278
|
+
ae();
|
|
279
279
|
}
|
|
280
|
-
},
|
|
281
|
-
|
|
282
|
-
},
|
|
283
|
-
|
|
284
|
-
},
|
|
285
|
-
const a =
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}, 0))),
|
|
289
|
-
},
|
|
290
|
-
|
|
280
|
+
}, S = () => {
|
|
281
|
+
O(-_());
|
|
282
|
+
}, k = () => {
|
|
283
|
+
O(_());
|
|
284
|
+
}, M = () => {
|
|
285
|
+
const a = G.value;
|
|
286
|
+
L !== null && a?.hasPointerCapture?.(L) && a.releasePointerCapture(L), E.value && (z = !0, se(), typeof window < "u" && (B = window.setTimeout(() => {
|
|
287
|
+
z = !1, B = null;
|
|
288
|
+
}, 0))), L = null, E.value = !1, a && (a.style.userSelect = "", a.style.cursor = ""), X();
|
|
289
|
+
}, ue = () => {
|
|
290
|
+
X();
|
|
291
291
|
}, ye = (a) => {
|
|
292
|
-
const l =
|
|
292
|
+
const l = G.value;
|
|
293
293
|
if (!l || !Q.value || Math.abs(a.deltaY) <= Math.abs(a.deltaX)) return;
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
}, me = (a) => a instanceof Element ? !!a.closest(
|
|
297
|
-
const l =
|
|
298
|
-
!l || !Q.value || a.pointerType !== "touch" && a.button === 0 && (me(a.target) || (
|
|
294
|
+
const D = a.deltaY < 0, re = a.deltaY > 0;
|
|
295
|
+
D && !le.value || re && !j.value || (a.preventDefault(), l.scrollLeft += a.deltaY, X());
|
|
296
|
+
}, me = (a) => a instanceof Element ? !!a.closest(V) : !1, de = (a) => {
|
|
297
|
+
const l = G.value;
|
|
298
|
+
!l || !Q.value || a.pointerType !== "touch" && a.button === 0 && (me(a.target) || (L = a.pointerId, I = a.clientX, Y = l.scrollLeft, z = !1));
|
|
299
299
|
}, fe = (a) => {
|
|
300
|
-
const l =
|
|
301
|
-
if (!l ||
|
|
302
|
-
const
|
|
303
|
-
!
|
|
304
|
-
},
|
|
305
|
-
|
|
300
|
+
const l = G.value;
|
|
301
|
+
if (!l || L !== a.pointerId) return;
|
|
302
|
+
const D = a.clientX - I;
|
|
303
|
+
!E.value && Math.abs(D) < T || (E.value || (E.value = !0, l.style.userSelect = "none", l.style.cursor = "grabbing", l.setPointerCapture?.(a.pointerId)), a.preventDefault(), l.scrollLeft = Y - D * Z, X());
|
|
304
|
+
}, oe = (a) => {
|
|
305
|
+
L === a.pointerId && M();
|
|
306
306
|
}, ge = () => {
|
|
307
|
-
|
|
308
|
-
},
|
|
309
|
-
|
|
310
|
-
},
|
|
311
|
-
typeof ResizeObserver < "u" && (
|
|
307
|
+
L !== null && M();
|
|
308
|
+
}, ve = (a) => {
|
|
309
|
+
z && (a.preventDefault(), a.stopPropagation(), z = !1);
|
|
310
|
+
}, v = (a) => {
|
|
311
|
+
typeof ResizeObserver < "u" && (J = new ResizeObserver(() => X()), J.observe(a)), U.observeMutations !== !1 && typeof MutationObserver < "u" && (w = new MutationObserver(() => ae()), w.observe(a, {
|
|
312
312
|
childList: !0,
|
|
313
313
|
subtree: !0,
|
|
314
314
|
characterData: !0
|
|
315
315
|
}));
|
|
316
|
-
},
|
|
317
|
-
|
|
316
|
+
}, $ = () => {
|
|
317
|
+
J?.disconnect(), w?.disconnect(), J = null, w = null;
|
|
318
318
|
}, ke = (a) => {
|
|
319
|
-
a.addEventListener("scroll",
|
|
319
|
+
a.addEventListener("scroll", ue), a.addEventListener("wheel", ye, { passive: !1 }), a.addEventListener("pointerdown", de), a.addEventListener("pointermove", fe), a.addEventListener("pointerup", oe), a.addEventListener("pointercancel", ge), a.addEventListener("lostpointercapture", ge), a.addEventListener("click", ve, !0), v(a), ae();
|
|
320
320
|
}, xe = (a) => {
|
|
321
|
-
a.removeEventListener("scroll",
|
|
321
|
+
a.removeEventListener("scroll", ue), a.removeEventListener("wheel", ye), a.removeEventListener("pointerdown", de), a.removeEventListener("pointermove", fe), a.removeEventListener("pointerup", oe), a.removeEventListener("pointercancel", ge), a.removeEventListener("lostpointercapture", ge), a.removeEventListener("click", ve, !0), $();
|
|
322
322
|
};
|
|
323
|
-
return Re(
|
|
324
|
-
l && xe(l), a ? ke(a) :
|
|
325
|
-
}),
|
|
326
|
-
|
|
323
|
+
return Re(G, (a, l) => {
|
|
324
|
+
l && xe(l), a ? ke(a) : X();
|
|
325
|
+
}), Fe(() => {
|
|
326
|
+
ae();
|
|
327
327
|
}), ze(() => {
|
|
328
|
-
|
|
328
|
+
se(), G.value && xe(G.value), z = !1, M();
|
|
329
329
|
}), {
|
|
330
|
-
canScrollLeft:
|
|
331
|
-
canScrollRight:
|
|
332
|
-
containerRef:
|
|
333
|
-
isDragging:
|
|
330
|
+
canScrollLeft: ie(() => le.value),
|
|
331
|
+
canScrollRight: ie(() => j.value),
|
|
332
|
+
containerRef: G,
|
|
333
|
+
isDragging: E,
|
|
334
334
|
isScrollable: Q,
|
|
335
|
-
refresh:
|
|
336
|
-
scrollNext:
|
|
337
|
-
scrollPrev:
|
|
338
|
-
showLeftShadow:
|
|
339
|
-
showRightShadow:
|
|
335
|
+
refresh: ae,
|
|
336
|
+
scrollNext: k,
|
|
337
|
+
scrollPrev: S,
|
|
338
|
+
showLeftShadow: le,
|
|
339
|
+
showRightShadow: j
|
|
340
340
|
};
|
|
341
341
|
}
|
|
342
342
|
const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "text-sm font-medium" }, ht = {
|
|
@@ -366,105 +366,105 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
366
366
|
}, Nt = {
|
|
367
367
|
key: 0,
|
|
368
368
|
class: "absolute -top-1 -right-1 flex items-center justify-center bg-primary rounded-full text-background size-4"
|
|
369
|
-
}, Ot = { class: "flex flex-wrap gap-2" }, Vt = ["onClick"], Mt = { key: 0 }, At = { key: 1 },
|
|
369
|
+
}, Ot = { class: "flex flex-wrap gap-2" }, Vt = ["onClick"], Mt = { key: 0 }, At = { key: 1 }, Et = { key: 2 }, Ft = /* @__PURE__ */ De({
|
|
370
370
|
__name: "QuickReservationAdder",
|
|
371
371
|
props: {
|
|
372
372
|
agendaData: {},
|
|
373
373
|
surface: { default: "card" }
|
|
374
374
|
},
|
|
375
375
|
emits: ["add"],
|
|
376
|
-
setup(
|
|
377
|
-
const
|
|
376
|
+
setup(U, { emit: G }) {
|
|
377
|
+
const E = U, Q = G, le = new st("en-US", {
|
|
378
378
|
dateStyle: "long"
|
|
379
|
-
}),
|
|
380
|
-
const [l,
|
|
381
|
-
return l * 60 +
|
|
382
|
-
},
|
|
383
|
-
const l = Math.floor(a / 60),
|
|
384
|
-
return `${l.toString().padStart(2, "0")}:${
|
|
385
|
-
},
|
|
386
|
-
if (!
|
|
387
|
-
const a =
|
|
388
|
-
let l = null,
|
|
389
|
-
for (const s of Object.values(
|
|
379
|
+
}), j = Ae(Ve()), Z = ie(() => E.surface === "popover"), T = P(""), F = P(void 0), V = P(""), L = P(""), I = P([]), Y = P(1), z = P(0), B = ie(() => E.agendaData?.resources?.find((a) => a.id === V.value)), J = (a) => {
|
|
380
|
+
const [l, D] = a.split(":").map(Number);
|
|
381
|
+
return l * 60 + D;
|
|
382
|
+
}, w = (a) => {
|
|
383
|
+
const l = Math.floor(a / 60), D = a % 60;
|
|
384
|
+
return `${l.toString().padStart(2, "0")}:${D.toString().padStart(2, "0")}`;
|
|
385
|
+
}, se = () => {
|
|
386
|
+
if (!B.value) return [];
|
|
387
|
+
const a = B.value.interval || 60;
|
|
388
|
+
let l = null, D = null;
|
|
389
|
+
for (const s of Object.values(B.value.openingHours || {}))
|
|
390
390
|
for (const n of s) {
|
|
391
|
-
const m =
|
|
392
|
-
(l === null || m < l) && (l = m), (
|
|
391
|
+
const m = J(n.start), x = J(n.end);
|
|
392
|
+
(l === null || m < l) && (l = m), (D === null || x > D) && (D = x);
|
|
393
393
|
}
|
|
394
|
-
if (l === null ||
|
|
395
|
-
const
|
|
396
|
-
for (let s = l; s <
|
|
397
|
-
|
|
398
|
-
return
|
|
399
|
-
},
|
|
400
|
-
const a = Number(
|
|
401
|
-
return
|
|
402
|
-
}),
|
|
403
|
-
canScrollLeft:
|
|
404
|
-
canScrollRight:
|
|
405
|
-
containerRef:
|
|
406
|
-
isDragging:
|
|
407
|
-
isScrollable:
|
|
408
|
-
scrollNext:
|
|
394
|
+
if (l === null || D === null) return [];
|
|
395
|
+
const re = [];
|
|
396
|
+
for (let s = l; s < D; s += a)
|
|
397
|
+
re.push(w(s));
|
|
398
|
+
return re;
|
|
399
|
+
}, X = ie(() => {
|
|
400
|
+
const a = Number(z.value);
|
|
401
|
+
return F.value && V.value && L.value && I.value.length > 0 && Number.isFinite(a) && a >= 0;
|
|
402
|
+
}), ae = ie(() => se()), {
|
|
403
|
+
canScrollLeft: _,
|
|
404
|
+
canScrollRight: O,
|
|
405
|
+
containerRef: S,
|
|
406
|
+
isDragging: k,
|
|
407
|
+
isScrollable: M,
|
|
408
|
+
scrollNext: ue,
|
|
409
409
|
scrollPrev: ye,
|
|
410
410
|
showLeftShadow: me,
|
|
411
411
|
showRightShadow: de
|
|
412
|
-
} = gt(), fe = (a) =>
|
|
412
|
+
} = gt(), fe = (a) => I.value.includes(a), oe = (a) => {
|
|
413
413
|
if (fe(a)) {
|
|
414
|
-
|
|
414
|
+
I.value = I.value.filter((l) => l !== a);
|
|
415
415
|
return;
|
|
416
416
|
}
|
|
417
|
-
|
|
417
|
+
I.value = [...I.value, a].sort((l, D) => J(l) - J(D));
|
|
418
418
|
}, ge = (a, l) => {
|
|
419
|
-
|
|
420
|
-
},
|
|
419
|
+
F.value = a ? Be(a) : void 0, T.value = a ? `${a}` : "", l();
|
|
420
|
+
}, ve = P(""), v = P(""), $ = P([]), ke = () => {
|
|
421
421
|
Q("add", {
|
|
422
|
-
date:
|
|
423
|
-
resourceId:
|
|
424
|
-
pricingOptionId:
|
|
425
|
-
startTimes:
|
|
422
|
+
date: F.value,
|
|
423
|
+
resourceId: V.value,
|
|
424
|
+
pricingOptionId: L.value,
|
|
425
|
+
startTimes: I.value,
|
|
426
426
|
spots: Y.value,
|
|
427
|
-
paid: Number(
|
|
428
|
-
}),
|
|
427
|
+
paid: Number(z.value) || 0
|
|
428
|
+
}), I.value = [], $.value = [], v.value = "", ve.value = "";
|
|
429
429
|
}, xe = () => {
|
|
430
|
-
|
|
430
|
+
T.value = j.toString(), F.value = j, V.value = E.agendaData?.resources?.[0]?.id || "", L.value = E.agendaData?.pricingOptions?.find((a) => a.isDefault)?.id || E.agendaData?.pricingOptions?.[0]?.id || "", I.value = [], Y.value = 1, z.value = 0, ve.value = "";
|
|
431
431
|
};
|
|
432
|
-
return
|
|
432
|
+
return Fe(() => {
|
|
433
433
|
xe();
|
|
434
434
|
}), (a, l) => {
|
|
435
|
-
const
|
|
435
|
+
const D = h("Label"), re = h("Button"), s = h("PopoverTrigger"), n = h("Calendar"), m = h("PopoverContent"), x = h("Popover"), A = h("DynamicSelectOption"), te = h("DynamicSelect"), K = h("Input");
|
|
436
436
|
return i(), p("div", {
|
|
437
437
|
class: he(g(Oe)(
|
|
438
438
|
"@container/quick-adder grid gap-4 overflow-hidden bg-background",
|
|
439
|
-
g(
|
|
439
|
+
g(Z) ? "p-5 sm:p-6" : "rounded-md border p-4"
|
|
440
440
|
))
|
|
441
441
|
}, [
|
|
442
442
|
f("div", vt, [
|
|
443
443
|
f("div", null, [
|
|
444
|
-
f("h3", _t,
|
|
445
|
-
g(
|
|
444
|
+
f("h3", _t, R(g(Z) ? "Quick add reservations" : "Add reservations"), 1),
|
|
445
|
+
g(Z) ? (i(), p("p", ht, " Choose one date and add multiple timeslots in one pass. ")) : H("", !0)
|
|
446
446
|
])
|
|
447
447
|
]),
|
|
448
448
|
f("div", bt, [
|
|
449
449
|
f("div", yt, [
|
|
450
|
-
r(
|
|
450
|
+
r(D, null, {
|
|
451
451
|
default: c(() => [...l[4] || (l[4] = [
|
|
452
|
-
|
|
452
|
+
N("Date", -1)
|
|
453
453
|
])]),
|
|
454
454
|
_: 1
|
|
455
455
|
}),
|
|
456
|
-
r(
|
|
456
|
+
r(x, null, {
|
|
457
457
|
default: c(({ close: b }) => [
|
|
458
458
|
r(s, { "as-child": "" }, {
|
|
459
459
|
default: c(() => [
|
|
460
|
-
r(
|
|
460
|
+
r(re, {
|
|
461
461
|
type: "button",
|
|
462
462
|
variant: "outline",
|
|
463
|
-
class: he(g(Oe)("w-full justify-start text-left font-normal", !g(
|
|
463
|
+
class: he(g(Oe)("w-full justify-start text-left font-normal", !g(F) && "text-muted-foreground"))
|
|
464
464
|
}, {
|
|
465
465
|
default: c(() => [
|
|
466
466
|
r(g(je)),
|
|
467
|
-
|
|
467
|
+
N(" " + R(g(F) ? g(le).format(g(F).toDate(g(Ve)())) : "Pick a date"), 1)
|
|
468
468
|
]),
|
|
469
469
|
_: 1
|
|
470
470
|
}, 8, ["class"])
|
|
@@ -477,8 +477,8 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
477
477
|
}, {
|
|
478
478
|
default: c(() => [
|
|
479
479
|
r(n, {
|
|
480
|
-
"model-value": g(
|
|
481
|
-
"default-placeholder": g(
|
|
480
|
+
"model-value": g(F),
|
|
481
|
+
"default-placeholder": g(j),
|
|
482
482
|
layout: "month-and-year",
|
|
483
483
|
"initial-focus": "",
|
|
484
484
|
"onUpdate:modelValue": (_e) => ge(_e, b),
|
|
@@ -491,70 +491,70 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
491
491
|
_: 1
|
|
492
492
|
})
|
|
493
493
|
]),
|
|
494
|
-
|
|
495
|
-
r(
|
|
494
|
+
U.agendaData.resources?.length > 1 ? (i(), p("div", xt, [
|
|
495
|
+
r(D, null, {
|
|
496
496
|
default: c(() => [...l[5] || (l[5] = [
|
|
497
|
-
|
|
497
|
+
N("Resource", -1)
|
|
498
498
|
])]),
|
|
499
499
|
_: 1
|
|
500
500
|
}),
|
|
501
|
-
r(
|
|
502
|
-
modelValue: g(
|
|
503
|
-
"onUpdate:modelValue": l[0] || (l[0] = (b) => we(
|
|
501
|
+
r(te, {
|
|
502
|
+
modelValue: g(V),
|
|
503
|
+
"onUpdate:modelValue": l[0] || (l[0] = (b) => we(V) ? V.value = b : null),
|
|
504
504
|
"wrapper-class": "w-full",
|
|
505
505
|
class: "w-full",
|
|
506
506
|
placeholder: "Select resource"
|
|
507
507
|
}, {
|
|
508
508
|
default: c(() => [
|
|
509
|
-
(i(!0), p(
|
|
509
|
+
(i(!0), p(ee, null, pe(U.agendaData.resources || [], (b) => (i(), be(A, {
|
|
510
510
|
key: b.id,
|
|
511
511
|
value: b.id
|
|
512
512
|
}, {
|
|
513
513
|
default: c(() => [
|
|
514
|
-
|
|
514
|
+
N(R(b.name), 1)
|
|
515
515
|
]),
|
|
516
516
|
_: 2
|
|
517
517
|
}, 1032, ["value"]))), 128))
|
|
518
518
|
]),
|
|
519
519
|
_: 1
|
|
520
520
|
}, 8, ["modelValue"])
|
|
521
|
-
])) :
|
|
522
|
-
|
|
523
|
-
r(
|
|
521
|
+
])) : H("", !0),
|
|
522
|
+
U.agendaData.pricingOptions?.length > 1 ? (i(), p("div", St, [
|
|
523
|
+
r(D, null, {
|
|
524
524
|
default: c(() => [...l[6] || (l[6] = [
|
|
525
|
-
|
|
525
|
+
N("Type", -1)
|
|
526
526
|
])]),
|
|
527
527
|
_: 1
|
|
528
528
|
}),
|
|
529
|
-
r(
|
|
530
|
-
modelValue: g(
|
|
531
|
-
"onUpdate:modelValue": l[1] || (l[1] = (b) => we(
|
|
529
|
+
r(te, {
|
|
530
|
+
modelValue: g(L),
|
|
531
|
+
"onUpdate:modelValue": l[1] || (l[1] = (b) => we(L) ? L.value = b : null),
|
|
532
532
|
"wrapper-class": "w-full",
|
|
533
533
|
class: "w-full",
|
|
534
534
|
placeholder: "Select type"
|
|
535
535
|
}, {
|
|
536
536
|
default: c(() => [
|
|
537
|
-
(i(!0), p(
|
|
537
|
+
(i(!0), p(ee, null, pe(U.agendaData.pricingOptions || [], (b) => (i(), be(A, {
|
|
538
538
|
key: b.id,
|
|
539
539
|
value: b.id
|
|
540
540
|
}, {
|
|
541
541
|
default: c(() => [
|
|
542
|
-
|
|
542
|
+
N(R(b.name) + " (" + R(b.duration) + "min) ", 1)
|
|
543
543
|
]),
|
|
544
544
|
_: 2
|
|
545
545
|
}, 1032, ["value"]))), 128))
|
|
546
546
|
]),
|
|
547
547
|
_: 1
|
|
548
548
|
}, 8, ["modelValue"])
|
|
549
|
-
])) :
|
|
550
|
-
|
|
551
|
-
r(
|
|
549
|
+
])) : H("", !0),
|
|
550
|
+
U.agendaData?.maxTicketsPerReservation > 1 ? (i(), p("div", kt, [
|
|
551
|
+
r(D, null, {
|
|
552
552
|
default: c(() => [...l[7] || (l[7] = [
|
|
553
|
-
|
|
553
|
+
N("Spots/tickets", -1)
|
|
554
554
|
])]),
|
|
555
555
|
_: 1
|
|
556
556
|
}),
|
|
557
|
-
r(
|
|
557
|
+
r(K, {
|
|
558
558
|
modelValue: g(Y),
|
|
559
559
|
"onUpdate:modelValue": l[2] || (l[2] = (b) => we(Y) ? Y.value = b : null),
|
|
560
560
|
modelModifiers: { number: !0 },
|
|
@@ -563,17 +563,17 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
563
563
|
class: "no-spinner",
|
|
564
564
|
autocomplete: "off"
|
|
565
565
|
}, null, 8, ["modelValue"])
|
|
566
|
-
])) :
|
|
566
|
+
])) : H("", !0),
|
|
567
567
|
f("div", $t, [
|
|
568
|
-
r(
|
|
568
|
+
r(D, null, {
|
|
569
569
|
default: c(() => [...l[8] || (l[8] = [
|
|
570
|
-
|
|
570
|
+
N("Paid (per reservation)", -1)
|
|
571
571
|
])]),
|
|
572
572
|
_: 1
|
|
573
573
|
}),
|
|
574
|
-
r(
|
|
575
|
-
modelValue: g(
|
|
576
|
-
"onUpdate:modelValue": l[3] || (l[3] = (b) => we(
|
|
574
|
+
r(K, {
|
|
575
|
+
modelValue: g(z),
|
|
576
|
+
"onUpdate:modelValue": l[3] || (l[3] = (b) => we(z) ? z.value = b : null),
|
|
577
577
|
modelModifiers: { number: !0 },
|
|
578
578
|
type: "number",
|
|
579
579
|
min: "0",
|
|
@@ -585,14 +585,14 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
585
585
|
])
|
|
586
586
|
]),
|
|
587
587
|
f("div", Tt, [
|
|
588
|
-
r(
|
|
588
|
+
r(D, null, {
|
|
589
589
|
default: c(() => [...l[10] || (l[10] = [
|
|
590
|
-
|
|
590
|
+
N("Available hours", -1)
|
|
591
591
|
])]),
|
|
592
592
|
_: 1
|
|
593
593
|
}),
|
|
594
|
-
g(
|
|
595
|
-
g(
|
|
594
|
+
g(ae).length === 0 ? (i(), p("div", It, " No preset hours are available for this resource. You can still add a custom time below. ")) : (i(), p("div", Rt, [
|
|
595
|
+
g(_) ? (i(), be(re, {
|
|
596
596
|
key: 0,
|
|
597
597
|
type: "button",
|
|
598
598
|
size: "icon",
|
|
@@ -604,69 +604,69 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
604
604
|
r(g(He), { class: "size-4" })
|
|
605
605
|
]),
|
|
606
606
|
_: 1
|
|
607
|
-
}, 8, ["onClick"])) :
|
|
607
|
+
}, 8, ["onClick"])) : H("", !0),
|
|
608
608
|
f("div", wt, [
|
|
609
|
-
g(me) ? (i(), p("div", Dt)) :
|
|
610
|
-
g(de) ? (i(), p("div", Ct)) :
|
|
609
|
+
g(me) ? (i(), p("div", Dt)) : H("", !0),
|
|
610
|
+
g(de) ? (i(), p("div", Ct)) : H("", !0),
|
|
611
611
|
f("div", {
|
|
612
612
|
ref_key: "hourScrollContainer",
|
|
613
|
-
ref:
|
|
613
|
+
ref: S,
|
|
614
614
|
class: he(g(Oe)(
|
|
615
615
|
"hour-scroll-track flex w-full min-w-0 gap-2 overflow-x-auto overscroll-contain py-2",
|
|
616
|
-
g(
|
|
617
|
-
g(
|
|
616
|
+
g(M) && !g(k) && "cursor-grab",
|
|
617
|
+
g(k) && "cursor-grabbing select-none"
|
|
618
618
|
))
|
|
619
619
|
}, [
|
|
620
|
-
(i(!0), p(
|
|
620
|
+
(i(!0), p(ee, null, pe(g(ae), (b) => (i(), be(re, {
|
|
621
621
|
key: b,
|
|
622
622
|
type: "button",
|
|
623
623
|
variant: "outline",
|
|
624
624
|
class: he(["relative h-12 shrink-0", fe(b) ? "border-primary!" : ""]),
|
|
625
|
-
onClick: (_e) =>
|
|
625
|
+
onClick: (_e) => oe(b)
|
|
626
626
|
}, {
|
|
627
627
|
default: c(() => [
|
|
628
|
-
|
|
628
|
+
N(R(b) + " ", 1),
|
|
629
629
|
fe(b) ? (i(), p("div", Nt, [
|
|
630
630
|
r(g(Qe), { class: "size-3" })
|
|
631
|
-
])) :
|
|
631
|
+
])) : H("", !0)
|
|
632
632
|
]),
|
|
633
633
|
_: 2
|
|
634
634
|
}, 1032, ["class", "onClick"]))), 128))
|
|
635
635
|
], 2)
|
|
636
636
|
]),
|
|
637
|
-
g(
|
|
637
|
+
g(O) ? (i(), be(re, {
|
|
638
638
|
key: 1,
|
|
639
639
|
type: "button",
|
|
640
640
|
size: "icon",
|
|
641
641
|
variant: "outline",
|
|
642
642
|
class: "hidden absolute size-8 shrink-0 rounded-full shadow-sm md:inline-flex z-[11] right-0.5",
|
|
643
|
-
onClick: g(
|
|
643
|
+
onClick: g(ue)
|
|
644
644
|
}, {
|
|
645
645
|
default: c(() => [
|
|
646
646
|
r(g(Ye), { class: "size-4" })
|
|
647
647
|
]),
|
|
648
648
|
_: 1
|
|
649
|
-
}, 8, ["onClick"])) :
|
|
649
|
+
}, 8, ["onClick"])) : H("", !0)
|
|
650
650
|
])),
|
|
651
651
|
f("div", Ot, [
|
|
652
|
-
(i(!0), p(
|
|
652
|
+
(i(!0), p(ee, null, pe(g($), (b) => (i(), p("div", {
|
|
653
653
|
key: b,
|
|
654
654
|
class: "relative"
|
|
655
655
|
}, [
|
|
656
|
-
r(
|
|
656
|
+
r(re, {
|
|
657
657
|
type: "button",
|
|
658
658
|
variant: "outline",
|
|
659
659
|
class: "h-12 px-4 py-2"
|
|
660
660
|
}, {
|
|
661
661
|
default: c(() => [
|
|
662
|
-
|
|
662
|
+
N(R(b), 1)
|
|
663
663
|
]),
|
|
664
664
|
_: 2
|
|
665
665
|
}, 1024),
|
|
666
666
|
f("div", {
|
|
667
667
|
class: "absolute -top-1 -right-1 flex items-center justify-center bg-red-500 rounded-full text-white size-4 cursor-pointer",
|
|
668
668
|
onClick: (_e) => {
|
|
669
|
-
|
|
669
|
+
$.value = g($).filter((ce) => ce !== b), I.value = g(I).filter((ce) => ce !== b);
|
|
670
670
|
}
|
|
671
671
|
}, [
|
|
672
672
|
r(g(We), { class: "size-3" })
|
|
@@ -675,12 +675,12 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
675
675
|
])
|
|
676
676
|
]),
|
|
677
677
|
f("div", null, [
|
|
678
|
-
r(
|
|
679
|
-
disabled: !g(
|
|
678
|
+
r(re, {
|
|
679
|
+
disabled: !g(X),
|
|
680
680
|
onClick: ke
|
|
681
681
|
}, {
|
|
682
682
|
default: c(() => [
|
|
683
|
-
g(
|
|
683
|
+
g(I).length === 0 ? (i(), p("span", Mt, "Select at least one timeslot")) : g(I).length === 1 ? (i(), p("span", At, "Add 1 reservation")) : (i(), p("span", Et, "Add " + R(g(I).length) + " reservations", 1))
|
|
684
684
|
]),
|
|
685
685
|
_: 1
|
|
686
686
|
}, 8, ["disabled"])
|
|
@@ -688,7 +688,7 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
688
688
|
], 2);
|
|
689
689
|
};
|
|
690
690
|
}
|
|
691
|
-
}), Lt = /* @__PURE__ */ at(
|
|
691
|
+
}), Lt = /* @__PURE__ */ at(Ft, [["__scopeId", "data-v-30be47b0"]]), Pt = { class: "space-y-3" }, Ut = { class: "flex flex-wrap items-center justify-between gap-3" }, zt = { class: "text-xs text-muted-foreground" }, Bt = { class: "flex flex-wrap items-center gap-2" }, qt = {
|
|
692
692
|
key: 0,
|
|
693
693
|
class: "rounded-md border border-dashed bg-muted/20 px-4 py-6 text-sm text-muted-foreground"
|
|
694
694
|
}, jt = {
|
|
@@ -714,12 +714,12 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
714
714
|
availabilityByReservation: {}
|
|
715
715
|
},
|
|
716
716
|
emits: ["add", "quick-add", "update:modelValue"],
|
|
717
|
-
setup(
|
|
718
|
-
const
|
|
717
|
+
setup(U, { emit: G }) {
|
|
718
|
+
const E = U, Q = G, le = /^([01]\d|2[0-3]):[0-5]\d$/, j = ie(() => E.modelValue ?? []), Z = ie(() => Number(E.agendaData?.maxTicketsPerReservation) > 1), T = P(null), F = P(!1), V = ie(() => String(E.agendaData?.currency || "EUR").toUpperCase()), L = ie(() => {
|
|
719
719
|
try {
|
|
720
720
|
return new Intl.NumberFormat("en-US", {
|
|
721
721
|
style: "currency",
|
|
722
|
-
currency:
|
|
722
|
+
currency: V.value,
|
|
723
723
|
minimumFractionDigits: 2,
|
|
724
724
|
maximumFractionDigits: 2
|
|
725
725
|
});
|
|
@@ -729,11 +729,11 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
729
729
|
maximumFractionDigits: 2
|
|
730
730
|
});
|
|
731
731
|
}
|
|
732
|
-
}),
|
|
732
|
+
}), I = (s) => {
|
|
733
733
|
Q("update:modelValue", s);
|
|
734
|
-
}, Y = (s) => ["date", "resourceId", "pricingOption"].includes(s),
|
|
734
|
+
}, Y = (s) => ["date", "resourceId", "pricingOption"].includes(s), z = (s) => {
|
|
735
735
|
if (!s.date || !s.resourceId || !s.pricingOption) return s;
|
|
736
|
-
const n =
|
|
736
|
+
const n = oe(s);
|
|
737
737
|
return n.length === 0 ? {
|
|
738
738
|
...s,
|
|
739
739
|
startTime: ""
|
|
@@ -741,130 +741,130 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
741
741
|
...s,
|
|
742
742
|
startTime: n[0]
|
|
743
743
|
};
|
|
744
|
-
},
|
|
745
|
-
|
|
746
|
-
if (
|
|
744
|
+
}, B = (s, n, m) => {
|
|
745
|
+
I(j.value.map((x) => {
|
|
746
|
+
if (x.id !== s) return x;
|
|
747
747
|
if (n === "date") {
|
|
748
|
-
const
|
|
749
|
-
...
|
|
748
|
+
const te = {
|
|
749
|
+
...x,
|
|
750
750
|
date: String(m ?? ""),
|
|
751
751
|
dateValue: m || void 0
|
|
752
752
|
};
|
|
753
|
-
return
|
|
753
|
+
return z(te);
|
|
754
754
|
}
|
|
755
|
-
const
|
|
756
|
-
...
|
|
755
|
+
const A = {
|
|
756
|
+
...x,
|
|
757
757
|
[n]: m
|
|
758
758
|
};
|
|
759
|
-
return Y(n) ?
|
|
759
|
+
return Y(n) ? z(A) : A;
|
|
760
760
|
}));
|
|
761
|
-
},
|
|
761
|
+
}, J = (s, n) => {
|
|
762
762
|
const m = Number(n);
|
|
763
|
-
|
|
764
|
-
},
|
|
763
|
+
B(s, "paid", Number.isFinite(m) ? m : 0);
|
|
764
|
+
}, w = (s, n) => {
|
|
765
765
|
const m = Number(n);
|
|
766
|
-
|
|
767
|
-
},
|
|
768
|
-
|
|
769
|
-
},
|
|
770
|
-
Q("quick-add", s),
|
|
771
|
-
},
|
|
772
|
-
const n =
|
|
766
|
+
B(s, "spots", Number.isFinite(m) && m > 0 ? m : 1);
|
|
767
|
+
}, se = (s) => {
|
|
768
|
+
I(j.value.filter((n) => n.id !== s));
|
|
769
|
+
}, X = (s) => {
|
|
770
|
+
Q("quick-add", s), F.value = !1;
|
|
771
|
+
}, ae = (s) => E.agendaData?.pricingOptions?.find((n) => n.id === s.pricingOption), _ = (s) => {
|
|
772
|
+
const n = ae(s);
|
|
773
773
|
return n ? n.duration ? `${n.name} (${n.duration}min)` : n.name : "Reservation";
|
|
774
|
-
},
|
|
775
|
-
if (!s || !
|
|
774
|
+
}, O = (s) => E.agendaData?.resources?.find((n) => n.id === s.resourceId), S = (s) => O(s)?.name || "Unknown resource", k = (s) => {
|
|
775
|
+
if (!s || !le.test(s)) return null;
|
|
776
776
|
const [n, m] = s.split(":").map(Number);
|
|
777
777
|
return n * 60 + m;
|
|
778
|
-
},
|
|
779
|
-
const n = (s % 1440 + 1440) % 1440, m = Math.floor(n / 60),
|
|
780
|
-
return `${m.toString().padStart(2, "0")}:${
|
|
781
|
-
},
|
|
782
|
-
const n = Number(
|
|
778
|
+
}, M = (s) => {
|
|
779
|
+
const n = (s % 1440 + 1440) % 1440, m = Math.floor(n / 60), x = n % 60;
|
|
780
|
+
return `${m.toString().padStart(2, "0")}:${x.toString().padStart(2, "0")}`;
|
|
781
|
+
}, ue = (s) => {
|
|
782
|
+
const n = Number(ae(s)?.duration);
|
|
783
783
|
return Number.isFinite(n) && n > 0 ? n : 0;
|
|
784
784
|
}, ye = (s) => {
|
|
785
785
|
if (!s.startTime) return "";
|
|
786
|
-
const n =
|
|
786
|
+
const n = ue(s);
|
|
787
787
|
if (n <= 0) return "";
|
|
788
|
-
const m =
|
|
789
|
-
return m === null ? "" :
|
|
788
|
+
const m = k(s.startTime);
|
|
789
|
+
return m === null ? "" : M(m + n);
|
|
790
790
|
}, me = (s) => {
|
|
791
791
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(s)) return null;
|
|
792
|
-
const [n, m,
|
|
793
|
-
return Number.isNaN(
|
|
794
|
-
}, de = (s, n) => (
|
|
795
|
-
const n =
|
|
792
|
+
const [n, m, x] = s.split("-").map(Number), A = new Date(n, m - 1, x);
|
|
793
|
+
return Number.isNaN(A.getTime()) || A.getFullYear() !== n || A.getMonth() !== m - 1 || A.getDate() !== x ? null : A;
|
|
794
|
+
}, de = (s, n) => (E.agendaData?.exceptions || []).find((x) => n >= x.startDate && n <= x.endDate ? !x.resourceIds || x.resourceIds.length === 0 ? !0 : x.resourceIds.includes(s) : !1) || null, fe = (s) => {
|
|
795
|
+
const n = O(s), m = me(s.date);
|
|
796
796
|
if (!n || !m) return [];
|
|
797
|
-
const
|
|
798
|
-
if (
|
|
799
|
-
return
|
|
800
|
-
start:
|
|
801
|
-
end:
|
|
797
|
+
const x = de(n.id, s.date);
|
|
798
|
+
if (x)
|
|
799
|
+
return x.isClosed ? [] : (x.timeslots || []).map((te) => ({
|
|
800
|
+
start: te.startTime,
|
|
801
|
+
end: te.endTime
|
|
802
802
|
}));
|
|
803
|
-
const
|
|
804
|
-
return n.openingHours?.[
|
|
805
|
-
},
|
|
806
|
-
const n =
|
|
803
|
+
const A = m.getDay();
|
|
804
|
+
return n.openingHours?.[A] || [];
|
|
805
|
+
}, oe = (s) => {
|
|
806
|
+
const n = O(s);
|
|
807
807
|
if (!n) return [];
|
|
808
|
-
const m = Number(n.interval) > 0 ? Number(n.interval) : 60,
|
|
809
|
-
for (const
|
|
810
|
-
const
|
|
811
|
-
if (
|
|
812
|
-
const _e =
|
|
813
|
-
for (let ce =
|
|
814
|
-
|
|
808
|
+
const m = Number(n.interval) > 0 ? Number(n.interval) : 60, x = ue(s), A = /* @__PURE__ */ new Set();
|
|
809
|
+
for (const te of fe(s)) {
|
|
810
|
+
const K = k(te.start), b = k(te.end);
|
|
811
|
+
if (K === null || b === null || b <= K) continue;
|
|
812
|
+
const _e = x > 0 ? b - x : b - m;
|
|
813
|
+
for (let ce = K; ce <= _e; ce += m)
|
|
814
|
+
A.add(M(ce));
|
|
815
815
|
}
|
|
816
|
-
return Array.from(
|
|
816
|
+
return Array.from(A).sort((te, K) => (k(te) ?? 0) - (k(K) ?? 0));
|
|
817
817
|
}, ge = (s) => {
|
|
818
818
|
if (!s.startTime) return "Select time";
|
|
819
819
|
const n = ye(s);
|
|
820
820
|
return n ? `${s.startTime} - ${n}` : s.startTime;
|
|
821
|
-
},
|
|
821
|
+
}, ve = (s) => {
|
|
822
822
|
const n = Number(s);
|
|
823
|
-
if (!Number.isFinite(n)) return
|
|
823
|
+
if (!Number.isFinite(n)) return V.value === "EUR" ? "€0.00" : "0.00";
|
|
824
824
|
try {
|
|
825
|
-
return
|
|
825
|
+
return L.value.format(n);
|
|
826
826
|
} catch {
|
|
827
827
|
return `${n.toFixed(2)}`;
|
|
828
828
|
}
|
|
829
|
-
},
|
|
829
|
+
}, v = (s) => {
|
|
830
830
|
const n = Number(s.spots), m = Number.isFinite(n) && n > 0 ? n : 1;
|
|
831
831
|
return m === 1 ? "1 spot" : `${m} spots`;
|
|
832
|
-
},
|
|
833
|
-
const n =
|
|
832
|
+
}, $ = (s) => E.availabilityByReservation?.[s.id] ?? null, ke = (s) => {
|
|
833
|
+
const n = $(s);
|
|
834
834
|
return !n || n.status === "checking" ? "text-muted-foreground" : n.status === "available" ? "text-green-600 dark:text-green-400" : "text-red-600 dark:text-red-400";
|
|
835
835
|
}, xe = (s) => {
|
|
836
836
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(s)) return null;
|
|
837
|
-
const [n, m,
|
|
838
|
-
return Number.isNaN(
|
|
837
|
+
const [n, m, x] = s.split("-").map(Number), A = new Date(n, m - 1, x);
|
|
838
|
+
return Number.isNaN(A.getTime()) || A.getFullYear() !== n || A.getMonth() !== m - 1 || A.getDate() !== x ? null : (A.setHours(0, 0, 0, 0), A);
|
|
839
839
|
}, a = (s) => {
|
|
840
840
|
const n = xe(String(s.date || "").trim());
|
|
841
841
|
if (!n) return "";
|
|
842
842
|
const m = /* @__PURE__ */ new Date();
|
|
843
843
|
if (m.setHours(0, 0, 0, 0), n < m)
|
|
844
844
|
return "This date is in the past. Double-check it before saving.";
|
|
845
|
-
const
|
|
846
|
-
return
|
|
847
|
-
}, l = (s) => !s.date || !s.startTime || !s.resourceId || !s.pricingOption,
|
|
848
|
-
|
|
845
|
+
const x = new Date(m);
|
|
846
|
+
return x.setFullYear(x.getFullYear() + 1), n > x ? "This date is more than a year ahead. Double-check it before saving." : "";
|
|
847
|
+
}, l = (s) => !s.date || !s.startTime || !s.resourceId || !s.pricingOption, D = (s) => T.value === s, re = (s) => {
|
|
848
|
+
T.value = T.value === s ? null : s;
|
|
849
849
|
};
|
|
850
|
-
return Re(
|
|
850
|
+
return Re(j, (s) => {
|
|
851
851
|
const n = new Set(s.map((m) => m.id));
|
|
852
|
-
if (
|
|
852
|
+
if (T.value && !n.has(T.value) && (T.value = null), !T.value) {
|
|
853
853
|
const m = s.find(l);
|
|
854
|
-
m && (
|
|
854
|
+
m && (T.value = m.id);
|
|
855
855
|
}
|
|
856
856
|
}, { immediate: !0 }), (s, n) => {
|
|
857
|
-
const m = h("Button"),
|
|
857
|
+
const m = h("Button"), x = h("PopoverTrigger"), A = h("PopoverContent"), te = h("Popover"), K = h("Label"), b = h("DynamicSelectOption"), _e = h("DynamicSelect"), ce = h("Input"), Ce = h("SelectValue"), Ne = h("SelectTrigger"), e = h("SelectItem"), o = h("SelectContent"), d = h("Select");
|
|
858
858
|
return i(), p("div", Pt, [
|
|
859
859
|
f("div", Ut, [
|
|
860
|
-
f("p", zt,
|
|
860
|
+
f("p", zt, R(j.value.length === 1 ? "1 reservation line" : `${j.value.length} reservation lines`), 1),
|
|
861
861
|
f("div", Bt, [
|
|
862
|
-
r(
|
|
863
|
-
open:
|
|
864
|
-
"onUpdate:open": n[0] || (n[0] = (t) =>
|
|
862
|
+
r(te, {
|
|
863
|
+
open: F.value,
|
|
864
|
+
"onUpdate:open": n[0] || (n[0] = (t) => F.value = t)
|
|
865
865
|
}, {
|
|
866
866
|
default: c(() => [
|
|
867
|
-
r(
|
|
867
|
+
r(x, { "as-child": "" }, {
|
|
868
868
|
default: c(() => [
|
|
869
869
|
r(m, {
|
|
870
870
|
type: "button",
|
|
@@ -874,24 +874,24 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
874
874
|
}, {
|
|
875
875
|
default: c(() => [
|
|
876
876
|
r(g(Ge), { class: "size-4 text-primary" }),
|
|
877
|
-
n[2] || (n[2] =
|
|
877
|
+
n[2] || (n[2] = N(" Quick add ", -1))
|
|
878
878
|
]),
|
|
879
879
|
_: 1
|
|
880
880
|
})
|
|
881
881
|
]),
|
|
882
882
|
_: 1
|
|
883
883
|
}),
|
|
884
|
-
r(
|
|
884
|
+
r(A, {
|
|
885
885
|
align: "end",
|
|
886
886
|
class: "max-h-[80vh] w-[min(34rem,calc(100vw-2rem))] overflow-y-auto p-0"
|
|
887
887
|
}, {
|
|
888
888
|
default: c(() => [
|
|
889
|
-
|
|
889
|
+
F.value ? (i(), be(Lt, {
|
|
890
890
|
key: 0,
|
|
891
891
|
surface: "popover",
|
|
892
|
-
agendaData:
|
|
893
|
-
onAdd:
|
|
894
|
-
}, null, 8, ["agendaData"])) :
|
|
892
|
+
agendaData: U.agendaData,
|
|
893
|
+
onAdd: X
|
|
894
|
+
}, null, 8, ["agendaData"])) : H("", !0)
|
|
895
895
|
]),
|
|
896
896
|
_: 1
|
|
897
897
|
})
|
|
@@ -906,14 +906,14 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
906
906
|
}, {
|
|
907
907
|
default: c(() => [
|
|
908
908
|
r(g(Pe), { class: "size-4" }),
|
|
909
|
-
n[3] || (n[3] =
|
|
909
|
+
n[3] || (n[3] = N(" Add line ", -1))
|
|
910
910
|
]),
|
|
911
911
|
_: 1
|
|
912
912
|
})
|
|
913
913
|
])
|
|
914
914
|
]),
|
|
915
|
-
|
|
916
|
-
(i(!0), p(
|
|
915
|
+
j.value.length === 0 ? (i(), p("div", qt, " Use Quick add to create filled reservation lines, or add an empty line manually. ")) : (i(), p("div", jt, [
|
|
916
|
+
(i(!0), p(ee, null, pe(j.value, (t, y) => (i(), p("div", {
|
|
917
917
|
key: t.id,
|
|
918
918
|
class: "rounded-xl border bg-background"
|
|
919
919
|
}, [
|
|
@@ -921,20 +921,20 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
921
921
|
f("button", {
|
|
922
922
|
type: "button",
|
|
923
923
|
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",
|
|
924
|
-
"aria-expanded":
|
|
925
|
-
onClick: (u) =>
|
|
924
|
+
"aria-expanded": D(t.id),
|
|
925
|
+
onClick: (u) => re(t.id)
|
|
926
926
|
}, [
|
|
927
|
-
f("span", Yt,
|
|
927
|
+
f("span", Yt, R(y + 1), 1),
|
|
928
928
|
f("span", Wt, [
|
|
929
929
|
f("span", Gt, [
|
|
930
930
|
f("span", Xt, [
|
|
931
|
-
f("span", Zt,
|
|
932
|
-
f("span", Jt,
|
|
933
|
-
f("span", Kt,
|
|
934
|
-
|
|
931
|
+
f("span", Zt, R(ge(t)), 1),
|
|
932
|
+
f("span", Jt, R(t.date || "No date selected"), 1),
|
|
933
|
+
f("span", Kt, R(S(t)) + " · " + R(_(t)), 1),
|
|
934
|
+
$(t)?.message ? (i(), p("span", {
|
|
935
935
|
key: 0,
|
|
936
936
|
class: he(["mt-1 block text-xs font-medium", ke(t)])
|
|
937
|
-
},
|
|
937
|
+
}, R($(t)?.message), 3)) : H("", !0)
|
|
938
938
|
]),
|
|
939
939
|
f("span", en, [
|
|
940
940
|
r(g(Xe), { class: "size-4" })
|
|
@@ -943,11 +943,11 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
943
943
|
f("span", tn, [
|
|
944
944
|
f("span", nn, [
|
|
945
945
|
r(g(Ze), { class: "size-4" }),
|
|
946
|
-
|
|
946
|
+
N(" " + R(v(t)), 1)
|
|
947
947
|
]),
|
|
948
948
|
f("span", sn, [
|
|
949
949
|
r(g(Je), { class: "size-4" }),
|
|
950
|
-
|
|
950
|
+
N(" " + R(ve(t.paid)), 1)
|
|
951
951
|
])
|
|
952
952
|
])
|
|
953
953
|
])
|
|
@@ -957,7 +957,7 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
957
957
|
variant: "ghost",
|
|
958
958
|
size: "icon",
|
|
959
959
|
class: "mt-1 shrink-0",
|
|
960
|
-
onClick: (u) =>
|
|
960
|
+
onClick: (u) => se(t.id)
|
|
961
961
|
}, {
|
|
962
962
|
default: c(() => [
|
|
963
963
|
r(g(Me), { class: "size-4" })
|
|
@@ -967,19 +967,19 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
967
967
|
]),
|
|
968
968
|
f("div", an, [
|
|
969
969
|
f("div", null, [
|
|
970
|
-
f("p", on, "Reservation " +
|
|
971
|
-
f("p", rn,
|
|
972
|
-
|
|
970
|
+
f("p", on, "Reservation " + R(y + 1), 1),
|
|
971
|
+
f("p", rn, R(S(t)) + " · " + R(_(t)), 1),
|
|
972
|
+
$(t)?.message ? (i(), p("p", {
|
|
973
973
|
key: 0,
|
|
974
974
|
class: he(["mt-1 text-xs font-medium", ke(t)])
|
|
975
|
-
},
|
|
975
|
+
}, R($(t)?.message), 3)) : H("", !0)
|
|
976
976
|
]),
|
|
977
977
|
r(m, {
|
|
978
978
|
type: "button",
|
|
979
979
|
variant: "ghost",
|
|
980
980
|
size: "icon",
|
|
981
981
|
class: "shrink-0",
|
|
982
|
-
onClick: (u) =>
|
|
982
|
+
onClick: (u) => se(t.id)
|
|
983
983
|
}, {
|
|
984
984
|
default: c(() => [
|
|
985
985
|
r(g(Me), { class: "size-4" })
|
|
@@ -988,13 +988,13 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
988
988
|
}, 8, ["onClick"])
|
|
989
989
|
]),
|
|
990
990
|
f("div", {
|
|
991
|
-
class: he(["px-3 pb-3 md:px-4 md:pb-4 overflow-hidden",
|
|
991
|
+
class: he(["px-3 pb-3 md:px-4 md:pb-4 overflow-hidden", D(t.id) ? "block" : "hidden md:block"])
|
|
992
992
|
}, [
|
|
993
993
|
f("div", ln, [
|
|
994
994
|
f("div", un, [
|
|
995
|
-
r(
|
|
995
|
+
r(K, null, {
|
|
996
996
|
default: c(() => [...n[4] || (n[4] = [
|
|
997
|
-
|
|
997
|
+
N("Resource", -1)
|
|
998
998
|
])]),
|
|
999
999
|
_: 1
|
|
1000
1000
|
}),
|
|
@@ -1003,15 +1003,15 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1003
1003
|
"wrapper-class": "w-full",
|
|
1004
1004
|
class: "w-full",
|
|
1005
1005
|
placeholder: "Select resource",
|
|
1006
|
-
"onUpdate:modelValue": (u) =>
|
|
1006
|
+
"onUpdate:modelValue": (u) => B(t.id, "resourceId", String(u ?? ""))
|
|
1007
1007
|
}, {
|
|
1008
1008
|
default: c(() => [
|
|
1009
|
-
(i(!0), p(
|
|
1009
|
+
(i(!0), p(ee, null, pe(U.agendaData?.resources || [], (u) => (i(), be(b, {
|
|
1010
1010
|
key: u.id,
|
|
1011
1011
|
value: u.id
|
|
1012
1012
|
}, {
|
|
1013
1013
|
default: c(() => [
|
|
1014
|
-
|
|
1014
|
+
N(R(u.name), 1)
|
|
1015
1015
|
]),
|
|
1016
1016
|
_: 2
|
|
1017
1017
|
}, 1032, ["value"]))), 128))
|
|
@@ -1020,32 +1020,32 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1020
1020
|
}, 8, ["model-value", "onUpdate:modelValue"])
|
|
1021
1021
|
]),
|
|
1022
1022
|
f("div", dn, [
|
|
1023
|
-
r(
|
|
1023
|
+
r(K, null, {
|
|
1024
1024
|
default: c(() => [...n[5] || (n[5] = [
|
|
1025
|
-
|
|
1025
|
+
N("Date", -1)
|
|
1026
1026
|
])]),
|
|
1027
1027
|
_: 1
|
|
1028
1028
|
}),
|
|
1029
1029
|
r(ce, {
|
|
1030
1030
|
"model-value": t.date,
|
|
1031
1031
|
type: "date",
|
|
1032
|
-
"onUpdate:modelValue": (u) =>
|
|
1032
|
+
"onUpdate:modelValue": (u) => B(t.id, "date", String(u ?? ""))
|
|
1033
1033
|
}, null, 8, ["model-value", "onUpdate:modelValue"]),
|
|
1034
|
-
a(t) ? (i(), p("p", cn,
|
|
1034
|
+
a(t) ? (i(), p("p", cn, R(a(t)), 1)) : H("", !0)
|
|
1035
1035
|
]),
|
|
1036
1036
|
f("div", pn, [
|
|
1037
|
-
r(
|
|
1037
|
+
r(K, {
|
|
1038
1038
|
for: `new_reservation_res_line_${y}_time`
|
|
1039
1039
|
}, {
|
|
1040
1040
|
default: c(() => [...n[6] || (n[6] = [
|
|
1041
|
-
|
|
1041
|
+
N("Time", -1)
|
|
1042
1042
|
])]),
|
|
1043
1043
|
_: 1
|
|
1044
1044
|
}, 8, ["for"]),
|
|
1045
|
-
t.resourceId && t.date ? (i(), p(
|
|
1045
|
+
t.resourceId && t.date ? (i(), p(ee, { key: 0 }, [
|
|
1046
1046
|
r(d, {
|
|
1047
1047
|
"model-value": t.startTime,
|
|
1048
|
-
"onUpdate:modelValue": (u) =>
|
|
1048
|
+
"onUpdate:modelValue": (u) => B(t.id, "startTime", String(u ?? ""))
|
|
1049
1049
|
}, {
|
|
1050
1050
|
default: c(() => [
|
|
1051
1051
|
r(Ne, {
|
|
@@ -1059,12 +1059,12 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1059
1059
|
}, 8, ["id"]),
|
|
1060
1060
|
r(o, null, {
|
|
1061
1061
|
default: c(() => [
|
|
1062
|
-
(i(!0), p(
|
|
1062
|
+
(i(!0), p(ee, null, pe(oe(t), (u) => (i(), be(e, {
|
|
1063
1063
|
key: u,
|
|
1064
1064
|
value: u
|
|
1065
1065
|
}, {
|
|
1066
1066
|
default: c(() => [
|
|
1067
|
-
|
|
1067
|
+
N(R(u), 1)
|
|
1068
1068
|
]),
|
|
1069
1069
|
_: 2
|
|
1070
1070
|
}, 1032, ["value"]))), 128))
|
|
@@ -1074,17 +1074,17 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1074
1074
|
]),
|
|
1075
1075
|
_: 2
|
|
1076
1076
|
}, 1032, ["model-value", "onUpdate:modelValue"]),
|
|
1077
|
-
t.resourceId && t.date &&
|
|
1077
|
+
t.resourceId && t.date && oe(t).length === 0 ? (i(), p("p", mn, " No times are available for this resource on the selected date. ")) : H("", !0)
|
|
1078
1078
|
], 64)) : (i(), p("p", fn, [
|
|
1079
|
-
!t.resourceId && !t.date ? (i(), p("span", gn, "Please select a resource and date.")) : t.resourceId ? t.date ?
|
|
1079
|
+
!t.resourceId && !t.date ? (i(), p("span", gn, "Please select a resource and date.")) : t.resourceId ? t.date ? H("", !0) : (i(), p("span", _n, "Please select a date.")) : (i(), p("span", vn, "Please select a resource."))
|
|
1080
1080
|
]))
|
|
1081
1081
|
]),
|
|
1082
1082
|
f("div", {
|
|
1083
|
-
class: he(["grid gap-2", { hidden:
|
|
1083
|
+
class: he(["grid gap-2", { hidden: U.agendaData?.pricingOptions?.length < 2 }])
|
|
1084
1084
|
}, [
|
|
1085
|
-
r(
|
|
1085
|
+
r(K, null, {
|
|
1086
1086
|
default: c(() => [...n[7] || (n[7] = [
|
|
1087
|
-
|
|
1087
|
+
N("Type", -1)
|
|
1088
1088
|
])]),
|
|
1089
1089
|
_: 1
|
|
1090
1090
|
}),
|
|
@@ -1093,15 +1093,15 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1093
1093
|
"wrapper-class": "w-full",
|
|
1094
1094
|
class: "w-full",
|
|
1095
1095
|
placeholder: "Select type",
|
|
1096
|
-
"onUpdate:modelValue": (u) =>
|
|
1096
|
+
"onUpdate:modelValue": (u) => B(t.id, "pricingOption", String(u ?? ""))
|
|
1097
1097
|
}, {
|
|
1098
1098
|
default: c(() => [
|
|
1099
|
-
(i(!0), p(
|
|
1099
|
+
(i(!0), p(ee, null, pe(U.agendaData?.pricingOptions || [], (u) => (i(), be(b, {
|
|
1100
1100
|
key: u.id,
|
|
1101
1101
|
value: u.id
|
|
1102
1102
|
}, {
|
|
1103
1103
|
default: c(() => [
|
|
1104
|
-
|
|
1104
|
+
N(R(u.name), 1)
|
|
1105
1105
|
]),
|
|
1106
1106
|
_: 2
|
|
1107
1107
|
}, 1032, ["value"]))), 128))
|
|
@@ -1110,12 +1110,12 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1110
1110
|
}, 8, ["model-value", "onUpdate:modelValue"])
|
|
1111
1111
|
], 2),
|
|
1112
1112
|
f("div", {
|
|
1113
|
-
class: he(["grid gap-4",
|
|
1113
|
+
class: he(["grid gap-4", Z.value ? "md:grid-cols-2 xl:grid-cols-2 xl:col-span-1" : ""])
|
|
1114
1114
|
}, [
|
|
1115
|
-
|
|
1116
|
-
r(
|
|
1115
|
+
Z.value ? (i(), p("div", hn, [
|
|
1116
|
+
r(K, null, {
|
|
1117
1117
|
default: c(() => [...n[8] || (n[8] = [
|
|
1118
|
-
|
|
1118
|
+
N("Spots", -1)
|
|
1119
1119
|
])]),
|
|
1120
1120
|
_: 1
|
|
1121
1121
|
}),
|
|
@@ -1124,15 +1124,15 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1124
1124
|
type: "number",
|
|
1125
1125
|
min: "1",
|
|
1126
1126
|
class: "no-spinner",
|
|
1127
|
-
"onUpdate:modelValue": (u) =>
|
|
1127
|
+
"onUpdate:modelValue": (u) => w(t.id, u)
|
|
1128
1128
|
}, null, 8, ["model-value", "onUpdate:modelValue"])
|
|
1129
|
-
])) :
|
|
1129
|
+
])) : H("", !0),
|
|
1130
1130
|
f("div", {
|
|
1131
|
-
class: he(["grid gap-2",
|
|
1131
|
+
class: he(["grid gap-2", Z.value ? "" : "md:col-span-2 xl:col-span-1"])
|
|
1132
1132
|
}, [
|
|
1133
|
-
r(
|
|
1133
|
+
r(K, null, {
|
|
1134
1134
|
default: c(() => [...n[9] || (n[9] = [
|
|
1135
|
-
|
|
1135
|
+
N("Paid", -1)
|
|
1136
1136
|
])]),
|
|
1137
1137
|
_: 1
|
|
1138
1138
|
}),
|
|
@@ -1142,7 +1142,7 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1142
1142
|
min: "0",
|
|
1143
1143
|
step: "1",
|
|
1144
1144
|
class: "no-spinner",
|
|
1145
|
-
"onUpdate:modelValue": (u) =>
|
|
1145
|
+
"onUpdate:modelValue": (u) => J(t.id, u)
|
|
1146
1146
|
}, null, 8, ["model-value", "onUpdate:modelValue"])
|
|
1147
1147
|
], 2)
|
|
1148
1148
|
], 2)
|
|
@@ -1153,55 +1153,55 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1153
1153
|
]);
|
|
1154
1154
|
};
|
|
1155
1155
|
}
|
|
1156
|
-
}), yn = { class: "space-y-5 md:mt-5" }, xn = { class: "space-y-3" }, Sn = { class: "mt-4 text-red-400" }, kn = { class: "list-disc pl-4" }, $n = { key: 0 }, Tn = { key: 1 }, In = { key: 2 },
|
|
1156
|
+
}), yn = { class: "space-y-5 md:mt-5" }, xn = { class: "space-y-3" }, Sn = { class: "mt-4 text-red-400" }, kn = { class: "list-disc pl-4" }, $n = { key: 0 }, Tn = { key: 1 }, In = { key: 2 }, Ee = "", Vn = /* @__PURE__ */ De({
|
|
1157
1157
|
__name: "NewReservationDialog",
|
|
1158
1158
|
props: {
|
|
1159
1159
|
agendaData: {}
|
|
1160
1160
|
},
|
|
1161
|
-
setup(
|
|
1162
|
-
const
|
|
1163
|
-
let
|
|
1164
|
-
const
|
|
1161
|
+
setup(U) {
|
|
1162
|
+
const G = U, { params: E } = Ke(), { config: Q } = et(), { log: le, logError: j } = tt(), Z = nt(Q.project), T = ie(() => E.value?.id ?? E.id ?? ""), F = qe("agendaData", P({})), V = ie(() => G.agendaData ?? F.value ?? {}), L = P(!1), I = P(!1), Y = P({});
|
|
1163
|
+
let z = 0;
|
|
1164
|
+
const B = P([]), J = /^([01]\d|2[0-3]):[0-5]\d$/, w = P([]), se = P(null), X = ie(() => Object.values(Y.value).some((e) => e.status === "checking")), ae = ie(() => Object.values(Y.value).some((e) => e.status === "unavailable")), _ = () => V.value?.resources?.[0]?.id ?? "", O = () => V.value?.pricingOptions?.find((e) => e.isDefault === !0)?.id ?? V.value?.pricingOptions?.[0]?.id ?? "", S = () => {
|
|
1165
1165
|
const e = /* @__PURE__ */ new Date(), o = e.getFullYear(), d = `${e.getMonth() + 1}`.padStart(2, "0"), t = `${e.getDate()}`.padStart(2, "0");
|
|
1166
1166
|
return `${o}-${d}-${t}`;
|
|
1167
|
-
},
|
|
1168
|
-
let o = e?.pricingOption ??
|
|
1167
|
+
}, k = (e) => {
|
|
1168
|
+
let o = e?.pricingOption ?? O(), d = V.value?.pricingOptions?.find((y) => y.id === o)?.price ?? 0;
|
|
1169
1169
|
typeof d == "string" && (d = Number(d));
|
|
1170
1170
|
let t = e?.paid ?? d;
|
|
1171
1171
|
return typeof t == "string" && (t = Number(t)), {
|
|
1172
1172
|
id: `reservation_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
|
|
1173
1173
|
spots: Number(e?.spots) || 1,
|
|
1174
1174
|
paid: Number.isFinite(t) ? t : 0,
|
|
1175
|
-
resourceId: e?.resourceId ??
|
|
1175
|
+
resourceId: e?.resourceId ?? _(),
|
|
1176
1176
|
pricingOption: o,
|
|
1177
|
-
date: e?.date ??
|
|
1177
|
+
date: e?.date ?? S(),
|
|
1178
1178
|
dateValue: e?.dateValue,
|
|
1179
|
-
startTime: e?.startTime ??
|
|
1179
|
+
startTime: e?.startTime ?? Ee
|
|
1180
1180
|
};
|
|
1181
|
-
},
|
|
1182
|
-
|
|
1183
|
-
},
|
|
1184
|
-
const e =
|
|
1185
|
-
|
|
1186
|
-
}, me = (e) =>
|
|
1187
|
-
const e = Number(
|
|
1181
|
+
}, M = () => {
|
|
1182
|
+
w.value = [k()];
|
|
1183
|
+
}, ue = (e) => (!e.date || e.date === S()) && e.startTime === Ee, ye = () => {
|
|
1184
|
+
const e = w.value[w.value.length - 1];
|
|
1185
|
+
w.value = [...w.value, k(e ? { ...e } : void 0)];
|
|
1186
|
+
}, me = (e) => V.value?.pricingOptions?.find((o) => o.id === e.pricingOption), de = (e) => V.value?.resources?.find((o) => o.id === e.resourceId), fe = () => {
|
|
1187
|
+
const e = Number(V.value?.maxTicketsPerReservation);
|
|
1188
1188
|
return Number.isFinite(e) && e > 0 ? e : null;
|
|
1189
|
-
},
|
|
1189
|
+
}, oe = (e) => `Reservation ${e + 1}`, ge = (e) => {
|
|
1190
1190
|
const o = String(e.date || "").trim(), d = String(e.startTime || "").trim(), t = String(e.resourceId || "").trim();
|
|
1191
1191
|
return !o || !d || !t ? "" : `${t}_${o}_${d}`;
|
|
1192
|
-
},
|
|
1192
|
+
}, ve = () => {
|
|
1193
1193
|
const e = [], o = /* @__PURE__ */ new Map(), d = fe();
|
|
1194
|
-
return
|
|
1195
|
-
const u =
|
|
1196
|
-
|
|
1194
|
+
return w.value.forEach((t, y) => {
|
|
1195
|
+
const u = oe(y), q = String(t.date || "").trim(), W = String(t.startTime || "").trim(), C = String(t.resourceId || "").trim(), ne = String(t.pricingOption || "").trim(), Te = Number(t.spots), $e = Number(t.paid);
|
|
1196
|
+
q || e.push(`${u}: please select a date.`), W ? J.test(W) || e.push(`${u}: please enter a valid time.`) : e.push(`${u}: please select a time.`), C ? de(t) || e.push(`${u}: the selected resource is no longer available.`) : e.push(`${u}: please select a resource.`), ne ? me(t) || e.push(`${u}: the selected type is no longer available.`) : e.push(`${u}: please select a type.`), !Number.isFinite(Te) || Te <= 0 ? e.push(`${u}: spots must be at least 1.`) : d !== null && Te > d && e.push(`${u}: spots cannot be more than ${d}.`), (!Number.isFinite($e) || $e < 0) && e.push(`${u}: paid amount must be 0 or higher.`);
|
|
1197
1197
|
const Se = ge(t);
|
|
1198
1198
|
if (Se) {
|
|
1199
1199
|
const Ie = o.get(Se);
|
|
1200
|
-
Ie !== void 0 ? e.push(`${u}: duplicate of ${
|
|
1200
|
+
Ie !== void 0 ? e.push(`${u}: duplicate of ${oe(Ie).toLowerCase()}.`) : o.set(Se, y);
|
|
1201
1201
|
}
|
|
1202
1202
|
}), e;
|
|
1203
|
-
},
|
|
1204
|
-
const o = e.startTimes.map((d) =>
|
|
1203
|
+
}, v = (e) => {
|
|
1204
|
+
const o = e.startTimes.map((d) => k({
|
|
1205
1205
|
date: e.date ? `${e.date}` : "",
|
|
1206
1206
|
dateValue: e.date,
|
|
1207
1207
|
pricingOption: e.pricingOptionId,
|
|
@@ -1211,14 +1211,14 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1211
1211
|
startTime: d
|
|
1212
1212
|
}));
|
|
1213
1213
|
if (o.length !== 0) {
|
|
1214
|
-
if (
|
|
1215
|
-
|
|
1214
|
+
if (w.value.length === 1 && ue(w.value[0])) {
|
|
1215
|
+
w.value = o;
|
|
1216
1216
|
return;
|
|
1217
1217
|
}
|
|
1218
|
-
|
|
1218
|
+
w.value = [...w.value, ...o];
|
|
1219
1219
|
}
|
|
1220
|
-
},
|
|
1221
|
-
if (!e || !
|
|
1220
|
+
}, $ = (e) => {
|
|
1221
|
+
if (!e || !J.test(e)) return null;
|
|
1222
1222
|
const [o, d] = e.split(":").map(Number);
|
|
1223
1223
|
return o * 60 + d;
|
|
1224
1224
|
}, ke = (e) => {
|
|
@@ -1228,7 +1228,7 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1228
1228
|
if (!e.startTime || !e.pricingOption) return "";
|
|
1229
1229
|
const o = me(e), d = Number(o?.duration);
|
|
1230
1230
|
if (!Number.isFinite(d) || d <= 0) return e.startTime;
|
|
1231
|
-
const t =
|
|
1231
|
+
const t = $(e.startTime);
|
|
1232
1232
|
return t === null ? "" : ke(t + d);
|
|
1233
1233
|
}, a = (e) => {
|
|
1234
1234
|
const o = Number(e.spots);
|
|
@@ -1236,8 +1236,8 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1236
1236
|
}, l = (e) => {
|
|
1237
1237
|
const o = Number(de(e)?.capacity);
|
|
1238
1238
|
return Number.isFinite(o) && o > 0 ? o : 1;
|
|
1239
|
-
},
|
|
1240
|
-
const o = String(e.date || "").trim(), d = String(e.resourceId || "").trim(), t =
|
|
1239
|
+
}, D = (e) => {
|
|
1240
|
+
const o = String(e.date || "").trim(), d = String(e.resourceId || "").trim(), t = $(e.startTime), y = $(xe(e));
|
|
1241
1241
|
return !o || !d || !de(e) || !me(e) || t === null || y === null || y <= t ? null : {
|
|
1242
1242
|
reservation: e,
|
|
1243
1243
|
date: o,
|
|
@@ -1247,114 +1247,114 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1247
1247
|
capacity: l(e),
|
|
1248
1248
|
requestedSpots: a(e)
|
|
1249
1249
|
};
|
|
1250
|
-
},
|
|
1250
|
+
}, re = (e) => ["approved", "needs_approval"].includes(e?.status), s = (e, o, d, t) => e < t && o > d, n = (e) => `${e} ${e === 1 ? "spot" : "spots"}`, m = (e, o, d) => e < d ? {
|
|
1251
1251
|
status: "unavailable",
|
|
1252
1252
|
message: `Not enough spots: ${n(Math.max(e, 0))} open, needs ${n(d)}.`
|
|
1253
1253
|
} : {
|
|
1254
1254
|
status: "available",
|
|
1255
1255
|
message: `Available: ${e} of ${o} ${o === 1 ? "spot" : "spots"} open, ${n(e - d)} will remain.`
|
|
1256
|
-
},
|
|
1256
|
+
}, x = (e) => e?.id || e?.orderId || "", A = (e, o) => {
|
|
1257
1257
|
const d = [];
|
|
1258
1258
|
for (let t = 0; t < e.length; t += o)
|
|
1259
1259
|
d.push(e.slice(t, t + o));
|
|
1260
1260
|
return d;
|
|
1261
|
-
},
|
|
1261
|
+
}, te = async (e) => {
|
|
1262
1262
|
const o = /* @__PURE__ */ new Map(), d = [];
|
|
1263
|
-
for (const t of
|
|
1263
|
+
for (const t of A(e, 10)) {
|
|
1264
1264
|
const y = [
|
|
1265
1265
|
{ field: "status", operator: "==", value: "confirmed" },
|
|
1266
1266
|
{ field: "flattenedReservationDates", operator: "array-contains-any", value: t }
|
|
1267
1267
|
];
|
|
1268
|
-
|
|
1269
|
-
const u = await
|
|
1270
|
-
for (const
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1268
|
+
T.value && y.unshift({ field: "agendaId", operator: "==", value: T.value });
|
|
1269
|
+
const u = await Z.find(Q.reservationsCollection, { filters: y });
|
|
1270
|
+
for (const q of u || []) {
|
|
1271
|
+
const W = x(q);
|
|
1272
|
+
W ? o.set(W, q) : d.push(q);
|
|
1273
1273
|
}
|
|
1274
1274
|
}
|
|
1275
1275
|
return [...o.values(), ...d];
|
|
1276
|
-
},
|
|
1276
|
+
}, K = (e, o) => {
|
|
1277
1277
|
let d = 0;
|
|
1278
1278
|
for (const t of e)
|
|
1279
1279
|
for (const y of t?.reservations || []) {
|
|
1280
|
-
if (!
|
|
1281
|
-
const u =
|
|
1282
|
-
if (u === null ||
|
|
1283
|
-
const
|
|
1284
|
-
d += Number.isFinite(
|
|
1280
|
+
if (!re(y) || y?.date !== o.date || y?.resourceId !== o.resourceId) continue;
|
|
1281
|
+
const u = $(y?.timeslot?.startTime), q = $(y?.timeslot?.endTime);
|
|
1282
|
+
if (u === null || q === null || q <= u || !s(o.startMinutes, o.endMinutes, u, q)) continue;
|
|
1283
|
+
const W = Number(y?.spots);
|
|
1284
|
+
d += Number.isFinite(W) && W > 0 ? W : 1;
|
|
1285
1285
|
}
|
|
1286
1286
|
return d;
|
|
1287
1287
|
}, b = (e) => {
|
|
1288
1288
|
let o = 0;
|
|
1289
|
-
for (const d of
|
|
1289
|
+
for (const d of w.value) {
|
|
1290
1290
|
if (d.id === e.reservation.id) continue;
|
|
1291
|
-
const t =
|
|
1291
|
+
const t = D(d);
|
|
1292
1292
|
t && t.date === e.date && t.resourceId === e.resourceId && s(e.startMinutes, e.endMinutes, t.startMinutes, t.endMinutes) && (o += t.requestedSpots);
|
|
1293
1293
|
}
|
|
1294
1294
|
return o;
|
|
1295
1295
|
}, _e = async () => {
|
|
1296
|
-
const e = ++
|
|
1296
|
+
const e = ++z, o = w.value.map(D).filter((t) => !!t), d = o.reduce((t, y) => (t[y.reservation.id] = {
|
|
1297
1297
|
status: "checking",
|
|
1298
1298
|
message: "Checking availability..."
|
|
1299
1299
|
}, t), {});
|
|
1300
|
-
if (Y.value = d,
|
|
1300
|
+
if (Y.value = d, !L.value || o.length === 0)
|
|
1301
1301
|
return d;
|
|
1302
1302
|
try {
|
|
1303
|
-
const t = Array.from(new Set(o.map((
|
|
1304
|
-
if (e !==
|
|
1305
|
-
const u = o.reduce((
|
|
1306
|
-
const
|
|
1307
|
-
return
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
),
|
|
1303
|
+
const t = Array.from(new Set(o.map((q) => `${q.resourceId}_${q.date}`))), y = await te(t);
|
|
1304
|
+
if (e !== z) return null;
|
|
1305
|
+
const u = o.reduce((q, W) => {
|
|
1306
|
+
const C = K(y, W) + b(W), ne = W.capacity - C;
|
|
1307
|
+
return q[W.reservation.id] = m(
|
|
1308
|
+
ne,
|
|
1309
|
+
W.capacity,
|
|
1310
|
+
W.requestedSpots
|
|
1311
|
+
), q;
|
|
1312
1312
|
}, {});
|
|
1313
1313
|
return Y.value = u, u;
|
|
1314
1314
|
} catch (t) {
|
|
1315
|
-
if (e !==
|
|
1315
|
+
if (e !== z) return null;
|
|
1316
1316
|
console.error("Error checking new reservation availability:", t);
|
|
1317
|
-
const y = o.reduce((u,
|
|
1317
|
+
const y = o.reduce((u, q) => (u[q.reservation.id] = {
|
|
1318
1318
|
status: "error",
|
|
1319
1319
|
message: "Could not check availability for this reservation."
|
|
1320
1320
|
}, u), {});
|
|
1321
1321
|
return Y.value = y, y;
|
|
1322
1322
|
}
|
|
1323
|
-
}, ce = (e) => e ?
|
|
1323
|
+
}, ce = (e) => e ? w.value.flatMap((o, d) => {
|
|
1324
1324
|
const t = e[o.id];
|
|
1325
|
-
return t ? t.status === "unavailable" ? [`${
|
|
1325
|
+
return t ? t.status === "unavailable" ? [`${oe(d)}: ${t.message}`] : t.status === "error" ? [`${oe(d)}: availability could not be checked.`] : [] : [];
|
|
1326
1326
|
}) : ["Could not check availability before creating the reservation."];
|
|
1327
|
-
Re(
|
|
1328
|
-
e ? (
|
|
1329
|
-
}), Re(
|
|
1330
|
-
|
|
1327
|
+
Re(L, async (e) => {
|
|
1328
|
+
e ? (B.value = [], M(), await Le(), se.value?.reset()) : (z += 1, Y.value = {});
|
|
1329
|
+
}), Re(w, () => {
|
|
1330
|
+
L.value && _e();
|
|
1331
1331
|
}, { deep: !0 });
|
|
1332
1332
|
const Ce = () => {
|
|
1333
1333
|
const e = [];
|
|
1334
|
-
|
|
1335
|
-
const o =
|
|
1336
|
-
return o || e.push("Customer information form is unavailable."),
|
|
1334
|
+
B.value = [];
|
|
1335
|
+
const o = se.value, d = o ? o.validateForm() : !1;
|
|
1336
|
+
return o || e.push("Customer information form is unavailable."), w.value.length === 0 && e.push("Please add at least one reservation."), e.push(...ve()), B.value = e, e.length === 0 && d;
|
|
1337
1337
|
}, Ne = async () => {
|
|
1338
|
-
const e =
|
|
1338
|
+
const e = se.value;
|
|
1339
1339
|
if (!e || !Ce()) return;
|
|
1340
1340
|
const o = await _e(), d = ce(o);
|
|
1341
1341
|
if (d.length > 0) {
|
|
1342
|
-
|
|
1342
|
+
B.value = d;
|
|
1343
1343
|
return;
|
|
1344
1344
|
}
|
|
1345
1345
|
let t = !1;
|
|
1346
1346
|
try {
|
|
1347
|
-
|
|
1348
|
-
const y = e.getCustomerInfo(), u =
|
|
1349
|
-
const
|
|
1347
|
+
I.value = !0;
|
|
1348
|
+
const y = e.getCustomerInfo(), u = w.value.map((C) => {
|
|
1349
|
+
const ne = Number(C.paid) || 0, Te = Number(C.spots) || 1, $e = me(C), Se = de(C), Ie = C.date;
|
|
1350
1350
|
return {
|
|
1351
|
-
paidAmount:
|
|
1352
|
-
flattenedReservationDate: `${
|
|
1353
|
-
flattenedReservation: `${
|
|
1351
|
+
paidAmount: ne,
|
|
1352
|
+
flattenedReservationDate: `${C.resourceId}_${Ie}`,
|
|
1353
|
+
flattenedReservation: `${C.resourceId}_${Ie}_${C.startTime.replace(":", "")}`,
|
|
1354
1354
|
reservation: {
|
|
1355
1355
|
status: "approved",
|
|
1356
|
-
totalPrice: Number(
|
|
1357
|
-
basePrice: Number((
|
|
1356
|
+
totalPrice: Number(ne.toFixed(2)),
|
|
1357
|
+
basePrice: Number((ne / Te).toFixed(2)),
|
|
1358
1358
|
addOnsPrice: 0,
|
|
1359
1359
|
addOns: [],
|
|
1360
1360
|
date: Ie,
|
|
@@ -1365,7 +1365,7 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1365
1365
|
name: $e?.name || "",
|
|
1366
1366
|
price: $e?.price || ""
|
|
1367
1367
|
},
|
|
1368
|
-
pricingOptionId:
|
|
1368
|
+
pricingOptionId: C.pricingOption,
|
|
1369
1369
|
resource: {
|
|
1370
1370
|
avatarLabel: Se?.avatarLabel || "",
|
|
1371
1371
|
color: Se?.color || "",
|
|
@@ -1373,52 +1373,52 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1373
1373
|
id: Se?.id || "",
|
|
1374
1374
|
name: Se?.name || ""
|
|
1375
1375
|
},
|
|
1376
|
-
resourceId:
|
|
1376
|
+
resourceId: C.resourceId,
|
|
1377
1377
|
spots: Te,
|
|
1378
1378
|
timeslot: {
|
|
1379
|
-
startTime:
|
|
1380
|
-
endTime: xe(
|
|
1379
|
+
startTime: C.startTime,
|
|
1380
|
+
endTime: xe(C)
|
|
1381
1381
|
}
|
|
1382
1382
|
}
|
|
1383
1383
|
};
|
|
1384
|
-
}),
|
|
1385
|
-
agendaId:
|
|
1384
|
+
}), q = Number(u.reduce((C, ne) => C + ne.paidAmount, 0).toFixed(2)), W = {
|
|
1385
|
+
agendaId: T.value,
|
|
1386
1386
|
customerInfo: y,
|
|
1387
1387
|
metadata: {},
|
|
1388
|
-
amountPaid:
|
|
1388
|
+
amountPaid: q,
|
|
1389
1389
|
amountDue: 0,
|
|
1390
|
-
subtotal:
|
|
1391
|
-
total:
|
|
1390
|
+
subtotal: q,
|
|
1391
|
+
total: q,
|
|
1392
1392
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1393
1393
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
1394
1394
|
discount: 0,
|
|
1395
|
-
flattenedReservationDates: Array.from(new Set(u.map((
|
|
1396
|
-
flattenedReservations: u.map((
|
|
1395
|
+
flattenedReservationDates: Array.from(new Set(u.map((C) => C.flattenedReservationDate))),
|
|
1396
|
+
flattenedReservations: u.map((C) => C.flattenedReservation),
|
|
1397
1397
|
paymentStatus: "paid",
|
|
1398
1398
|
paymentType: "full",
|
|
1399
|
-
reservations: u.map((
|
|
1399
|
+
reservations: u.map((C) => C.reservation),
|
|
1400
1400
|
status: "confirmed"
|
|
1401
1401
|
};
|
|
1402
|
-
await
|
|
1403
|
-
agendaId:
|
|
1404
|
-
reservationIds: u.map((
|
|
1405
|
-
amountPaid:
|
|
1406
|
-
reservations: u.map((
|
|
1402
|
+
await Z.add(Q.reservationsCollection, W), t = !0, le(`${u.length} ${u.length > 1 ? "reservations" : "reservation"} created in Studio`, {
|
|
1403
|
+
agendaId: T.value,
|
|
1404
|
+
reservationIds: u.map((C) => C.reservation.id),
|
|
1405
|
+
amountPaid: q,
|
|
1406
|
+
reservations: u.map((C) => `${C.reservation.resource.name}: ${C.reservation.date} ${C.reservation.timeslot.startTime}`)
|
|
1407
1407
|
});
|
|
1408
1408
|
} catch (y) {
|
|
1409
|
-
|
|
1409
|
+
j("Failed to create reservation in Studio", {
|
|
1410
1410
|
error: y instanceof Error ? y.message : String(y),
|
|
1411
|
-
agendaId:
|
|
1411
|
+
agendaId: T.value
|
|
1412
1412
|
}), console.error("Error creating reservation:", y);
|
|
1413
1413
|
} finally {
|
|
1414
|
-
|
|
1414
|
+
I.value = !1, t && (L.value = !1);
|
|
1415
1415
|
}
|
|
1416
1416
|
};
|
|
1417
1417
|
return (e, o) => {
|
|
1418
|
-
const d = h("Button"), t = h("ResponsiveModalTrigger"), y = h("ResponsiveModalTitle"), u = h("ResponsiveModalHeader"),
|
|
1419
|
-
return i(), be(
|
|
1420
|
-
open:
|
|
1421
|
-
"onUpdate:open": o[1] || (o[1] = (
|
|
1418
|
+
const d = h("Button"), t = h("ResponsiveModalTrigger"), y = h("ResponsiveModalTitle"), u = h("ResponsiveModalHeader"), q = h("ResponsiveModalFooter"), W = h("ResponsiveModalScrollContent"), C = h("ResponsiveModal");
|
|
1419
|
+
return i(), be(C, {
|
|
1420
|
+
open: L.value,
|
|
1421
|
+
"onUpdate:open": o[1] || (o[1] = (ne) => L.value = ne)
|
|
1422
1422
|
}, {
|
|
1423
1423
|
default: c(() => [
|
|
1424
1424
|
r(t, { "as-child": "" }, {
|
|
@@ -1426,20 +1426,20 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1426
1426
|
r(d, null, {
|
|
1427
1427
|
default: c(() => [
|
|
1428
1428
|
r(g(Pe), { class: "size-4" }),
|
|
1429
|
-
o[2] || (o[2] =
|
|
1429
|
+
o[2] || (o[2] = N(" Add Reservation ", -1))
|
|
1430
1430
|
]),
|
|
1431
1431
|
_: 1
|
|
1432
1432
|
})
|
|
1433
1433
|
]),
|
|
1434
1434
|
_: 1
|
|
1435
1435
|
}),
|
|
1436
|
-
r(
|
|
1436
|
+
r(W, { class: "@container/modal sm:max-w-7xl" }, {
|
|
1437
1437
|
default: c(() => [
|
|
1438
1438
|
r(u, null, {
|
|
1439
1439
|
default: c(() => [
|
|
1440
1440
|
r(y, null, {
|
|
1441
1441
|
default: c(() => [...o[3] || (o[3] = [
|
|
1442
|
-
|
|
1442
|
+
N("Create new reservation", -1)
|
|
1443
1443
|
])]),
|
|
1444
1444
|
_: 1
|
|
1445
1445
|
})
|
|
@@ -1449,8 +1449,8 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1449
1449
|
f("div", yn, [
|
|
1450
1450
|
r(ft, {
|
|
1451
1451
|
ref_key: "customerInformationRef",
|
|
1452
|
-
ref:
|
|
1453
|
-
agendaData:
|
|
1452
|
+
ref: se,
|
|
1453
|
+
agendaData: V.value
|
|
1454
1454
|
}, null, 8, ["agendaData"]),
|
|
1455
1455
|
o[5] || (o[5] = f("div", { class: "w-full h-[1px] bg-border my-8" }, null, -1)),
|
|
1456
1456
|
f("div", xn, [
|
|
@@ -1458,28 +1458,28 @@ const vt = { class: "flex items-start justify-between gap-3" }, _t = { class: "t
|
|
|
1458
1458
|
f("h2", { class: "text-sm font-medium" }, "Reservations")
|
|
1459
1459
|
], -1)),
|
|
1460
1460
|
r(bn, {
|
|
1461
|
-
modelValue:
|
|
1462
|
-
"onUpdate:modelValue": o[0] || (o[0] = (
|
|
1463
|
-
agendaData:
|
|
1461
|
+
modelValue: w.value,
|
|
1462
|
+
"onUpdate:modelValue": o[0] || (o[0] = (ne) => w.value = ne),
|
|
1463
|
+
agendaData: V.value,
|
|
1464
1464
|
"availability-by-reservation": Y.value,
|
|
1465
1465
|
onAdd: ye,
|
|
1466
|
-
onQuickAdd:
|
|
1466
|
+
onQuickAdd: v
|
|
1467
1467
|
}, null, 8, ["modelValue", "agendaData", "availability-by-reservation"])
|
|
1468
1468
|
]),
|
|
1469
1469
|
f("div", Sn, [
|
|
1470
1470
|
f("ul", kn, [
|
|
1471
|
-
(i(!0), p(
|
|
1471
|
+
(i(!0), p(ee, null, pe(B.value, (ne) => (i(), p("li", { key: ne }, R(ne), 1))), 128))
|
|
1472
1472
|
])
|
|
1473
1473
|
])
|
|
1474
1474
|
]),
|
|
1475
|
-
r(
|
|
1475
|
+
r(q, { class: "gap-2" }, {
|
|
1476
1476
|
default: c(() => [
|
|
1477
1477
|
r(d, {
|
|
1478
1478
|
onClick: Ne,
|
|
1479
|
-
disabled:
|
|
1479
|
+
disabled: I.value || X.value || ae.value
|
|
1480
1480
|
}, {
|
|
1481
1481
|
default: c(() => [
|
|
1482
|
-
|
|
1482
|
+
I.value ? (i(), p("span", $n, "Creating...")) : X.value ? (i(), p("span", Tn, "Checking availability...")) : (i(), p("span", In, R(w.value.length > 1 ? `Create ${w.value.length} reservations` : "Create reservation"), 1))
|
|
1483
1483
|
]),
|
|
1484
1484
|
_: 1
|
|
1485
1485
|
}, 8, ["disabled"])
|