@coras-io/embed 0.8.3 → 0.9.0
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/CHANGELOG.md +14 -0
- package/dist/components/attraction-card/long/attraction-long-card.styles.js +14 -4
- package/dist/components/attraction-card/short/attraction-short-card.styles.js +3 -1
- package/dist/components/locations-results/locations-results.component.d.ts +1 -0
- package/dist/components/locations-results/locations-results.component.js +5 -2
- package/dist/components/loyalty-badge/loyalty-badge.component.d.ts +34 -0
- package/dist/components/loyalty-badge/loyalty-badge.component.js +141 -0
- package/dist/components/loyalty-badge/loyalty-badge.d.ts +8 -0
- package/dist/components/loyalty-badge/loyalty-badge.js +6 -0
- package/dist/components/loyalty-badge/loyalty-badge.styles.js +61 -0
- package/dist/components/loyalty-badge/loyalty-badge.types.d.ts +6 -0
- package/dist/components/loyalty-badge/loyalty-badge.utils.d.ts +23 -0
- package/dist/components/loyalty-badge/loyalty-badge.utils.js +30 -0
- package/dist/containers/basket/basket.component.d.ts +2 -1
- package/dist/containers/basket/basket.component.js +17 -44
- package/dist/containers/navbar/navbar.styles.js +4 -2
- package/dist/contexts/properties.context.d.ts +8 -0
- package/dist/contexts/properties.context.js +5 -0
- package/dist/core/types/api-schema.d.ts +181 -5
- package/dist/core/types/core/index.d.ts +0 -1
- package/dist/core/types/index.d.ts +0 -1
- package/dist/core/utils/loyalty.d.ts +37 -4
- package/dist/core/utils/loyalty.js +14 -5
- package/dist/core/utils/seats.d.ts +6 -0
- package/dist/core/utils/seats.js +40 -0
- package/dist/index.d.ts +1 -1
- package/dist/locales/ar-SA.d.ts +4 -0
- package/dist/locales/ar-SA.js +4 -0
- package/dist/locales/da-DK.d.ts +4 -0
- package/dist/locales/da-DK.js +4 -0
- package/dist/locales/de-DE.d.ts +4 -0
- package/dist/locales/de-DE.js +4 -0
- package/dist/locales/en-IE.d.ts +4 -0
- package/dist/locales/en-IE.js +4 -0
- package/dist/locales/en-US.d.ts +4 -0
- package/dist/locales/en-US.js +4 -0
- package/dist/locales/es-ES.d.ts +4 -0
- package/dist/locales/es-ES.js +4 -0
- package/dist/locales/fr-FR.d.ts +4 -0
- package/dist/locales/fr-FR.js +4 -0
- package/dist/locales/fr-MA.d.ts +4 -0
- package/dist/locales/fr-MA.js +4 -0
- package/dist/locales/is-IS.d.ts +4 -0
- package/dist/locales/is-IS.js +4 -0
- package/dist/locales/it-IT.d.ts +4 -0
- package/dist/locales/it-IT.js +4 -0
- package/dist/locales/ms-MY.d.ts +4 -0
- package/dist/locales/ms-MY.js +4 -0
- package/dist/locales/nb-NO.d.ts +4 -0
- package/dist/locales/nb-NO.js +4 -0
- package/dist/locales/pl-PL.d.ts +4 -0
- package/dist/locales/pl-PL.js +4 -0
- package/dist/locales/pt-PT.d.ts +4 -0
- package/dist/locales/pt-PT.js +4 -0
- package/dist/locales/sv-SE.d.ts +4 -0
- package/dist/locales/sv-SE.js +4 -0
- package/dist/locales/th-TH.d.ts +4 -0
- package/dist/locales/th-TH.js +4 -0
- package/dist/locales/tr-TR.d.ts +4 -0
- package/dist/locales/tr-TR.js +4 -0
- package/dist/locales/zh-CN.d.ts +4 -0
- package/dist/locales/zh-CN.js +4 -0
- package/dist/locales/zh-HK.d.ts +4 -0
- package/dist/locales/zh-HK.js +4 -0
- package/dist/mixins/base.mixin.d.ts +2 -0
- package/dist/mixins/base.mixin.js +8 -1
- package/dist/mixins/location-search/location-search.js +14 -10
- package/dist/sdk/page-registry.js +2 -0
- package/dist/sdk/theme.d.ts +1 -1
- package/dist/sdk/types.d.ts +9 -1
- package/dist/sdk/validation.js +51 -0
- package/dist/styles/tokens.d.ts +1 -1
- package/dist/styles/tokens.generated.d.ts +1 -1
- package/dist/styles/tokens.generated.js +1 -1
- package/dist/styles/tokens.metadata.js +18 -0
- package/dist/views/chrome-only-page/chrome-only-page.component.d.ts +1 -0
- package/dist/views/details-page/details-page.component.d.ts +2 -1
- package/dist/views/details-page/details-page.component.js +15 -5
- package/dist/views/details-page/partials/location-highlights/location-highlights.component.d.ts +2 -0
- package/dist/views/details-page/partials/location-highlights/location-highlights.component.js +16 -2
- package/dist/views/help-page/help-page.component.d.ts +1 -0
- package/dist/views/landing-page/landing-page.component.d.ts +2 -3
- package/dist/views/landing-page/landing-page.component.js +10 -18
- package/dist/views/payment-page/controllers/form-validation.controller.d.ts +4 -1
- package/dist/views/payment-page/controllers/form-validation.controller.js +7 -2
- package/dist/views/payment-page/partials/confirmation/confirmation.component.js +49 -27
- package/dist/views/payment-page/payment-page.component.d.ts +6 -0
- package/dist/views/payment-page/payment-page.component.js +76 -8
- package/dist/views/payment-page/payment-page.loyalty.d.ts +13 -0
- package/dist/views/payment-page/payment-page.loyalty.js +80 -0
- package/dist/views/payment-page/payment-page.styles.js +16 -0
- package/dist/views/payment-page/payment-page.utils.d.ts +1 -1
- package/dist/views/payment-page/payment-page.utils.js +19 -1
- package/dist/views/payment-page/services/payment-api.service.d.ts +1 -0
- package/dist/views/search-page/search-page.component.d.ts +1 -0
- package/dist/views/search-page/search-page.component.js +9 -0
- package/dist/views/suggestion-widget/suggestion-widget.component.d.ts +1 -0
- package/dist/views/suggestion-widget/suggestion-widget.component.js +11 -1
- package/package.json +5 -5
- package/dist/components/points/points.component.d.ts +0 -9
- package/dist/components/points/points.component.js +0 -36
- package/dist/components/points/points.d.ts +0 -8
- package/dist/components/points/points.js +0 -6
- package/dist/components/points/points.styles.js +0 -47
- package/dist/core/types/core/points.d.ts +0 -4
- package/dist/mixins/points/points.d.ts +0 -3
- package/dist/mixins/points/points.js +0 -30
- package/dist/mixins/points/types.d.ts +0 -8
- package/dist/mixins/points/types.js +0 -1
- /package/dist/components/{points/points.styles.d.ts → loyalty-badge/loyalty-badge.styles.d.ts} +0 -0
- /package/dist/{core/types/core/points.js → components/loyalty-badge/loyalty-badge.types.js} +0 -0
|
@@ -37,7 +37,7 @@ import "./partials/location-highlights/location-highlights.js";
|
|
|
37
37
|
import "./partials/location-categories/location-categories.js";
|
|
38
38
|
import type { DetailsPageParamsEvent } from "../../core/pages.js";
|
|
39
39
|
import type { PageName } from "../../core/types/shared.js";
|
|
40
|
-
declare const CorasDetailsPage_base: import("../../contexts/utils.js").Constructor<import("../../mixins/error-modal.mixin.js").ErrorModalMixinInterface> & import("../../
|
|
40
|
+
declare const CorasDetailsPage_base: import("../../contexts/utils.js").Constructor<import("../../mixins/error-modal.mixin.js").ErrorModalMixinInterface> & import("../../contexts/utils.js").Constructor<{
|
|
41
41
|
apiHost: string;
|
|
42
42
|
distributorID: string;
|
|
43
43
|
assetsURL: string;
|
|
@@ -46,6 +46,7 @@ declare const CorasDetailsPage_base: import("../../contexts/utils.js").Construct
|
|
|
46
46
|
locale: SupportedLocales;
|
|
47
47
|
locales: SupportedLocales[];
|
|
48
48
|
loyaltyPoints: boolean;
|
|
49
|
+
loyaltyProgramme: import("../../core/utils/loyalty.js").LoyaltyProgramme | null;
|
|
49
50
|
logger: import("../../core/logger.js").Logger;
|
|
50
51
|
client: import("openapi-fetch").Client<import("../../core/types/api-schema.js").paths>;
|
|
51
52
|
getPageProperties(): DetailsPageParamsEvent;
|
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { getLoyaltyAmount } from "../../core/utils/loyalty.js";
|
|
8
|
+
import { renderLoyaltyBadge } from "../../components/loyalty-badge/loyalty-badge.utils.js";
|
|
8
9
|
import { LitElement, html, nothing, } from "lit";
|
|
9
10
|
import { state, property } from "lit/decorators.js";
|
|
10
11
|
import { Task, TaskStatus } from "@lit/task";
|
|
@@ -50,7 +51,6 @@ import "./partials/theater-description/theater-description.js";
|
|
|
50
51
|
import "./partials/tour-description/tour-description.js";
|
|
51
52
|
import "./partials/location-highlights/location-highlights.js";
|
|
52
53
|
import "./partials/location-categories/location-categories.js";
|
|
53
|
-
import { PointsMixin } from "../../mixins/points/points.js";
|
|
54
54
|
import styles from "./details-page.styles.js";
|
|
55
55
|
import { BaseMixin } from "../../mixins/base.mixin.js";
|
|
56
56
|
import { ErrorModalMixin } from "../../mixins/error-modal.mixin.js";
|
|
@@ -79,7 +79,7 @@ const MINIMUM_TICKETS_ERROR_CODES = new Set([38, 39]);
|
|
|
79
79
|
* @fires coras:state-change
|
|
80
80
|
* @fires coras:reservation-created
|
|
81
81
|
*/
|
|
82
|
-
let CorasDetailsPage = class CorasDetailsPage extends ErrorModalMixin(
|
|
82
|
+
let CorasDetailsPage = class CorasDetailsPage extends ErrorModalMixin(BaseMixin(LitElement)) {
|
|
83
83
|
constructor() {
|
|
84
84
|
super(...arguments);
|
|
85
85
|
this.attractionId = "";
|
|
@@ -345,6 +345,7 @@ let CorasDetailsPage = class CorasDetailsPage extends ErrorModalMixin(PointsMixi
|
|
|
345
345
|
pickup_id: null,
|
|
346
346
|
pickup_entry: null,
|
|
347
347
|
content_indexed_at: null,
|
|
348
|
+
seatsio_reservation_token: null,
|
|
348
349
|
...reservationFields,
|
|
349
350
|
},
|
|
350
351
|
}));
|
|
@@ -466,14 +467,23 @@ let CorasDetailsPage = class CorasDetailsPage extends ErrorModalMixin(PointsMixi
|
|
|
466
467
|
`;
|
|
467
468
|
};
|
|
468
469
|
this.renderPayInComponents = () => {
|
|
469
|
-
if (!this.loyaltyPoints) {
|
|
470
|
-
return nothing;
|
|
471
|
-
}
|
|
472
470
|
const attraction = this.attractionTask.value?.attraction;
|
|
473
471
|
const loyalty = attraction?.loyalty;
|
|
474
472
|
if (!loyalty) {
|
|
475
473
|
return nothing;
|
|
476
474
|
}
|
|
475
|
+
if (this.loyaltyProgramme) {
|
|
476
|
+
return renderLoyaltyBadge({
|
|
477
|
+
loyalty,
|
|
478
|
+
programme: this.loyaltyProgramme,
|
|
479
|
+
locale: this.locale,
|
|
480
|
+
variant: "banner",
|
|
481
|
+
from: true,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
if (!this.loyaltyPoints) {
|
|
485
|
+
return nothing;
|
|
486
|
+
}
|
|
477
487
|
const earnAmount = getLoyaltyAmount(loyalty, "earn");
|
|
478
488
|
const payAmount = getLoyaltyAmount(loyalty, "pay");
|
|
479
489
|
if (earnAmount <= 0 || payAmount <= 0) {
|
package/dist/views/details-page/partials/location-highlights/location-highlights.component.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import "../../../../components/attraction-card/short/attraction-short-card.js";
|
|
|
4
4
|
import { type PageDispatchInput } from "../../../../contexts/events.context.js";
|
|
5
5
|
import type { paths } from "../../../../core/types/api-schema.js";
|
|
6
6
|
import type { SupportedCurrencies, SupportedLocales } from "../../../../core/types/index.js";
|
|
7
|
+
import type { LoyaltyProgramme } from "../../../../core/utils/loyalty.js";
|
|
7
8
|
export declare class CorasLocationHighlights extends LitElement {
|
|
8
9
|
static styles: CSSResultGroup;
|
|
9
10
|
/** Country slug, as `/landing` and the landing page understand it. */
|
|
@@ -18,6 +19,7 @@ export declare class CorasLocationHighlights extends LitElement {
|
|
|
18
19
|
distributorID: string;
|
|
19
20
|
locale: SupportedLocales;
|
|
20
21
|
currency: SupportedCurrencies;
|
|
22
|
+
loyaltyProgramme: LoyaltyProgramme | null;
|
|
21
23
|
dispatchPageUpdate: (params: PageDispatchInput) => void;
|
|
22
24
|
private highlightsTask;
|
|
23
25
|
private handleCardClick;
|
package/dist/views/details-page/partials/location-highlights/location-highlights.component.js
CHANGED
|
@@ -15,9 +15,10 @@ import { apiGet } from "../../../../core/api/queries.js";
|
|
|
15
15
|
import { APIError } from "../../../../core/api/api-error.js";
|
|
16
16
|
import { convertToLocaleCurrency } from "../../../../core/currency/index.js";
|
|
17
17
|
import { clientContext } from "../../../../contexts/client.context.js";
|
|
18
|
-
import { currencyContext, distributorIdContext, localeContext, } from "../../../../contexts/properties.context.js";
|
|
18
|
+
import { currencyContext, distributorIdContext, localeContext, loyaltyProgrammeContext, } from "../../../../contexts/properties.context.js";
|
|
19
19
|
import { pageDispatchContext, } from "../../../../contexts/events.context.js";
|
|
20
20
|
import styles from "./location-highlights.styles.js";
|
|
21
|
+
import { renderLoyaltyBadge } from "../../../../components/loyalty-badge/loyalty-badge.utils.js";
|
|
21
22
|
/**
|
|
22
23
|
* The row is designed as a single full width of cards. A partial row reads as
|
|
23
24
|
* a rendering fault rather than as a short list, so the section is dropped
|
|
@@ -35,6 +36,7 @@ let CorasLocationHighlights = class CorasLocationHighlights extends LitElement {
|
|
|
35
36
|
this.locationName = "";
|
|
36
37
|
/** The attraction being viewed, so the row never links back to itself. */
|
|
37
38
|
this.excludeId = "";
|
|
39
|
+
this.loyaltyProgramme = null;
|
|
38
40
|
this.highlightsTask = new Task(this, {
|
|
39
41
|
task: async ([locale, currency, country, city, excludeId]) => {
|
|
40
42
|
if (!this.client || (!country && !city)) {
|
|
@@ -101,7 +103,16 @@ let CorasLocationHighlights = class CorasLocationHighlights extends LitElement {
|
|
|
101
103
|
timezone=${card.timezone}
|
|
102
104
|
locale=${this.locale}
|
|
103
105
|
@click=${() => this.handleCardClick(card)}
|
|
104
|
-
|
|
106
|
+
>
|
|
107
|
+
${renderLoyaltyBadge({
|
|
108
|
+
loyalty: card.loyalty,
|
|
109
|
+
programme: this.loyaltyProgramme,
|
|
110
|
+
locale: this.locale,
|
|
111
|
+
variant: "card",
|
|
112
|
+
slot: "points",
|
|
113
|
+
from: true,
|
|
114
|
+
})}
|
|
115
|
+
</coras-attraction-short-card>
|
|
105
116
|
`;
|
|
106
117
|
}
|
|
107
118
|
render() {
|
|
@@ -149,6 +160,9 @@ __decorate([
|
|
|
149
160
|
__decorate([
|
|
150
161
|
consume({ context: currencyContext, subscribe: true })
|
|
151
162
|
], CorasLocationHighlights.prototype, "currency", void 0);
|
|
163
|
+
__decorate([
|
|
164
|
+
consume({ context: loyaltyProgrammeContext, subscribe: true })
|
|
165
|
+
], CorasLocationHighlights.prototype, "loyaltyProgramme", void 0);
|
|
152
166
|
__decorate([
|
|
153
167
|
consume({ context: pageDispatchContext })
|
|
154
168
|
], CorasLocationHighlights.prototype, "dispatchPageUpdate", void 0);
|
|
@@ -23,6 +23,7 @@ declare const CorasHelpPage_base: import("../../contexts/utils.js").Constructor<
|
|
|
23
23
|
locale: import("../../index.js").SupportedLocales;
|
|
24
24
|
locales: import("../../index.js").SupportedLocales[];
|
|
25
25
|
loyaltyPoints: boolean;
|
|
26
|
+
loyaltyProgramme: import("../../index.js").CorasLoyaltyProgramme | null;
|
|
26
27
|
logger: import("../../core/logger.js").Logger;
|
|
27
28
|
client: import("openapi-fetch").Client<import("../../core/types/api-schema.js").paths>;
|
|
28
29
|
getPageProperties(): HelpPageParamsEvent;
|
|
@@ -20,7 +20,6 @@ import "../../components/tour-ticket-type-selector/tour-ticket-counter-button/to
|
|
|
20
20
|
import "../../components/sort-dropdown/sort-dropdown.js";
|
|
21
21
|
import "../../components/sort-list/sort-list.js";
|
|
22
22
|
import "../../components/select-list/select-option/select-option.js";
|
|
23
|
-
import "../../components/points/points.js";
|
|
24
23
|
import "../../components/chip/chip.js";
|
|
25
24
|
import "../../components/categories-tree/categories-tree.js";
|
|
26
25
|
import "../../components/breadcrumbs/breadcrumbs.js";
|
|
@@ -28,7 +27,7 @@ import "../../components/breadcrumbs/breadcrumb-item/breadcrumb-item.js";
|
|
|
28
27
|
import "../../contexts/basket/basket.js";
|
|
29
28
|
import "../../components/layout/layout.js";
|
|
30
29
|
import type { Sorting } from "../../core/types/index.js";
|
|
31
|
-
declare const CorasLandingPage_base: import("../../contexts/utils.js").Constructor<import("../../mixins/error-modal.mixin.js").ErrorModalMixinInterface> & import("../../
|
|
30
|
+
declare const CorasLandingPage_base: import("../../contexts/utils.js").Constructor<import("../../mixins/error-modal.mixin.js").ErrorModalMixinInterface> & import("../../contexts/utils.js").Constructor<import("../../mixins/location-search/types.js").LocationSearchMixinInterface> & import("../../contexts/utils.js").Constructor<{
|
|
32
31
|
apiHost: string;
|
|
33
32
|
distributorID: string;
|
|
34
33
|
assetsURL: string;
|
|
@@ -37,6 +36,7 @@ declare const CorasLandingPage_base: import("../../contexts/utils.js").Construct
|
|
|
37
36
|
locale: import("../../core/types/index.js").SupportedLocales;
|
|
38
37
|
locales: import("../../core/types/index.js").SupportedLocales[];
|
|
39
38
|
loyaltyPoints: boolean;
|
|
39
|
+
loyaltyProgramme: import("../../index.js").CorasLoyaltyProgramme | null;
|
|
40
40
|
logger: import("../../core/logger.js").Logger;
|
|
41
41
|
client: import("openapi-fetch").Client<import("../../core/types/api-schema.js").paths>;
|
|
42
42
|
getPageProperties(): LandingPageParamsEvent;
|
|
@@ -119,7 +119,6 @@ export declare class CorasLandingPage extends CorasLandingPage_base {
|
|
|
119
119
|
private renderAttractionsTitle;
|
|
120
120
|
private renderSections;
|
|
121
121
|
private renderShowMoreButton;
|
|
122
|
-
private renderPoints;
|
|
123
122
|
private renderAttractionCards;
|
|
124
123
|
private get resolvedCountry();
|
|
125
124
|
private get resolvedCountryCode();
|
|
@@ -13,7 +13,6 @@ import { consume } from "@lit/context";
|
|
|
13
13
|
import { addMonths, format, formatISO, parseISO } from "date-fns";
|
|
14
14
|
import { convertToLocaleCurrency } from "../../core/currency/index.js";
|
|
15
15
|
import { getDateRangeLabel } from "../../core/i18n/date.js";
|
|
16
|
-
import { PointsMixin } from "../../mixins/points/points.js";
|
|
17
16
|
import { getLocale, setLocale } from "../../core/i18n/localization.js";
|
|
18
17
|
import styles from "./landing-page.styles.js";
|
|
19
18
|
import { MOBILE_SCREEN_BREAKPOINT } from "./landing-page.constants.js";
|
|
@@ -40,7 +39,6 @@ import "../../components/tour-ticket-type-selector/tour-ticket-counter-button/to
|
|
|
40
39
|
import "../../components/sort-dropdown/sort-dropdown.js";
|
|
41
40
|
import "../../components/sort-list/sort-list.js";
|
|
42
41
|
import "../../components/select-list/select-option/select-option.js";
|
|
43
|
-
import "../../components/points/points.js";
|
|
44
42
|
import "../../components/chip/chip.js";
|
|
45
43
|
import "../../components/categories-tree/categories-tree.js";
|
|
46
44
|
import "../../components/breadcrumbs/breadcrumbs.js";
|
|
@@ -49,11 +47,12 @@ import "../../contexts/basket/basket.js";
|
|
|
49
47
|
import "../../components/layout/layout.js";
|
|
50
48
|
import { apiGet } from "../../core/api/queries.js";
|
|
51
49
|
import { addRecentlySelectedSearches } from "../../containers/navbar/navbar.utils.js";
|
|
50
|
+
import { renderLoyaltyBadge } from "../../components/loyalty-badge/loyalty-badge.utils.js";
|
|
52
51
|
/**
|
|
53
52
|
* @fires coras:navigate
|
|
54
53
|
* @fires coras:state-change
|
|
55
54
|
*/
|
|
56
|
-
let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(
|
|
55
|
+
let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(LocationSearchMixin(BaseMixin(LitElement))) {
|
|
57
56
|
constructor() {
|
|
58
57
|
super(...arguments);
|
|
59
58
|
this.currentPage = "landing";
|
|
@@ -818,20 +817,6 @@ let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(PointsMixi
|
|
|
818
817
|
renderShowMoreButton(_) {
|
|
819
818
|
return html `<span class="show-more-button" aria-hidden="true"></span>`;
|
|
820
819
|
}
|
|
821
|
-
renderPoints(price) {
|
|
822
|
-
if (this.calculateRewardPoints) {
|
|
823
|
-
price = price / 100;
|
|
824
|
-
const points = this.calculateRewardPoints({ price });
|
|
825
|
-
return html `<coras-points
|
|
826
|
-
slot="points"
|
|
827
|
-
points=${points.toLocaleString("en-GB")}
|
|
828
|
-
points-logo-url=${this.pointsLogoUrl}
|
|
829
|
-
points-icon-url=${this.pointsIconUrl}
|
|
830
|
-
points-unit=${this.pointsUnit}
|
|
831
|
-
></coras-points>`;
|
|
832
|
-
}
|
|
833
|
-
return html ``;
|
|
834
|
-
}
|
|
835
820
|
renderAttractionCards(section) {
|
|
836
821
|
const currency = this.currency;
|
|
837
822
|
const locale = this.locale;
|
|
@@ -870,7 +855,14 @@ let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(PointsMixi
|
|
|
870
855
|
}),
|
|
871
856
|
})}
|
|
872
857
|
>
|
|
873
|
-
${
|
|
858
|
+
${renderLoyaltyBadge({
|
|
859
|
+
loyalty: card.loyalty,
|
|
860
|
+
programme: this.loyaltyProgramme,
|
|
861
|
+
locale: this.locale,
|
|
862
|
+
variant: "card",
|
|
863
|
+
slot: "points",
|
|
864
|
+
from: true,
|
|
865
|
+
})}
|
|
874
866
|
</coras-attraction-short-card>
|
|
875
867
|
`;
|
|
876
868
|
})}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactiveController, ReactiveControllerHost } from "lit";
|
|
2
2
|
import { type ValidatorContext } from "../payment-page.validators.js";
|
|
3
|
-
import type { FormValues, PhoneCodeSelection, FieldVisibility } from "../payment-page.types.js";
|
|
3
|
+
import type { FieldsConfig, FormValues, PhoneCodeSelection, FieldVisibility } from "../payment-page.types.js";
|
|
4
4
|
import type { components } from "../../../core/types/api-schema.js";
|
|
5
5
|
/**
|
|
6
6
|
* FormValidationController manages form state, validation, and field visibility.
|
|
@@ -13,6 +13,8 @@ export declare class FormValidationController implements ReactiveController {
|
|
|
13
13
|
private host;
|
|
14
14
|
formValues: FormValues;
|
|
15
15
|
formErrors: Record<string, string>;
|
|
16
|
+
/** Fields the API adds to the form, e.g. loyalty programme membership fields. */
|
|
17
|
+
additionalFields: FieldsConfig;
|
|
16
18
|
selectedPhoneCode: PhoneCodeSelection | null;
|
|
17
19
|
termsAccepted: boolean;
|
|
18
20
|
termsError: boolean;
|
|
@@ -25,6 +27,7 @@ export declare class FormValidationController implements ReactiveController {
|
|
|
25
27
|
* Updates formValues and re-validates the field if a submission has been attempted.
|
|
26
28
|
*/
|
|
27
29
|
handleValueChange(fieldName: string, value: string, submissionAttempts: number): void;
|
|
30
|
+
get fields(): FieldsConfig;
|
|
28
31
|
/**
|
|
29
32
|
* Get the value of a form field, supporting nested reservation field structures.
|
|
30
33
|
*/
|
|
@@ -13,6 +13,8 @@ export class FormValidationController {
|
|
|
13
13
|
constructor(host) {
|
|
14
14
|
this.formValues = {};
|
|
15
15
|
this.formErrors = {};
|
|
16
|
+
/** Fields the API adds to the form, e.g. loyalty programme membership fields. */
|
|
17
|
+
this.additionalFields = {};
|
|
16
18
|
this.selectedPhoneCode = null;
|
|
17
19
|
this.termsAccepted = false;
|
|
18
20
|
this.termsError = false;
|
|
@@ -32,11 +34,14 @@ export class FormValidationController {
|
|
|
32
34
|
this.formValues = handleFormValueChange(fieldName, value, this.formValues);
|
|
33
35
|
if (submissionAttempts > 0) {
|
|
34
36
|
const context = this.getValidationContext(fieldName);
|
|
35
|
-
const result = validateFieldUtil(fieldName, value, this.formErrors,
|
|
37
|
+
const result = validateFieldUtil(fieldName, value, this.formErrors, this.fields, required, context);
|
|
36
38
|
this.formErrors = result.errors;
|
|
37
39
|
}
|
|
38
40
|
this.host.requestUpdate();
|
|
39
41
|
}
|
|
42
|
+
get fields() {
|
|
43
|
+
return { ...FIELDS, ...this.additionalFields };
|
|
44
|
+
}
|
|
40
45
|
/**
|
|
41
46
|
* Get the value of a form field, supporting nested reservation field structures.
|
|
42
47
|
*/
|
|
@@ -63,7 +68,7 @@ export class FormValidationController {
|
|
|
63
68
|
* Returns true if all visible, required fields pass validation.
|
|
64
69
|
*/
|
|
65
70
|
validate(checkData, shouldValidateBillingAddress, paymentType, hasCryptoEmail) {
|
|
66
|
-
const result = validateFormUtil(this.formValues, this.formErrors,
|
|
71
|
+
const result = validateFormUtil(this.formValues, this.formErrors, this.fields, required, checkData, shouldValidateBillingAddress, (fieldName) => this.getValidationContext(fieldName), Object.keys(this.additionalFields));
|
|
67
72
|
this.formErrors = result.errors;
|
|
68
73
|
this.termsError = !this.termsAccepted;
|
|
69
74
|
if (paymentType === "crypto" && !hasCryptoEmail) {
|
|
@@ -13,6 +13,7 @@ import { DEFAULT_LOCALE } from "../../../constants.js";
|
|
|
13
13
|
import { convertToLocaleCurrency } from "../../../../core/currency/index.js";
|
|
14
14
|
import { getLoyaltyAmount } from "../../../../core/utils/loyalty.js";
|
|
15
15
|
import { formatDateTimeForDisplay, formatTimeForDisplay, } from "../../../../core/utils/datetime.js";
|
|
16
|
+
import { getSeatDetails } from "../../../../core/utils/seats.js";
|
|
16
17
|
import { consume } from "@lit/context";
|
|
17
18
|
import { pageDispatchContext, } from "../../../../contexts/events.context.js";
|
|
18
19
|
let CorasConfirmation = class CorasConfirmation extends LitElement {
|
|
@@ -85,7 +86,9 @@ let CorasConfirmation = class CorasConfirmation extends LitElement {
|
|
|
85
86
|
</p>
|
|
86
87
|
</div>
|
|
87
88
|
|
|
88
|
-
${this.reservations.map((reservation, index) =>
|
|
89
|
+
${this.reservations.map((reservation, index) => {
|
|
90
|
+
const { section, seats } = getSeatDetails(reservation.tickets);
|
|
91
|
+
return html `
|
|
89
92
|
${index > 0 ? html `<div class="reservation-spacer"></div>` : nothing}
|
|
90
93
|
|
|
91
94
|
<div class="confirmation-container">
|
|
@@ -106,18 +109,18 @@ let CorasConfirmation = class CorasConfirmation extends LitElement {
|
|
|
106
109
|
<div class="info-label">${msg("Time")}</div>
|
|
107
110
|
<div class="info-value">
|
|
108
111
|
${formatDateTimeForDisplay({
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
dateTime: reservation.start_datetime,
|
|
113
|
+
timezone: reservation.timezone,
|
|
114
|
+
locale: this.locale || navigator.language,
|
|
115
|
+
}, {
|
|
116
|
+
includeYear: true,
|
|
117
|
+
shortFormat: true,
|
|
118
|
+
})},
|
|
116
119
|
${formatTimeForDisplay({
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
dateTime: reservation.start_datetime,
|
|
121
|
+
timezone: reservation.timezone,
|
|
122
|
+
locale: this.locale || navigator.language,
|
|
123
|
+
})}
|
|
121
124
|
</div>
|
|
122
125
|
</div>
|
|
123
126
|
|
|
@@ -125,39 +128,58 @@ let CorasConfirmation = class CorasConfirmation extends LitElement {
|
|
|
125
128
|
<div class="info-label">${msg("Location")}</div>
|
|
126
129
|
<div class="info-value">
|
|
127
130
|
${reservation.location_name
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
? html `${reservation.location_name}, ${reservation.city}`
|
|
132
|
+
: reservation.city}
|
|
130
133
|
</div>
|
|
131
134
|
</div>
|
|
132
135
|
|
|
136
|
+
${section
|
|
137
|
+
? html `
|
|
138
|
+
<div class="info-item">
|
|
139
|
+
<div class="info-label">${msg("Section")}</div>
|
|
140
|
+
<div class="info-value" data-testid="section">
|
|
141
|
+
${section}
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
`
|
|
145
|
+
: nothing}
|
|
146
|
+
${seats
|
|
147
|
+
? html `
|
|
148
|
+
<div class="info-item">
|
|
149
|
+
<div class="info-label">${msg("Seats")}</div>
|
|
150
|
+
<div class="info-value" data-testid="seats">${seats}</div>
|
|
151
|
+
</div>
|
|
152
|
+
`
|
|
153
|
+
: nothing}
|
|
133
154
|
${"tour_language" in reservation && reservation.tour_language
|
|
134
|
-
|
|
155
|
+
? html `
|
|
135
156
|
<div class="info-item">
|
|
136
157
|
<div class="info-label">${msg("Language")}</div>
|
|
137
158
|
<div class="info-value">${reservation.tour_language}</div>
|
|
138
159
|
</div>
|
|
139
160
|
`
|
|
140
|
-
|
|
161
|
+
: nothing}
|
|
141
162
|
|
|
142
163
|
<div class="info-item">
|
|
143
164
|
<div class="info-label">${msg("Amount Paid")}</div>
|
|
144
165
|
<div class="info-value">
|
|
145
166
|
${(() => {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
167
|
+
const payAmount = getLoyaltyAmount(reservation.loyalty, "pay");
|
|
168
|
+
return this.loyalty && payAmount
|
|
169
|
+
? `${new Intl.NumberFormat(this.locale || navigator.language).format(payAmount)} FIDA`
|
|
170
|
+
: convertToLocaleCurrency({
|
|
171
|
+
value: reservation.total_price,
|
|
172
|
+
locale: this.locale || navigator.language,
|
|
173
|
+
currency: (reservation.currency ||
|
|
174
|
+
"USD"),
|
|
175
|
+
});
|
|
176
|
+
})()}
|
|
156
177
|
</div>
|
|
157
178
|
</div>
|
|
158
179
|
</div>
|
|
159
180
|
</div>
|
|
160
|
-
|
|
181
|
+
`;
|
|
182
|
+
})}
|
|
161
183
|
|
|
162
184
|
<div class="help-text">
|
|
163
185
|
${msg("If you need help with your order, please visit our")}
|
|
@@ -37,6 +37,7 @@ declare const CorasPaymentPage_base: import("../../contexts/utils.js").Construct
|
|
|
37
37
|
locale: import("../../index.js").SupportedLocales;
|
|
38
38
|
locales: import("../../index.js").SupportedLocales[];
|
|
39
39
|
loyaltyPoints: boolean;
|
|
40
|
+
loyaltyProgramme: import("../../core/utils/loyalty.js").LoyaltyProgramme | null;
|
|
40
41
|
logger: Logger;
|
|
41
42
|
client: import("openapi-fetch").Client<import("../../core/types/api-schema.js").paths>;
|
|
42
43
|
getPageProperties(): PaymentPageParamsEvent;
|
|
@@ -74,6 +75,8 @@ export declare class CorasPaymentPage extends CorasPaymentPage_base {
|
|
|
74
75
|
private cdpReady;
|
|
75
76
|
private pendingTransferRecoveryStarted;
|
|
76
77
|
private apiService;
|
|
78
|
+
protected willUpdate(changedProperties: PropertyValues): void;
|
|
79
|
+
private appliedLoyaltyRequirements;
|
|
77
80
|
private getApiService;
|
|
78
81
|
private showCryptoAuthModal;
|
|
79
82
|
private transactionId;
|
|
@@ -138,6 +141,7 @@ export declare class CorasPaymentPage extends CorasPaymentPage_base {
|
|
|
138
141
|
*/
|
|
139
142
|
private shouldShowBillingAddress;
|
|
140
143
|
private renderContactDetailsEditable;
|
|
144
|
+
private renderLoyaltyProgrammeFields;
|
|
141
145
|
private renderActivityDetails;
|
|
142
146
|
private validateWalletEmail;
|
|
143
147
|
/**
|
|
@@ -239,6 +243,8 @@ export declare class CorasPaymentPage extends CorasPaymentPage_base {
|
|
|
239
243
|
private renderContent;
|
|
240
244
|
private getLoyaltyAccountUrl;
|
|
241
245
|
private renderSuccess;
|
|
246
|
+
private renderLoyaltyProgrammeTerms;
|
|
247
|
+
private renderLoyaltyProgrammeEarned;
|
|
242
248
|
private renderPending;
|
|
243
249
|
private renderFailure;
|
|
244
250
|
/**
|
|
@@ -44,7 +44,9 @@ import "./partials/billing-address/billing-address.js";
|
|
|
44
44
|
import { getBookingSession, removeBookingSession, } from "../../core/api/middlewares/booking-session/booking-session.utils.js";
|
|
45
45
|
import { PaymentApiService } from "./services/payment-api.service.js";
|
|
46
46
|
import { getDefaultPhoneCode, getDefaultCountry, getShortestExpirationSeconds, getTotalQuantity, getTotalPrice, validateWalletEmail, findCountryCode as findCountryCodeUtil, toE164, prepareReservationData, prepareAttendeesData, isApiError, unwrapApiErrorBody, mapApiErrorsToForm, prepareCustomerData as prepareCustomerDataUtil, getFieldConfig, isFinalStatus, pollTransactionStatus, INVALID_FIELD_SELECTOR, } from "./payment-page.utils.js";
|
|
47
|
-
import { getLoyaltyAmount } from "../../core/utils/loyalty.js";
|
|
47
|
+
import { getLoyaltyAmount, sumProgrammeUnitsEarned, } from "../../core/utils/loyalty.js";
|
|
48
|
+
import { renderLoyaltyBadge } from "../../components/loyalty-badge/loyalty-badge.utils.js";
|
|
49
|
+
import { buildLoyaltyFieldsConfig, collectLoyaltyMetadata, getLoyaltyFieldName, } from "./payment-page.loyalty.js";
|
|
48
50
|
import { consume } from "@lit/context";
|
|
49
51
|
import { currentPageContext } from "../../contexts/current-page.context.js";
|
|
50
52
|
import { convertToLocaleCurrency } from "../../core/currency/index.js";
|
|
@@ -141,6 +143,7 @@ let CorasPaymentPage = class CorasPaymentPage extends CoinbaseMixin(ErrorModalMi
|
|
|
141
143
|
this.cdpReady = false;
|
|
142
144
|
this.pendingTransferRecoveryStarted = false;
|
|
143
145
|
this.apiService = null;
|
|
146
|
+
this.appliedLoyaltyRequirements = null;
|
|
144
147
|
this.showCryptoAuthModal = false;
|
|
145
148
|
this.transactionId = "";
|
|
146
149
|
this.userId = "";
|
|
@@ -506,6 +509,15 @@ let CorasPaymentPage = class CorasPaymentPage extends CoinbaseMixin(ErrorModalMi
|
|
|
506
509
|
locale: this.locale,
|
|
507
510
|
};
|
|
508
511
|
}
|
|
512
|
+
willUpdate(changedProperties) {
|
|
513
|
+
super.willUpdate(changedProperties);
|
|
514
|
+
const loyaltyRequirements = this.reservationsCheckTask.value?.loyalty ?? null;
|
|
515
|
+
if (changedProperties.has("loyaltyProgramme") ||
|
|
516
|
+
loyaltyRequirements !== this.appliedLoyaltyRequirements) {
|
|
517
|
+
this.appliedLoyaltyRequirements = loyaltyRequirements;
|
|
518
|
+
this.formController.additionalFields = buildLoyaltyFieldsConfig(loyaltyRequirements, this.loyaltyProgramme);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
509
521
|
getApiService() {
|
|
510
522
|
if (!this.apiService) {
|
|
511
523
|
this.apiService = new PaymentApiService({
|
|
@@ -759,6 +771,23 @@ let CorasPaymentPage = class CorasPaymentPage extends CoinbaseMixin(ErrorModalMi
|
|
|
759
771
|
</div>
|
|
760
772
|
`;
|
|
761
773
|
}
|
|
774
|
+
renderLoyaltyProgrammeFields() {
|
|
775
|
+
const requirements = this.reservationsCheckTask.value?.loyalty;
|
|
776
|
+
if (!requirements || requirements.requirements.length === 0) {
|
|
777
|
+
return nothing;
|
|
778
|
+
}
|
|
779
|
+
return html `
|
|
780
|
+
<section class="loyalty-programme" data-testid="loyalty-programme-fields">
|
|
781
|
+
<h2>${msg("Additional details")}</h2>
|
|
782
|
+
<div class="fields-container">
|
|
783
|
+
${requirements.requirements.map((requirement) => this.renderField({
|
|
784
|
+
fieldName: getLoyaltyFieldName(requirement.field),
|
|
785
|
+
}))}
|
|
786
|
+
</div>
|
|
787
|
+
</section>
|
|
788
|
+
<hr class="section-divider" />
|
|
789
|
+
`;
|
|
790
|
+
}
|
|
762
791
|
renderActivityDetails() {
|
|
763
792
|
const data = this.reservationsCheckTask.value;
|
|
764
793
|
if (!data?.reservations || !data.reservations.length) {
|
|
@@ -1206,6 +1235,10 @@ let CorasPaymentPage = class CorasPaymentPage extends CoinbaseMixin(ErrorModalMi
|
|
|
1206
1235
|
this.logger.error("Cannot confirm reservation: booking session is missing.");
|
|
1207
1236
|
return null;
|
|
1208
1237
|
}
|
|
1238
|
+
const metadata = {
|
|
1239
|
+
...this.metadata,
|
|
1240
|
+
...collectLoyaltyMetadata(this.reservationsCheckTask.value?.loyalty, this.formController.formValues),
|
|
1241
|
+
};
|
|
1209
1242
|
const body = {
|
|
1210
1243
|
first_name: this.getFieldValue("first_name"),
|
|
1211
1244
|
second_name: this.getFieldValue("second_name"),
|
|
@@ -1220,10 +1253,7 @@ let CorasPaymentPage = class CorasPaymentPage extends CoinbaseMixin(ErrorModalMi
|
|
|
1220
1253
|
id_number: null,
|
|
1221
1254
|
wallet_address: null,
|
|
1222
1255
|
transaction_hash: null,
|
|
1223
|
-
|
|
1224
|
-
...(Object.keys(this.metadata).length > 0
|
|
1225
|
-
? { metadata: this.metadata }
|
|
1226
|
-
: {}),
|
|
1256
|
+
...(Object.keys(metadata).length > 0 ? { metadata } : {}),
|
|
1227
1257
|
};
|
|
1228
1258
|
const customHeaders = {};
|
|
1229
1259
|
if (this.paymentType === "crypto") {
|
|
@@ -1372,7 +1402,7 @@ let CorasPaymentPage = class CorasPaymentPage extends CoinbaseMixin(ErrorModalMi
|
|
|
1372
1402
|
if (fieldName === "phone") {
|
|
1373
1403
|
return this.renderPhoneField(fieldName);
|
|
1374
1404
|
}
|
|
1375
|
-
const fieldConfig = getFieldConfig(fieldName,
|
|
1405
|
+
const fieldConfig = getFieldConfig(fieldName, this.formController.fields);
|
|
1376
1406
|
if (!fieldConfig)
|
|
1377
1407
|
return null;
|
|
1378
1408
|
const value = this.getFieldValue(fieldName);
|
|
@@ -1492,8 +1522,8 @@ let CorasPaymentPage = class CorasPaymentPage extends CoinbaseMixin(ErrorModalMi
|
|
|
1492
1522
|
<form id="form" @submit=${this.onFormSubmit}>
|
|
1493
1523
|
${this.renderContactDetailsEditable()}
|
|
1494
1524
|
<hr class="section-divider" />
|
|
1495
|
-
${this.
|
|
1496
|
-
${this.renderPaymentDetailsStep()}
|
|
1525
|
+
${this.renderLoyaltyProgrammeFields()} ${this.renderActivityDetails()}
|
|
1526
|
+
${this.renderPaymentTypeSelector()} ${this.renderPaymentDetailsStep()}
|
|
1497
1527
|
</form>
|
|
1498
1528
|
${this.renderCryptoAuthModalElement()}
|
|
1499
1529
|
`;
|
|
@@ -1569,6 +1599,44 @@ let CorasPaymentPage = class CorasPaymentPage extends CoinbaseMixin(ErrorModalMi
|
|
|
1569
1599
|
></coras-collect-fida>
|
|
1570
1600
|
</div>`
|
|
1571
1601
|
: nothing}
|
|
1602
|
+
${this.renderLoyaltyProgrammeEarned()}
|
|
1603
|
+
</div>
|
|
1604
|
+
`;
|
|
1605
|
+
}
|
|
1606
|
+
renderLoyaltyProgrammeTerms(termsUrl) {
|
|
1607
|
+
const href = safeUrl(termsUrl);
|
|
1608
|
+
if (!href)
|
|
1609
|
+
return nothing;
|
|
1610
|
+
return html `
|
|
1611
|
+
<a
|
|
1612
|
+
class="loyalty-terms"
|
|
1613
|
+
href=${href}
|
|
1614
|
+
target="_blank"
|
|
1615
|
+
rel="noopener noreferrer"
|
|
1616
|
+
>${msg("Terms & Conditions")}</a
|
|
1617
|
+
>
|
|
1618
|
+
`;
|
|
1619
|
+
}
|
|
1620
|
+
renderLoyaltyProgrammeEarned() {
|
|
1621
|
+
const programme = this.loyaltyProgramme;
|
|
1622
|
+
const reservations = this.reservationsTask.value?.reservations ?? [];
|
|
1623
|
+
const earned = sumProgrammeUnitsEarned(reservations, programme);
|
|
1624
|
+
if (!programme || earned <= 0) {
|
|
1625
|
+
return nothing;
|
|
1626
|
+
}
|
|
1627
|
+
return html `
|
|
1628
|
+
<div
|
|
1629
|
+
class="loyalty-programme-earned"
|
|
1630
|
+
data-testid="loyalty-programme-earned"
|
|
1631
|
+
>
|
|
1632
|
+
${renderLoyaltyBadge({
|
|
1633
|
+
loyalty: null,
|
|
1634
|
+
programme,
|
|
1635
|
+
amount: earned,
|
|
1636
|
+
locale: this.locale,
|
|
1637
|
+
variant: "banner",
|
|
1638
|
+
})}
|
|
1639
|
+
${this.renderLoyaltyProgrammeTerms(programme.termsUrl ?? null)}
|
|
1572
1640
|
</div>
|
|
1573
1641
|
`;
|
|
1574
1642
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loyalty programme checkout fields. `GET /reservations/check` lists the
|
|
3
|
+
* fields and their rules (required, pattern, max length); the host's
|
|
4
|
+
* `config.loyalty` supplies the wording. This module turns both into the
|
|
5
|
+
* payment page's field config (the field's label shown as its placeholder,
|
|
6
|
+
* like the billing address fields) and collects the values into the
|
|
7
|
+
* reservation `metadata` the API validates and stores.
|
|
8
|
+
*/
|
|
9
|
+
import type { LoyaltyProgramme, LoyaltyRequirements } from "../../core/utils/loyalty.js";
|
|
10
|
+
import type { FieldsConfig, FormValues } from "./payment-page.types.js";
|
|
11
|
+
export declare function getLoyaltyFieldName(field: string): string;
|
|
12
|
+
export declare function buildLoyaltyFieldsConfig(requirements: LoyaltyRequirements | null | undefined, programme: LoyaltyProgramme | null | undefined): FieldsConfig;
|
|
13
|
+
export declare function collectLoyaltyMetadata(requirements: LoyaltyRequirements | null | undefined, formValues: FormValues): Record<string, string>;
|