UNPKG

@konnectio/core

Version:

Konnectio Core Frontend Integration.

318 lines (317 loc) 10.1 kB
import { D as e, Dt as t, E as n, Et as r, M as i, O as a, P as o, T as s, Y as c, bt as l, dt as ee, f as te, k as u, lt as d, o as ne, q as re, u as f, y as ie } from "./mitt-Dp_pykgV.js"; import { C as p, E as m, M as ae, O as oe, S as h, V as se, dt as ce, k as le, n as ue, r as g, t as de, v as fe } from "./SelectField-CfD2awPl.js"; import { n as _, p as pe } from "./AvailabilitySkeleton-DVRsnt_Y.js"; //#region src/components/forms/HotelAvailabilityForm.vue?vue&type=script&setup=true&lang.ts var me = { class: "konnectio-availability-location", key: "location" }, he = { id: "konnectio-availability-date-selection", key: "multiDate" }, ge = { key: 0, class: "konnectio-availability-date-selection-multi" }, _e = { class: "konnectio-availability-room-count", key: "room" }, ve = { class: "konnectio-availability-guest-selection", key: "guests" }, ye = { id: "konnectio-availability-confirmation", key: "confirm" }, v = /* @__PURE__ */ h(/* @__PURE__ */ o({ __name: "HotelAvailabilityForm", props: { booking: { type: Boolean, default: !1 }, link: {}, selectedLocation: { default: NaN }, disableDefaultLocation: { type: Boolean, default: !1 }, hideLocations: { type: Boolean, default: !1 } }, setup(o) { let { t: h } = ne(), v = o, y = p(), { adults: be, children: xe, roomCount: Se, arrivalDate: b, departureDate: x, location: S, hasHotelLocations: C, hotelLocations: w, controlLocation: Ce } = f(p()), T = oe(), we = pe(), { display: E } = ae(), { firstSelectableDateOffset: D, lastSelectableDateOffset: O, defaultAdultAmount: k, defaultChildAmount: A, maxAdultAmount: Te, maxChildAmount: Ee, splitBookingCalendar: De } = f(m()), { hasChildSelection: j, hasRoomAmountSelection: M } = m(), Oe = () => new Date(new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + D.value)).setHours(12, 0, 0, 0)), ke = () => new Date(new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + D.value + 1)).setHours(12, 0, 0, 0)), Ae = () => v.disableDefaultLocation ? void 0 : Ce.value, N = l(k.value), P = l(A.value), F = l(1), I = l(Oe()), L = l(ke()), R = l(Ae()), z = s({ get: () => v.booking ? y.adults : N.value, set: (e) => { v.booking ? be.value = Number(e) : N.value = Number(e); } }), B = s({ get: () => v.booking ? y.children : P.value, set: (e) => { v.booking ? xe.value = Number(e) : P.value = Number(e); } }), V = s({ get: () => v.booking ? y.roomCount : F.value, set: (e) => { v.booking ? Se.value = Number(e) : F.value = Number(e); } }), H = s({ get: () => v.booking ? b.value : I.value, set: (e) => { v.booking ? b.value = e : I.value = e; } }), U = s({ get: () => v.booking ? x.value : L.value, set: (e) => { v.booking ? x.value = e : L.value = e; } }), W = s({ get: () => isNaN(v.selectedLocation) ? v.booking ? S.value : R.value : v.selectedLocation, set: (e) => { v.booking ? S.value = e : R.value = e; } }), G = s(() => { let e = w.value.find(({ id: e }) => e === v.selectedLocation); return e ? e.name : ""; }), K = s(() => C.value && !v.hideLocations), q = l([]), J = s(() => new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate()))), je = s(() => new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + O.value))), Y = s(() => new Date((/* @__PURE__ */ new Date()).setDate(H.value.getDate() + (O.value + 1)))), X = s(() => z.value !== 0), Me = s(() => typeof v.link != "string"); function Z(e) { let t = e.getFullYear(), n = e.getMonth() + 1, r = e.getDate(); return r < 10 && (r = "0" + r), n < 10 && (n = "0" + n), `${t}-${n}-${r}`; } function Q(e) { let t = { a: z.value.toString(), c: B.value.toString(), r: V.value.toString(), ci: Z(H.value), co: Z(U.value), hid: W.value.toString() }, n = new URLSearchParams(t), r = new URL(e, window.location.origin); r.search = n.toString(), window.location.replace(r.toString()); } function Ne() { if (isNaN(W.value) && C.value) { E({ message: h("alert.error.selectHotelId"), type: "error" }); return; } if (isNaN(z.value)) { E({ message: h("alert.error.selectValidAdults"), type: "error" }); return; } if (isNaN(B.value)) { E({ message: h("alert.error.selectValidChildren"), type: "error" }); return; } if (v.booking === !1) if (Me.value) { let e = se(); v.link[e] ? Q(v.link[e]) : v.link.en ? Q(v.link.en) : E({ message: "Module misconfiguration, contact an admin", type: "error" }); } else Q(v.link); else X.value && T.fetchAvailabilityData(); } let Pe = ce("history", { removeNullishValues: !0 }); function $() { v.booking && (Pe.ci = Z(H.value), Pe.co = Z(U.value)); } return d(H, (e) => { let t = new Date(new Date(e).setDate(new Date(e).getDate() + 1)); new Date(U.value) < t && (U.value = t), $(); }), d(U, () => { $(); }), le.on("forcedDateChange", () => { q.value = [H.value, U.value]; }), d(q, (e) => { H.value = e[0], U.value = e[1]; }), d([ z, B, W ], () => { we.clearCache(); }), re(() => { q.value = [H.value, U.value]; }), (s, l) => (c(), u("form", { id: "konnectio-availability-form", class: t({ reservation: o.booking }), type: "availability", onSubmit: ie(Ne, ["prevent"]) }, [i(te, { id: "konnectio-availability-form-content", tag: "ul", class: t([ { "is-booking-page": o.booking }, { "only-adult-guests": !r(j)(W.value) }, { "all-guests": r(j)(W.value) }, { "has-location": K.value }, { "has-room-count": r(M)(W.value) } ]) }, { default: ee(() => [ K.value ? (c(), u("li", me, [isNaN(o.selectedLocation) ? (c(), e(de, { key: 1, modelValue: W.value, "onUpdate:modelValue": l[1] ||= (e) => W.value = e, label: r(h)("general.location"), placeholder: r(h)("general.locationPlaceholder"), icon: "location-dot", "icon-type": "fas", "icon-placement": "label", "label-key": "name", "value-key": "id", options: r(w), searchable: !1 }, null, 8, [ "modelValue", "label", "placeholder", "options" ])) : (c(), e(ue, { key: 0, modelValue: G.value, "onUpdate:modelValue": l[0] ||= (e) => G.value = e, label: r(h)("general.location"), icon: "location-dot", "icon-type": "fas", "icon-placement": "label", readonly: "" }, null, 8, ["modelValue", "label"]))])) : a("", !0), n("li", he, [r(De) ? (c(), u("div", ge, [i(_, { modelValue: H.value, "onUpdate:modelValue": l[2] ||= (e) => H.value = e, label: r(h)("availability.arrivalDate"), name: "arrivalDate", "icon-type": "fas", "icon-placement": "label", "start-date": H.value, "min-date": J.value, "max-date": je.value, "show-prices": "", "show-availability": "" }, null, 8, [ "modelValue", "label", "start-date", "min-date", "max-date" ]), i(_, { modelValue: U.value, "onUpdate:modelValue": l[3] ||= (e) => U.value = e, label: r(h)("availability.departureDate"), name: "departureDate", "icon-type": "fas", "icon-placement": "label", "start-date": U.value, "min-date": H.value, "max-date": Y.value, "show-prices": "", "show-availability": "" }, null, 8, [ "modelValue", "label", "start-date", "min-date", "max-date" ])])) : (c(), e(_, { key: 1, modelValue: q.value, "onUpdate:modelValue": l[4] ||= (e) => q.value = e, label: r(h)("availability.checkInOut"), "icon-type": "fas", "icon-placement": "label", "min-range": 1, "min-date": J.value, "max-date": Y.value, "show-prices": "", "show-availability": "", range: "" }, null, 8, [ "modelValue", "label", "min-date", "max-date" ]))]), r(M)(W.value) ? (c(), u("li", _e, [i(g, { modelValue: V.value, "onUpdate:modelValue": l[5] ||= (e) => V.value = e, label: r(h)("availability.roomCount"), "icon-type": "fas", "icon-placement": "label", name: "roomCount", icon: "house", "min-value": 1, "max-value": 10, controls: !0 }, null, 8, ["modelValue", "label"])])) : a("", !0), n("li", ve, [i(g, { modelValue: z.value, "onUpdate:modelValue": l[6] ||= (e) => z.value = e, label: r(h)("availability.adults"), description: r(h)("general.adultAgeRange"), "icon-type": "fas", "icon-placement": "label", name: "adults", icon: "male", "max-value": r(Te), placeholder: `${r(k)}`, controls: !0 }, null, 8, [ "modelValue", "label", "description", "max-value", "placeholder" ]), r(j)(W.value) ? (c(), e(g, { key: 0, modelValue: B.value, "onUpdate:modelValue": l[7] ||= (e) => B.value = e, label: r(h)("availability.children"), description: r(h)("general.childAgeRange"), "icon-type": "fas", "icon-placement": "label", name: "children", icon: "child", "max-value": r(Ee), placeholder: `${r(A)}`, controls: !0 }, null, 8, [ "modelValue", "label", "description", "max-value", "placeholder" ])) : a("", !0)]), n("li", ye, [i(fe, { class: "konnectio-availability-submit-small", type: "submit", icon: "search", "icon-type": "fas", disabled: !X.value, "is-loading": r(T).areListingsLoading }, null, 8, ["disabled", "is-loading"]), i(fe, { class: "konnectio-availability-submit-large", type: "submit", label: r(h)("availability.buttonLabel"), disabled: !X.value, "is-loading": r(T).areListingsLoading }, null, 8, [ "label", "disabled", "is-loading" ])]) ]), _: 1 }, 8, ["class"])], 34)); } }), [["__scopeId", "data-v-9502323e"]]); //#endregion export { v as t };