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