@coras-io/embed 0.8.2 → 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.
Files changed (119) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/components/attraction-card/long/attraction-long-card.styles.js +14 -4
  3. package/dist/components/attraction-card/short/attraction-short-card.styles.js +3 -1
  4. package/dist/components/basket/basket.styles.js +2 -2
  5. package/dist/components/locations-results/locations-results.component.d.ts +1 -0
  6. package/dist/components/locations-results/locations-results.component.js +5 -2
  7. package/dist/components/loyalty-badge/loyalty-badge.component.d.ts +34 -0
  8. package/dist/components/loyalty-badge/loyalty-badge.component.js +141 -0
  9. package/dist/components/loyalty-badge/loyalty-badge.d.ts +8 -0
  10. package/dist/components/loyalty-badge/loyalty-badge.js +6 -0
  11. package/dist/components/loyalty-badge/loyalty-badge.styles.js +61 -0
  12. package/dist/components/loyalty-badge/loyalty-badge.types.d.ts +6 -0
  13. package/dist/components/loyalty-badge/loyalty-badge.utils.d.ts +23 -0
  14. package/dist/components/loyalty-badge/loyalty-badge.utils.js +30 -0
  15. package/dist/components/seated-selector/seated-selector.component.js +2 -3
  16. package/dist/components/seats-io/seats-io.component.js +0 -5
  17. package/dist/containers/basket/basket.component.d.ts +2 -1
  18. package/dist/containers/basket/basket.component.js +17 -44
  19. package/dist/containers/navbar/navbar.component.js +3 -5
  20. package/dist/containers/navbar/navbar.styles.js +4 -2
  21. package/dist/contexts/properties.context.d.ts +8 -0
  22. package/dist/contexts/properties.context.js +5 -0
  23. package/dist/core/types/api-schema.d.ts +181 -5
  24. package/dist/core/types/core/index.d.ts +0 -1
  25. package/dist/core/types/index.d.ts +0 -1
  26. package/dist/core/utils/loyalty.d.ts +37 -4
  27. package/dist/core/utils/loyalty.js +14 -5
  28. package/dist/core/utils/seats.d.ts +6 -0
  29. package/dist/core/utils/seats.js +40 -0
  30. package/dist/index.d.ts +1 -1
  31. package/dist/locales/ar-SA.d.ts +5 -0
  32. package/dist/locales/ar-SA.js +6 -1
  33. package/dist/locales/da-DK.d.ts +5 -0
  34. package/dist/locales/da-DK.js +5 -0
  35. package/dist/locales/de-DE.d.ts +5 -0
  36. package/dist/locales/de-DE.js +5 -0
  37. package/dist/locales/en-IE.d.ts +5 -0
  38. package/dist/locales/en-IE.js +5 -0
  39. package/dist/locales/en-US.d.ts +5 -0
  40. package/dist/locales/en-US.js +5 -0
  41. package/dist/locales/es-ES.d.ts +5 -0
  42. package/dist/locales/es-ES.js +5 -0
  43. package/dist/locales/fr-FR.d.ts +5 -0
  44. package/dist/locales/fr-FR.js +5 -0
  45. package/dist/locales/fr-MA.d.ts +5 -0
  46. package/dist/locales/fr-MA.js +5 -0
  47. package/dist/locales/is-IS.d.ts +5 -0
  48. package/dist/locales/is-IS.js +5 -0
  49. package/dist/locales/it-IT.d.ts +5 -0
  50. package/dist/locales/it-IT.js +5 -0
  51. package/dist/locales/ms-MY.d.ts +5 -0
  52. package/dist/locales/ms-MY.js +5 -0
  53. package/dist/locales/nb-NO.d.ts +5 -0
  54. package/dist/locales/nb-NO.js +5 -0
  55. package/dist/locales/pl-PL.d.ts +5 -0
  56. package/dist/locales/pl-PL.js +5 -0
  57. package/dist/locales/pt-PT.d.ts +5 -0
  58. package/dist/locales/pt-PT.js +5 -0
  59. package/dist/locales/sv-SE.d.ts +5 -0
  60. package/dist/locales/sv-SE.js +5 -0
  61. package/dist/locales/th-TH.d.ts +5 -0
  62. package/dist/locales/th-TH.js +5 -0
  63. package/dist/locales/tr-TR.d.ts +5 -0
  64. package/dist/locales/tr-TR.js +5 -0
  65. package/dist/locales/zh-CN.d.ts +5 -0
  66. package/dist/locales/zh-CN.js +5 -0
  67. package/dist/locales/zh-HK.d.ts +5 -0
  68. package/dist/locales/zh-HK.js +5 -0
  69. package/dist/mixins/base.mixin.d.ts +2 -0
  70. package/dist/mixins/base.mixin.js +8 -1
  71. package/dist/mixins/location-search/location-search.js +70 -29
  72. package/dist/mixins/location-search/location-search.styles.js +11 -7
  73. package/dist/mixins/search-mixin/search-mixin.js +2 -2
  74. package/dist/sdk/page-registry.js +2 -0
  75. package/dist/sdk/theme.d.ts +1 -1
  76. package/dist/sdk/types.d.ts +9 -1
  77. package/dist/sdk/validation.js +51 -0
  78. package/dist/styles/tokens.d.ts +1 -1
  79. package/dist/styles/tokens.generated.d.ts +1 -1
  80. package/dist/styles/tokens.generated.js +1 -1
  81. package/dist/styles/tokens.metadata.js +18 -0
  82. package/dist/views/chrome-only-page/chrome-only-page.component.d.ts +1 -0
  83. package/dist/views/details-page/details-page.component.d.ts +2 -1
  84. package/dist/views/details-page/details-page.component.js +15 -5
  85. package/dist/views/details-page/partials/location-highlights/location-highlights.component.d.ts +2 -0
  86. package/dist/views/details-page/partials/location-highlights/location-highlights.component.js +16 -2
  87. package/dist/views/help-page/help-page.component.d.ts +1 -0
  88. package/dist/views/landing-page/landing-page.component.d.ts +5 -3
  89. package/dist/views/landing-page/landing-page.component.js +66 -28
  90. package/dist/views/payment-page/controllers/form-validation.controller.d.ts +4 -1
  91. package/dist/views/payment-page/controllers/form-validation.controller.js +7 -2
  92. package/dist/views/payment-page/partials/confirmation/confirmation.component.js +49 -27
  93. package/dist/views/payment-page/partials/stripe/stripe.types.d.ts +1 -0
  94. package/dist/views/payment-page/partials/stripe/stripe.utils.js +5 -0
  95. package/dist/views/payment-page/payment-page.component.d.ts +6 -0
  96. package/dist/views/payment-page/payment-page.component.js +76 -8
  97. package/dist/views/payment-page/payment-page.loyalty.d.ts +13 -0
  98. package/dist/views/payment-page/payment-page.loyalty.js +80 -0
  99. package/dist/views/payment-page/payment-page.styles.js +16 -0
  100. package/dist/views/payment-page/payment-page.utils.d.ts +1 -1
  101. package/dist/views/payment-page/payment-page.utils.js +19 -1
  102. package/dist/views/payment-page/services/payment-api.service.d.ts +1 -0
  103. package/dist/views/search-page/search-page.component.d.ts +1 -0
  104. package/dist/views/search-page/search-page.component.js +10 -0
  105. package/dist/views/suggestion-widget/suggestion-widget.component.d.ts +1 -0
  106. package/dist/views/suggestion-widget/suggestion-widget.component.js +11 -1
  107. package/package.json +5 -5
  108. package/dist/components/points/points.component.d.ts +0 -9
  109. package/dist/components/points/points.component.js +0 -36
  110. package/dist/components/points/points.d.ts +0 -8
  111. package/dist/components/points/points.js +0 -6
  112. package/dist/components/points/points.styles.js +0 -47
  113. package/dist/core/types/core/points.d.ts +0 -4
  114. package/dist/mixins/points/points.d.ts +0 -3
  115. package/dist/mixins/points/points.js +0 -30
  116. package/dist/mixins/points/types.d.ts +0 -8
  117. package/dist/mixins/points/types.js +0 -1
  118. /package/dist/components/{points/points.styles.d.ts → loyalty-badge/loyalty-badge.styles.d.ts} +0 -0
  119. /package/dist/{core/types/core/points.js → components/loyalty-badge/loyalty-badge.types.js} +0 -0
@@ -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("../../mixins/points/types.js").Constructor<import("../../mixins/points/types.js").PointsMixinInterface> & import("../../contexts/utils.js").Constructor<import("../../mixins/location-search/types.js").LocationSearchMixinInterface> & import("../../contexts/utils.js").Constructor<{
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;
@@ -108,6 +108,8 @@ export declare class CorasLandingPage extends CorasLandingPage_base {
108
108
  private updateSelectedPriceOptions;
109
109
  private renderPriceFilter;
110
110
  private filtersTask;
111
+ private locationCategoriesTask;
112
+ private keepCategoriesAvailableAtLocation;
111
113
  private transformFiltersToCategories;
112
114
  private renderCategoriesTree;
113
115
  private renderFiltersButtons;
@@ -117,9 +119,9 @@ export declare class CorasLandingPage extends CorasLandingPage_base {
117
119
  private renderAttractionsTitle;
118
120
  private renderSections;
119
121
  private renderShowMoreButton;
120
- private renderPoints;
121
122
  private renderAttractionCards;
122
123
  private get resolvedCountry();
124
+ private get resolvedCountryCode();
123
125
  private renderLocationImage;
124
126
  private renderBreadcrumbs;
125
127
  private renderAttractionsSkeleton;
@@ -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(PointsMixin(LocationSearchMixin(BaseMixin(LitElement)))) {
55
+ let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(LocationSearchMixin(BaseMixin(LitElement))) {
57
56
  constructor() {
58
57
  super(...arguments);
59
58
  this.currentPage = "landing";
@@ -102,6 +101,28 @@ let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(PointsMixi
102
101
  },
103
102
  args: () => [this.locale, this.currency],
104
103
  });
104
+ this.locationCategoriesTask = new Task(this, {
105
+ task: async ([locale, city, countryCode]) => {
106
+ if (!city && !countryCode)
107
+ return null;
108
+ const { data } = await apiGet({
109
+ client: this.client,
110
+ distributorID: this.distributorID,
111
+ endpoint: "/{api_version}/categories",
112
+ locale,
113
+ query: {
114
+ city_slug: city || undefined,
115
+ country_code: countryCode || undefined,
116
+ },
117
+ });
118
+ return data ?? null;
119
+ },
120
+ args: () => [
121
+ this.locale,
122
+ this.city,
123
+ this.city ? "" : this.resolvedCountryCode,
124
+ ],
125
+ });
105
126
  this.attractionsSearchTask = new Task(this, {
106
127
  task: async ([locale, country, city, startDate, endDate, sorting, duration, price, categories, currency,]) => {
107
128
  const { data } = await apiGet({
@@ -684,6 +705,21 @@ let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(PointsMixi
684
705
  })}
685
706
  </coras-checkbox-group>`;
686
707
  }
708
+ keepCategoriesAvailableAtLocation(categories, locationCategories) {
709
+ const availableSubcategories = new Map(locationCategories.map((category) => [
710
+ category.slug,
711
+ new Set(category.subcategories?.map((sub) => sub.slug)),
712
+ ]));
713
+ return categories.flatMap((category) => {
714
+ const available = availableSubcategories.get(category.slug);
715
+ if (!available)
716
+ return [];
717
+ const subcategories = (category.subcategories ?? []).filter((sub) => available.has(sub.slug));
718
+ if (category.subcategories?.length && !subcategories.length)
719
+ return [];
720
+ return [{ ...category, subcategories }];
721
+ });
722
+ }
687
723
  transformFiltersToCategories(filters) {
688
724
  const categoryFilters = filters.filter((filter) => filter.type === "category");
689
725
  return categoryFilters.map((categoryFilter, index) => ({
@@ -709,16 +745,20 @@ let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(PointsMixi
709
745
  if (!filters)
710
746
  return nothing;
711
747
  const transformedCategories = this.transformFiltersToCategories(filters);
712
- return html `
713
- <coras-categories-tree
714
- .categories=${transformedCategories}
715
- .selectedCategories=${this._selectedCategories}
716
- @selection-changed=${(event) => {
717
- this._selectedCategories = event.detail;
718
- event.stopPropagation();
719
- }}
720
- ></coras-categories-tree>
721
- `;
748
+ return this.locationCategoriesTask.render({
749
+ error: () => nothing,
750
+ pending: () => this.renderFiltersSkeleton(),
751
+ complete: (locationCategories) => html `<coras-categories-tree
752
+ .categories=${locationCategories
753
+ ? this.keepCategoriesAvailableAtLocation(transformedCategories, locationCategories)
754
+ : transformedCategories}
755
+ .selectedCategories=${this._selectedCategories}
756
+ @selection-changed=${(event) => {
757
+ this._selectedCategories = event.detail;
758
+ event.stopPropagation();
759
+ }}
760
+ ></coras-categories-tree>`,
761
+ });
722
762
  },
723
763
  });
724
764
  }
@@ -777,20 +817,6 @@ let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(PointsMixi
777
817
  renderShowMoreButton(_) {
778
818
  return html `<span class="show-more-button" aria-hidden="true"></span>`;
779
819
  }
780
- renderPoints(price) {
781
- if (this.calculateRewardPoints) {
782
- price = price / 100;
783
- const points = this.calculateRewardPoints({ price });
784
- return html `<coras-points
785
- slot="points"
786
- points=${points.toLocaleString("en-GB")}
787
- points-logo-url=${this.pointsLogoUrl}
788
- points-icon-url=${this.pointsIconUrl}
789
- points-unit=${this.pointsUnit}
790
- ></coras-points>`;
791
- }
792
- return html ``;
793
- }
794
820
  renderAttractionCards(section) {
795
821
  const currency = this.currency;
796
822
  const locale = this.locale;
@@ -829,7 +855,14 @@ let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(PointsMixi
829
855
  }),
830
856
  })}
831
857
  >
832
- ${this.renderPoints(card.price[currency])}
858
+ ${renderLoyaltyBadge({
859
+ loyalty: card.loyalty,
860
+ programme: this.loyaltyProgramme,
861
+ locale: this.locale,
862
+ variant: "card",
863
+ slot: "points",
864
+ from: true,
865
+ })}
833
866
  </coras-attraction-short-card>
834
867
  `;
835
868
  })}
@@ -848,6 +881,11 @@ let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(PointsMixi
848
881
  ?.flatMap((continent) => continent.countries ?? [])
849
882
  .find((country) => country?.cities?.some((city) => city?.slug === this.city))?.slug ?? "");
850
883
  }
884
+ get resolvedCountryCode() {
885
+ return (this.locationsData
886
+ ?.flatMap((continent) => continent.countries ?? [])
887
+ .find((country) => country?.slug === this.resolvedCountry)?.code ?? "");
888
+ }
851
889
  renderLocationImage() {
852
890
  if (this.city && !this.resolvedCountry) {
853
891
  return nothing;
@@ -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, FIELDS, required, context);
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, FIELDS, required, checkData, shouldValidateBillingAddress, (fieldName) => this.getValidationContext(fieldName));
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) => html `
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
- dateTime: reservation.start_datetime,
110
- timezone: reservation.timezone,
111
- locale: this.locale || navigator.language,
112
- }, {
113
- includeYear: true,
114
- shortFormat: true,
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
- dateTime: reservation.start_datetime,
118
- timezone: reservation.timezone,
119
- locale: this.locale || navigator.language,
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
- ? html `${reservation.location_name}, ${reservation.city}`
129
- : reservation.city}
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
- ? html `
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
- : nothing}
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
- const payAmount = getLoyaltyAmount(reservation.loyalty, "pay");
147
- return this.loyalty && payAmount
148
- ? `${new Intl.NumberFormat(this.locale || navigator.language).format(payAmount)} FIDA`
149
- : convertToLocaleCurrency({
150
- value: reservation.total_price,
151
- locale: this.locale || navigator.language,
152
- currency: (reservation.currency ||
153
- "USD"),
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")}
@@ -61,6 +61,7 @@ export interface ThemeColors {
61
61
  textColor: string;
62
62
  placeholderColor: string;
63
63
  errorColor: string;
64
+ backgroundColor: string;
64
65
  }
65
66
  /** Custom event types emitted by the Stripe component. */
66
67
  export interface CorasStripeEventMap {
@@ -88,6 +88,7 @@ export function extractThemeColors(host) {
88
88
  DEFAULT_COLORS.PLACEHOLDER,
89
89
  errorColor: resolve(read(CSS_VARS.FIELD_INPUT_ERROR_COLOR), "color") ||
90
90
  DEFAULT_COLORS.ERROR,
91
+ backgroundColor: resolve(read(CSS_VARS.SURFACE), "color") || DEFAULT_COLORS.BACKGROUND,
91
92
  }));
92
93
  }
93
94
  /** True when a resolved CSS colour (rgb()/rgba()/#hex) reads as dark. */
@@ -143,6 +144,10 @@ export function createStripeElementStyle(colors) {
143
144
  "::placeholder": {
144
145
  color: colors.placeholderColor,
145
146
  },
147
+ ":-webkit-autofill": {
148
+ color: colors.textColor,
149
+ backgroundColor: colors.backgroundColor,
150
+ },
146
151
  iconColor: colors.textColor,
147
152
  },
148
153
  invalid: {
@@ -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
- // Host-supplied custom data, stored by the API and returned on read.
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, FIELDS);
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.renderActivityDetails()} ${this.renderPaymentTypeSelector()}
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>;