@konnectio/core
Version:
Konnectio Core Frontend Integration.
321 lines (320 loc) • 11.9 kB
JavaScript
import { d as te, u as fe, s as Q, r as b, c as s, D as W, o as ye, h as m, b as u, f as n, w as De, i as x, e as h, a as k, g as t, n as N, B as ke, j as he } from "./mitt-CWSmi8M-.js";
import { u as X, b as we, a as Le, f as Z, P as Ve, T as _e, d as Ae, i as ee, e as ae, w as xe, _ as oe } from "./SelectField.vue_vue_type_style_index_0_lang-Cev1TH7y.js";
import { _ as A } from "./AvailabilitySkeleton.vue_vue_type_style_index_0_scoped_86730e88_lang-XzdmauPt.js";
import { E as le } from "./Field.vue_vue_type_style_index_0_scoped_6ef33e68_lang-NEWgHGKm.js";
import { F as p } from "./Field-Dw5FVydD.js";
const Ne = {
class: "konnectio-availability-location",
key: "location"
}, Se = {
id: "konnectio-availability-date-selection",
key: "multiDate"
}, Ce = {
key: 0,
class: "konnectio-availability-date-selection-multi"
}, $e = {
class: "konnectio-availability-guest-selection",
key: "guests"
}, Ue = {
id: "konnectio-availability-confirmation",
key: "confirm"
}, Be = /* @__PURE__ */ te({
__name: "HotelAvailabilityForm",
props: {
booking: { type: Boolean, default: !1 },
link: {},
selectedLocation: { default: NaN },
disableDefaultLocation: { type: Boolean, default: !1 },
hideLocations: { type: Boolean, default: !1 }
},
setup(S) {
const { t: i } = fe(), a = S, C = X(), {
adults: ie,
children: ne,
arrivalDate: $,
departureDate: U,
location: B,
hasHotelLocations: H,
hotelLocations: R,
controlLocation: se
} = Q(X()), w = we(), { display: y } = Le(), {
firstSelectableDateOffset: F,
lastSelectableDateOffset: I,
defaultAdultAmount: T,
defaultChildAmount: M,
maxAdultAmount: ue,
maxChildAmount: re,
splitBookingCalendar: ce
} = Q(Z()), { hasChildSelection: L } = Z(), de = () => new Date(new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + F.value)).setHours(12, 0, 0, 0)), ve = () => new Date(new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + F.value + 1)).setHours(12, 0, 0, 0)), me = () => a.disableDefaultLocation ? void 0 : se.value, O = b(T.value), P = b(M.value), E = b(de()), j = b(ve()), z = b(me()), g = s({
get: () => a.booking ? C.adults : O.value,
set: (e) => {
a.booking ? ie.value = Number(e) : O.value = Number(e);
}
}), D = s({
get: () => a.booking ? C.children : P.value,
set: (e) => {
a.booking ? ne.value = Number(e) : P.value = Number(e);
}
}), r = s({
get: () => a.booking ? $.value : E.value,
set: (e) => {
a.booking ? $.value = e : E.value = e;
}
}), c = s({
get: () => a.booking ? U.value : j.value,
set: (e) => {
a.booking ? U.value = e : j.value = e;
}
}), d = s({
get: () => isNaN(a.selectedLocation) ? a.booking ? B.value : z.value : a.selectedLocation,
set: (e) => {
a.booking ? B.value = e : z.value = e;
}
}), q = s(() => {
const e = R.value.find(({ id: l }) => l === a.selectedLocation);
return e ? e.name : "";
}), G = s(() => H.value && !a.hideLocations), f = b([]), Y = s(() => new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate()))), be = s(() => new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + I.value))), J = s(() => new Date((/* @__PURE__ */ new Date()).setDate(r.value.getDate() + (I.value + 1)))), V = s(() => g.value !== 0), pe = s(() => typeof a.link != "string");
function K(e) {
const l = e.getFullYear();
let o = e.getMonth() + 1, v = e.getDate();
return v < 10 && (v = "0" + v), o < 10 && (o = "0" + o), `${l}-${o}-${v}`;
}
function _(e) {
const l = {
a: g.value.toString(),
c: D.value.toString(),
ci: K(r.value),
co: K(c.value),
hid: d.value.toString()
}, o = new URLSearchParams(l), v = new URL(e, window.location.origin);
v.search = o.toString(), window.location.replace(v.toString());
}
function ge() {
if (isNaN(d.value) && H.value) {
y({
message: i("alert.error.selectHotelId"),
type: "error"
});
return;
}
if (isNaN(g.value)) {
y({
message: i("alert.error.selectValidAdults"),
type: "error"
});
return;
}
if (isNaN(D.value)) {
y({
message: i("alert.error.selectValidChildren"),
type: "error"
});
return;
}
if (a.booking === !1)
if (pe.value) {
const e = xe();
a.link[e] ? _(a.link[e]) : a.link.en ? _(a.link.en) : y({
message: "Module misconfiguration, contact an admin",
type: "error"
});
} else
_(a.link);
else V.value && w.fetchAvailabilityData();
}
return W(r, (e) => {
const l = new Date(new Date(e).setDate(new Date(e).getDate() + 1));
new Date(c.value) < l && (c.value = l);
}), Ve.on("forcedDateChange", () => {
f.value = [r.value, c.value];
}), W(f, (e) => {
r.value = e[0], c.value = e[1];
}), ye(() => {
f.value = [r.value, c.value];
}), (e, l) => (u(), m("form", {
id: "konnectio-availability-form",
class: N({ reservation: e.booking }),
type: "availability",
onSubmit: he(ge, ["prevent"])
}, [
n(ke, {
id: "konnectio-availability-form-content",
tag: "ul",
class: N([
{ "is-booking-page": e.booking },
{ "only-adult-guests": !t(L)(d.value) },
{ "all-guests": t(L)(d.value) },
{ "has-location": G.value }
])
}, {
default: De(() => [
G.value ? (u(), m("li", Ne, [
isNaN(e.selectedLocation) ? (u(), k(Ae, {
key: 1,
modelValue: d.value,
"onUpdate:modelValue": l[1] || (l[1] = (o) => d.value = o),
label: t(i)("general.location"),
placeholder: t(i)("general.locationPlaceholder"),
icon: "location-dot",
"icon-type": "fas",
"icon-placement": "label",
"label-key": "name",
"value-key": "id",
options: t(R),
searchable: !1
}, null, 8, ["modelValue", "label", "placeholder", "options"])) : (u(), k(_e, {
key: 0,
modelValue: q.value,
"onUpdate:modelValue": l[0] || (l[0] = (o) => q.value = o),
label: t(i)("general.location"),
icon: "location-dot",
"icon-type": "fas",
"icon-placement": "label",
readonly: ""
}, null, 8, ["modelValue", "label"]))
])) : x("", !0),
h("li", Se, [
t(ce) ? (u(), m("div", Ce, [
n(A, {
modelValue: r.value,
"onUpdate:modelValue": l[2] || (l[2] = (o) => r.value = o),
label: t(i)("availability.arrivalDate"),
name: "arrivalDate",
"icon-type": "fas",
"icon-placement": "label",
"start-date": r.value,
"min-date": Y.value,
"max-date": be.value
}, null, 8, ["modelValue", "label", "start-date", "min-date", "max-date"]),
n(A, {
modelValue: c.value,
"onUpdate:modelValue": l[3] || (l[3] = (o) => c.value = o),
label: t(i)("availability.departureDate"),
name: "departureDate",
"icon-type": "fas",
"icon-placement": "label",
"start-date": c.value,
"min-date": r.value,
"max-date": J.value
}, null, 8, ["modelValue", "label", "start-date", "min-date", "max-date"])
])) : (u(), k(A, {
key: 1,
modelValue: f.value,
"onUpdate:modelValue": l[4] || (l[4] = (o) => f.value = o),
label: t(i)("availability.checkInOut"),
"icon-type": "fas",
"icon-placement": "label",
"min-range": 1,
"min-date": Y.value,
"max-date": J.value,
range: ""
}, null, 8, ["modelValue", "label", "min-date", "max-date"]))
]),
h("li", $e, [
n(ee, {
modelValue: g.value,
"onUpdate:modelValue": l[5] || (l[5] = (o) => g.value = o),
label: t(i)("availability.adults"),
description: t(i)("general.adultAgeRange"),
"icon-type": "fas",
"icon-placement": "label",
name: "adults",
icon: "male",
"max-value": t(ue),
placeholder: `${t(T)}`,
controls: !0
}, null, 8, ["modelValue", "label", "description", "max-value", "placeholder"]),
t(L)(d.value) ? (u(), k(ee, {
key: 0,
modelValue: D.value,
"onUpdate:modelValue": l[6] || (l[6] = (o) => D.value = o),
label: t(i)("availability.children"),
description: t(i)("general.childAgeRange"),
"icon-type": "fas",
"icon-placement": "label",
name: "children",
icon: "child",
"max-value": t(re),
placeholder: `${t(M)}`,
controls: !0
}, null, 8, ["modelValue", "label", "description", "max-value", "placeholder"])) : x("", !0)
]),
h("li", Ue, [
n(ae, {
class: "konnectio-availability-submit-small",
type: "submit",
icon: "search",
"icon-type": "fas",
disabled: !V.value,
"is-loading": t(w).areListingsLoading
}, null, 8, ["disabled", "is-loading"]),
n(ae, {
class: "konnectio-availability-submit-large",
type: "submit",
label: t(i)("availability.buttonLabel"),
disabled: !V.value,
"is-loading": t(w).areListingsLoading
}, null, 8, ["label", "disabled", "is-loading"])
])
]),
_: 1
}, 8, ["class"])
], 34));
}
}), ze = /* @__PURE__ */ oe(Be, [["__scopeId", "data-v-ec87720a"]]), He = { class: "availability-skeleton" }, Re = {
key: 0,
class: "availability-skeleton-navigation"
}, Fe = { class: "availability-skeleton-content" }, Ie = {
key: 1,
class: "availability-skeleton-event"
}, Te = /* @__PURE__ */ te({
__name: "AvailabilitySkeleton",
props: {
view: { default: "hotel" },
hotel: { type: Boolean, default: !1 }
},
setup(S) {
return (i, a) => (u(), m("div", He, [
i.view === "both" ? (u(), m("div", Re, [
n(le, {
height: "28px",
width: "60px",
"border-radius": "20px"
}),
n(le, {
height: "28px",
width: "60px",
"border-radius": "20px"
})
])) : x("", !0),
h("div", Fe, [
i.view !== "event" ? (u(), m("div", {
key: 0,
class: N([
"availability-skeleton-hotel",
{ "within-hotel": i.hotel }
])
}, [
n(p, { "with-icon": "" }),
n(p, { "with-icon": "" }),
n(p, { "with-icon": "" }),
n(p, {
"with-icon": "",
"no-label": ""
})
], 2)) : (u(), m("div", Ie, [
n(p, { "with-icon": "" }),
n(p, {
"with-icon": "",
"no-label": ""
})
]))
])
]));
}
}), qe = /* @__PURE__ */ oe(Te, [["__scopeId", "data-v-86730e88"]]);
export {
qe as A,
ze as H
};
//# sourceMappingURL=AvailabilitySkeleton-D3iv0cT1.js.map