wickes-css2 2.106.0-develop.4 → 2.106.0-gift-cards.2

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 (123) hide show
  1. package/Readme.md +2 -2
  2. package/build/css/category-main.css +1 -1
  3. package/build/css/components/checkout-payment-details-v2.css +1 -1
  4. package/build/css/components/global-search.css +1 -1
  5. package/build/css/homepage-main.css +1 -1
  6. package/build/css/kitchen-plp-main.css +1 -1
  7. package/build/css/main.css +1 -1
  8. package/build/css/my-account-main-v2.css +1 -1
  9. package/build/css/my-account-main.css +1 -1
  10. package/build/css/pages/page_checkout_delivery-new.css +1 -1
  11. package/build/css/pages/page_products-list-combined.css +1 -1
  12. package/build/css/pdp-main-before-combine.css +1 -1
  13. package/build/css/pdp-main-critical.css +1 -1
  14. package/build/css/pdp-main-non-critical.css +1 -1
  15. package/build/css/pdp-main.css +1 -1
  16. package/build/css/plp-main.css +1 -1
  17. package/build/css/store-locator-main.css +1 -1
  18. package/build/img/billie-pay-later.svg +13 -0
  19. package/build/img/giftcard.svg +28 -0
  20. package/build/js/account-members.min.js +1 -1
  21. package/build/js/add-project-list-id.min.js +1 -1
  22. package/build/js/address-book.min.js +1 -1
  23. package/build/js/basket.min.js +2 -2
  24. package/build/js/bundle.min.js +1 -1
  25. package/build/js/change-password.min.js +1 -1
  26. package/build/js/checkout.min.js +2 -2
  27. package/build/js/emulation.min.js +2126 -1898
  28. package/build/js/general.bundle.min.js +1 -1
  29. package/build/js/gift-cards.min.js +1 -0
  30. package/build/js/merged-checkout.min.js +2 -2
  31. package/build/js/mini-basket-slider.min.js +1 -1
  32. package/build/js/page/basket/basket-update-cart-action.js +4 -1
  33. package/build/js/page/basket/klarna.js +13 -3
  34. package/build/js/page/basket-v2.js +6 -2
  35. package/build/js/page/components/billie-modal.js +20 -20
  36. package/build/js/page/components/gift-cards.js +915 -0
  37. package/build/js/page/components/order-summary.js +42 -25
  38. package/build/js/page/components/toggle-password-visibility.js +22 -0
  39. package/build/js/page/components/voucher.js +52 -47
  40. package/build/js/page/filters/plp-filters.js +2 -2
  41. package/build/js/page/kitchen/colour-swatches.js +152 -152
  42. package/build/js/page/plp-img-v2.js +25 -0
  43. package/build/js/page/quick-filter.js +103 -106
  44. package/build/js/page/utils/gift-cards-utils.js +188 -0
  45. package/build/js/page/utils/input-handling.js +92 -0
  46. package/build/js/page/utils/show-hide-input.js +28 -0
  47. package/build/js/page/utils/validation.js +46 -1
  48. package/build/js/pdp.bundle.min.js +1 -1
  49. package/build/js/personal-details.min.js +1 -1
  50. package/build/js/plp-filters.min.js +1 -1
  51. package/build/js/plp.bundle.min.js +1 -1
  52. package/build/js/project-list.min.js +44 -1
  53. package/build/js/quiz.min.js +1 -1
  54. package/build/js/track-my-order.min.js +1 -1
  55. package/package.json +2 -2
  56. package/src/components/checkout-payment-details-v2.hbs +4 -3
  57. package/src/components/gift-cards-hint.hbs +9 -0
  58. package/src/components/gift-cards.hbs +90 -0
  59. package/src/components/giftcard-chip.hbs +23 -0
  60. package/src/components/giftcard-summary.hbs +6 -0
  61. package/src/components/home-movers/form.hbs +1 -1
  62. package/src/components/price-block-v2.hbs +1 -1
  63. package/src/elements/form-row.hbs +1 -1
  64. package/src/elements/input.hbs +31 -2
  65. package/src/img/billie-pay-later.svg +13 -0
  66. package/src/img/giftcard.svg +28 -0
  67. package/src/js/components/general/notification.js +2 -1
  68. package/src/js/components/pdp-billie-modal-scroll-reset.js +42 -46
  69. package/src/js/emulation/basket-data.js +2126 -2038
  70. package/src/js/emulation/billie-modal.js +6 -6
  71. package/src/js/emulation/checkLocalEnv.js +6 -5
  72. package/src/js/emulation/checkout-data.js +35 -0
  73. package/src/js/emulation/checkout-payment-details.js +28 -26
  74. package/src/js/emulation/forms.js +16 -10
  75. package/src/js/emulation/gift-cards.js +205 -0
  76. package/src/js/emulation/mock.js +21 -88
  77. package/src/js/page/basket/basket-update-cart-action.js +4 -1
  78. package/src/js/page/basket/klarna.js +13 -3
  79. package/src/js/page/basket-v2.js +6 -2
  80. package/src/js/page/components/billie-modal.js +20 -20
  81. package/src/js/page/components/gift-cards.js +915 -0
  82. package/src/js/page/components/order-summary.js +42 -25
  83. package/src/js/page/components/toggle-password-visibility.js +22 -0
  84. package/src/js/page/components/voucher.js +52 -47
  85. package/src/js/page/filters/plp-filters.js +2 -2
  86. package/src/js/page/kitchen/colour-swatches.js +152 -152
  87. package/src/js/page/plp-img-v2.js +25 -0
  88. package/src/js/page/quick-filter.js +103 -106
  89. package/src/js/page/utils/gift-cards-utils.js +188 -0
  90. package/src/js/page/utils/input-handling.js +92 -0
  91. package/src/js/page/utils/show-hide-input.js +28 -0
  92. package/src/js/page/utils/validation.js +46 -1
  93. package/src/layouts/checkout.hbs +1 -5
  94. package/src/page_my-account_change-password.html +1 -0
  95. package/src/page_payment-details-with-gift-card.html +8 -5
  96. package/src/page_plp-with-paint.html +1 -1
  97. package/src/page_plp_v2-energy-efficiency.html +1 -1
  98. package/src/page_plp_v2-favourite-products.html +1 -1
  99. package/src/page_plp_v2-vat.html +1 -1
  100. package/src/page_plp_v2.html +1 -1
  101. package/src/page_product_search-vat.html +1 -1
  102. package/src/page_product_search.html +1 -1
  103. package/src/page_search-results.html +1 -1
  104. package/src/partials/scripts.hbs +0 -1
  105. package/src/scss/components/_custom-slider.scss +6 -7
  106. package/src/scss/components/_gift-cards.scss +360 -0
  107. package/src/scss/components/_quick-filter.scss +10 -32
  108. package/src/scss/components/checkout-payment-details-v2.scss +6 -2
  109. package/src/scss/components/kitchen/_price-tooltip.scss +2 -3
  110. package/src/scss/components/kitchen/_price.scss +2 -2
  111. package/src/scss/helpers/_variables.scss +16 -7
  112. package/src/scss/pages/page_checkout_delivery-new.scss +26 -0
  113. package/src/scss/pages/page_products-list-combined.scss +2 -34
  114. package/src/scss/pdp-main.scss +0 -1
  115. package/build/js/page/count-stepper/pdp-count-stepper.js +0 -29
  116. package/build/js/page/utils/create-count-stepper.js +0 -141
  117. package/build/js/pdp-count-stepper.min.js +0 -1
  118. package/src/elements/count-button.hbs +0 -10
  119. package/src/js/components/toggle-password-visibility.js +0 -58
  120. package/src/js/emulation/validity-emulation.js +0 -33
  121. package/src/js/page/count-stepper/pdp-count-stepper.js +0 -29
  122. package/src/js/page/utils/create-count-stepper.js +0 -141
  123. package/src/scss/components/_input-counter.scss +0 -65
@@ -0,0 +1,25 @@
1
+ $(document).ready(function () {
2
+
3
+ let imgWrap = $('.products-list-v2 .card__img-wrap');
4
+ let img = $('.products-list-v2 .card__img-v2');
5
+
6
+ square();
7
+
8
+ img.height(function () {
9
+ if (Math.round($(this).height()) > Math.round($(this).width())) {
10
+ $(this).height('99.9%'); //fix for ie
11
+ } else if ((Math.round($(this).height()) < Math.round($(this).width()))){
12
+ $(this).width('99.9%'); // fix for ie
13
+ } else {
14
+ $(this).width('99.9%'); // fix for ie
15
+ $(this).height('99.9%'); // fix for ie
16
+ }
17
+ });
18
+
19
+ function square() {
20
+ let width = imgWrap.width();
21
+ imgWrap.height(width);
22
+ }
23
+
24
+ $(window).on('resize', square);
25
+ });
@@ -1,111 +1,108 @@
1
1
  $(document).ready(function () {
2
- const SELECTORS = {
3
- quickFilter: '.quick-filter',
4
- swiperContainer: '.swiper-container',
5
- pagination: '.swiper-pagination',
6
- nextButton: '.quick-filter__next-btn',
7
- prevButton: '.quick-filter__prev-btn',
2
+ const SELECTORS = {
3
+ quickFilter: '.quick-filter',
4
+ swiperContainer: '.swiper-container',
5
+ pagination: '.swiper-pagination',
6
+ nextButton: '.quick-filter__next-btn',
7
+ prevButton: '.quick-filter__prev-btn',
8
+ };
9
+
10
+ const CSS_CLASSES = {
11
+ locked: 'quick-filter--locked',
12
+ colourSwatch: 'quick-filter--colour',
13
+ textOnly: 'quick-filter--text',
14
+ bulletClass: 'swiper-pagination-bullet',
15
+ bulletActiveClass: 'swiper-pagination-bullet-active'
16
+ };
17
+
18
+ const CONFIG = {
19
+ speed: 400,
20
+ defaultSpaceBetween: 16,
21
+ textOnlySpaceBetween: 8,
22
+ resizeDebounceTime: 250,
23
+ breakpoints: {
24
+ mobile: 767,
25
+ mobileSpaceBetween: 8,
26
+ },
27
+ };
28
+
29
+ function shouldSkipSlider($slider) {
30
+ return $slider.hasClass(CSS_CLASSES.colourSwatch);
31
+ }
32
+
33
+ function getSpaceBetween($slider) {
34
+ const isTextOnly = $slider.hasClass(CSS_CLASSES.textOnly);
35
+ return isTextOnly ? CONFIG.textOnlySpaceBetween : CONFIG.defaultSpaceBetween;
36
+ }
37
+
38
+ function getSwiperConfig($pagination, $nextBtn, $prevBtn, spaceBetween) {
39
+ return {
40
+ speed: CONFIG.speed,
41
+ spaceBetween: spaceBetween,
42
+ slidesPerView: 'auto',
43
+ watchOverflow: true,
44
+ pagination: {
45
+ el: $pagination[0],
46
+ type: 'bullets',
47
+ clickable: true,
48
+ bulletClass: CSS_CLASSES.bulletClass,
49
+ bulletActiveClass: CSS_CLASSES.bulletActiveClass,
50
+ },
51
+ navigation: {
52
+ nextEl: $nextBtn[0],
53
+ prevEl: $prevBtn[0],
54
+ },
55
+ breakpoints: {
56
+ [CONFIG.breakpoints.mobile]: {
57
+ spaceBetween: CONFIG.breakpoints.mobileSpaceBetween,
58
+ },
59
+ },
60
+ on: {
61
+ lock: handleLock,
62
+ unlock: handleUnlock,
63
+ },
8
64
  };
65
+ }
9
66
 
10
- const CSS_CLASSES = {
11
- locked: 'quick-filter--locked',
12
- colourSwatch: 'quick-filter--colour',
13
- textOnly: 'quick-filter--text',
14
- bulletClass: 'swiper-pagination-bullet',
15
- bulletActiveClass: 'swiper-pagination-bullet-active',
16
- };
67
+ function handleLock() {
68
+ this.el.parentElement.classList.add(CSS_CLASSES.locked);
69
+ }
17
70
 
18
- const CONFIG = {
19
- speed: 400,
20
- defaultSpaceBetween: 16,
21
- textOnlySpaceBetween: 8,
22
- resizeDebounceTime: 250,
23
- breakpoints: {
24
- mobile: 767,
25
- mobileSpaceBetween: 8,
26
- },
27
- };
71
+ function handleUnlock() {
72
+ this.el.parentElement.classList.remove(CSS_CLASSES.locked);
73
+ }
74
+
75
+ function initializeSwiper($slider) {
76
+ const $container = $slider.find(SELECTORS.swiperContainer);
77
+ const $pagination = $slider.find(SELECTORS.pagination);
78
+ const $nextBtn = $slider.find(SELECTORS.nextButton);
79
+ const $prevBtn = $slider.find(SELECTORS.prevButton);
80
+
81
+ const spaceBetween = getSpaceBetween($slider);
82
+ const config = getSwiperConfig($pagination, $nextBtn, $prevBtn, spaceBetween);
83
+
84
+ const swiper = new Swiper($container[0], config);
85
+
86
+ bindResizeHandler(swiper);
87
+ }
88
+
89
+ function bindResizeHandler(swiper) {
90
+ $(window).on('resize', _.debounce(function () {
91
+ swiper.update();
92
+ }, CONFIG.resizeDebounceTime));
93
+ }
94
+
95
+ function init() {
96
+ $(SELECTORS.quickFilter).each(function (index, slider) {
97
+ const $slider = $(slider);
98
+
99
+ if (shouldSkipSlider($slider)) {
100
+ return;
101
+ }
102
+
103
+ initializeSwiper($slider);
104
+ });
105
+ }
28
106
 
29
- function shouldSkipSlider($slider) {
30
- return $slider.hasClass(CSS_CLASSES.colourSwatch);
31
- }
32
-
33
- function getSpaceBetween($slider) {
34
- const isTextOnly = $slider.hasClass(CSS_CLASSES.textOnly);
35
- return isTextOnly ? CONFIG.textOnlySpaceBetween : CONFIG.defaultSpaceBetween;
36
- }
37
-
38
- function getSwiperConfig($pagination, $nextBtn, $prevBtn, spaceBetween) {
39
- return {
40
- speed: CONFIG.speed,
41
- spaceBetween: spaceBetween,
42
- slidesPerView: 'auto',
43
- watchOverflow: true,
44
- pagination: {
45
- el: $pagination[0],
46
- type: 'bullets',
47
- clickable: true,
48
- bulletClass: CSS_CLASSES.bulletClass,
49
- bulletActiveClass: CSS_CLASSES.bulletActiveClass,
50
- },
51
- navigation: {
52
- nextEl: $nextBtn[0],
53
- prevEl: $prevBtn[0],
54
- },
55
- breakpoints: {
56
- [CONFIG.breakpoints.mobile]: {
57
- spaceBetween: CONFIG.breakpoints.mobileSpaceBetween,
58
- },
59
- },
60
- on: {
61
- lock: handleLock,
62
- unlock: handleUnlock,
63
- },
64
- };
65
- }
66
-
67
- function handleLock() {
68
- this.el.parentElement.classList.add(CSS_CLASSES.locked);
69
- }
70
-
71
- function handleUnlock() {
72
- this.el.parentElement.classList.remove(CSS_CLASSES.locked);
73
- }
74
-
75
- function initializeSwiper($slider) {
76
- const $container = $slider.find(SELECTORS.swiperContainer);
77
- const $pagination = $slider.find(SELECTORS.pagination);
78
- const $nextBtn = $slider.find(SELECTORS.nextButton);
79
- const $prevBtn = $slider.find(SELECTORS.prevButton);
80
-
81
- const spaceBetween = getSpaceBetween($slider);
82
- const config = getSwiperConfig($pagination, $nextBtn, $prevBtn, spaceBetween);
83
-
84
- const swiper = new Swiper($container[0], config);
85
-
86
- bindResizeHandler(swiper);
87
- }
88
-
89
- function bindResizeHandler(swiper) {
90
- $(window).on(
91
- 'resize',
92
- _.debounce(function () {
93
- swiper.update();
94
- }, CONFIG.resizeDebounceTime)
95
- );
96
- }
97
-
98
- function init() {
99
- $(SELECTORS.quickFilter).each(function (index, slider) {
100
- const $slider = $(slider);
101
-
102
- if (shouldSkipSlider($slider)) {
103
- return;
104
- }
105
-
106
- initializeSwiper($slider);
107
- });
108
- }
109
-
110
- init();
111
- });
107
+ init();
108
+ });
@@ -0,0 +1,188 @@
1
+ import { showLoader, hideLoader } from "./loader";
2
+
3
+ const SUMMARY_SELECTORS = {
4
+ subTotal: { item: '.checkout-widget__item-bold', value: '.checkout-widget__item-value', title: 'Items subtotal:' },
5
+ vat: { item: '.checkout-widget__item-vat', value: '.checkout-widget__item-value', title: 'VAT:' },
6
+ clickAndCollectCost: { item: '.checkout-widget__item-cc', value: '.checkout-widget__item-value', title: 'Click & Collect:' },
7
+ deliveryCost: { item: '.checkout-widget__item-delivery', value: '.checkout-widget__item-value', title: 'Delivery:' },
8
+ charityPrice: { item: '.checkout-widget__item-charity', value: '.checkout-widget__item-value', title: 'Charity donation:' },
9
+ discountTotal: { item: '.checkout-widget__details-discount', value: '.checkout-widget__detail-value' },
10
+ giftCardApplied: { item: '.checkout-widget__gift-card', value: '.checkout-widget__item-value', title: 'Gift Card:' },
11
+ total: { item: '.checkout-widget__total', value: '.checkout-widget__total-value' },
12
+ };
13
+
14
+ const CURRENCY_KEYS = new Set([
15
+ 'subTotal','vat','clickAndCollectCost','deliveryCost',
16
+ 'charityPrice','discountTotal','total','giftCardApplied'
17
+ ]);
18
+
19
+ const GIFT_CARD_ALREADY_ADDED = 'GIFT_CARD_ALREADY_ADDED';
20
+ const PIS_REQUEST_TIMEOUT = 'PIS-REQUEST-TIMEOUT';
21
+ const PIS_INTEGRATION_ERROR = 'PIS-INTEGRATION-ERROR';
22
+ const PIS_INSUFFICIENT_AMOUNT = 'PIS-INSUFFICIENT-AMOUNT';
23
+ const PIS_PROCESSING_ERROR = 'PIS_PROCESSING_ERROR';
24
+ const HYBRIS_REQUEST_TIMEOUT = 'HYBRIS-REQUEST-TIMEOUT';
25
+ const HYBRIS_PIS_INTEGRATION_ERROR = 'HYBRIS-PIS_INTEGRATION-ERROR';
26
+ const HYBRIS_PIS_CONNECTION_ERROR = 'HYBRIS-PIS_CONNECTION-ERROR';
27
+ const ZERO_BALANCE = 'ZERO_BALANCE';
28
+ const SPLIT_PAYMENT_CARD_ERROR = 'SPLIT_PAYMENT_CARD_ERROR';
29
+
30
+ export const DEFAULT_ERROR_MESSAGE =
31
+ 'Unable to use Gift Card at this time, please try later or click here for support.';
32
+
33
+ export const DEFAULT_PAY_ERROR_MESSAGE =
34
+ 'Unfortunately there was a problem placing your order with Gift Card(s). Please click here for support.';
35
+
36
+ export const OK_CODE = 0;
37
+
38
+ export const MESSAGE_BY_CODE = {
39
+ 10: 'Gift Card number and / or PIN not recognised. A Gift Card will be locked following three unsuccessful PIN attempts.',
40
+ 16: 'Card locked due to three unsuccessful PIN entries. For support click here.',
41
+ 20: 'Unable to use Gift Card at this time, please try later or click here for support.',
42
+ 21: 'Gift Card number not recognised.',
43
+ 40: 'Unable to use Gift Card at this time, please try later or click here for support.',
44
+ 60: 'The entered Gift Card has expired. For support click here.',
45
+ 75: 'The entered Gift Card is invalid. For support click here.',
46
+ [GIFT_CARD_ALREADY_ADDED]: 'Gift Card already added, please use a different card.',
47
+ [PIS_REQUEST_TIMEOUT]: 'Unable to use Gift Card at this time, please try later or click here for support.',
48
+ [PIS_INTEGRATION_ERROR]: 'Unable to use Gift Card at this time, please try later or click here for support.',
49
+ [PIS_INSUFFICIENT_AMOUNT]: 'Unfortunately there was a problem placing your order with Gift Card(s). Please click here for support.',
50
+ [PIS_PROCESSING_ERROR]: 'Unfortunately there was a problem placing your order with Gift Card(s). Please click here for support.',
51
+ [HYBRIS_REQUEST_TIMEOUT]: 'Unable to use Gift Card at this time, please try later or click here for support.',
52
+ [HYBRIS_PIS_INTEGRATION_ERROR]: 'Unable to use Gift Card at this time, please try later or click here for support.',
53
+ [HYBRIS_PIS_CONNECTION_ERROR]: 'Unable to use Gift Card at this time, please try later or click here for support.',
54
+ [ZERO_BALANCE]: 'Insufficient funds available, please try another Gift Card or alternate payment method.',
55
+ 99: 'The entered Gift Card is invalid. For support click here.',
56
+ [-1]: 'Gift Card is unavailable at this time, please try later. For support click here.',
57
+ };
58
+
59
+ export const PAY_MESSAGE_BY_CODE = {
60
+ 101: 'Unable to use Gift Cards at this time, please try later or click here for support.',
61
+ 102: 'Unfortunately there was a problem with requesting your card details from the payment provider. Available funds on your Gift Card are unchanged.',
62
+ 103: 'Unfortunately there was a problem placing your order with Gift Card(s). Please click here for support.',
63
+ 104: 'Unfortunately there was a problem placing your order with Gift Card(s). Please click here for support.',
64
+ [PIS_REQUEST_TIMEOUT]: 'Unable to use Gift Card at this time, please try later or click here for support.',
65
+ [PIS_INTEGRATION_ERROR]: 'Unable to use Gift Card at this time, please try later or click here for support.',
66
+ [PIS_INSUFFICIENT_AMOUNT]: 'Unfortunately there was a problem placing your order with Gift Card(s). Please click here for support.',
67
+ [PIS_PROCESSING_ERROR]: 'Unfortunately there was a problem placing your order with Gift Card(s). Please click here for support.',
68
+ [HYBRIS_REQUEST_TIMEOUT]: 'Unable to use Gift Card at this time, please try later or click here for support.',
69
+ [HYBRIS_PIS_INTEGRATION_ERROR]: 'Unable to use Gift Card at this time, please try later or click here for support.',
70
+ [HYBRIS_PIS_CONNECTION_ERROR]: 'Unable to use Gift Card at this time, please try later or click here for support.',
71
+ [SPLIT_PAYMENT_CARD_ERROR]: 'Unfortunately there was a problem with requesting your card details from the payment provider. Available funds on your Gift Card are unchanged.',
72
+ };
73
+
74
+ export const ADD_GIFT_CARD = 'addGiftCard';
75
+ export const REMOVE_GIFT_CARD = 'removeGiftCard';
76
+ export const PAY_WITH_GIFT_CARD = 'payWithGiftCard';
77
+
78
+ export const FAQ_URL = 'https://www.wickes.co.uk/gifts';
79
+
80
+ export const escapeHtml = (s) => $('<div>').text(String(s || '')).html();
81
+
82
+ export const linkifyClickHere = (msg) =>
83
+ escapeHtml(msg).replace(
84
+ /\bclick here\b/gi,
85
+ `<a href="${FAQ_URL}" target="_blank" rel="noopener" class="notification_link">click here</a>`
86
+ );
87
+
88
+ export function formatGc16(raw) {
89
+ const digits = String(raw || '').replace(/\D/g, '').slice(0, 16);
90
+ return digits.replace(/(\d{4})(?=\d)/g, '$1-');
91
+ }
92
+
93
+ function formatGBP(value) {
94
+ if (value === null || typeof value === 'undefined' || String(value).trim() === '') {
95
+ return value;
96
+ }
97
+
98
+ const cleanedValue = String(value).replace(/[^\d.-]/g, '');
99
+ const numberValue = Number(cleanedValue);
100
+
101
+ if (Number.isFinite(numberValue)) {
102
+ return `£${numberValue.toFixed(2)}`;
103
+ }
104
+
105
+ return value;
106
+ }
107
+
108
+ export function buildHintContext(count, limit) {
109
+ const max = count >= limit;
110
+
111
+ return {
112
+ canAdd: !max,
113
+ max,
114
+ hintClass: `giftcard-summary__hint${max ? ' giftcard-summary__hint--max' : ''}`,
115
+ };
116
+ }
117
+
118
+ export function buildSummaryEqualMap(data) {
119
+ return Object.entries(SUMMARY_SELECTORS).map(([key, d]) => {
120
+ const raw = data[key];
121
+ let dataValue = raw;
122
+
123
+ if (key === 'giftCardApplied') {
124
+ if (isZeroAmount(raw)) {
125
+ dataValue = '';
126
+ } else if (raw != null && raw !== '') {
127
+ dataValue = formatGBP(raw);
128
+ if (typeof dataValue === 'string' && dataValue.startsWith('£')) {
129
+ dataValue = `-${dataValue}`;
130
+ }
131
+ }
132
+ } else {
133
+ if (CURRENCY_KEYS.has(key) && raw != null && raw !== '') {
134
+ dataValue = formatGBP(raw);
135
+ }
136
+ }
137
+
138
+ return {
139
+ item: d.item,
140
+ itemValue: d.value,
141
+ dataValue,
142
+ ...(d.title ? { title: d.title } : {}),
143
+ };
144
+ });
145
+ }
146
+
147
+ export function isZeroAmount(val) {
148
+ const cleaned = String(val ?? '').replace(/[^\d.]/g, '');
149
+ if (!cleaned) {
150
+ return false;
151
+ }
152
+ const num = Number(cleaned);
153
+ return Number.isFinite(num) && num === 0;
154
+ }
155
+
156
+ // --- API/Event-Dispatching Functions ---
157
+
158
+ export function verifyGiftCard($loader, giftCardNumber, pin) {
159
+ showLoader($loader);
160
+ return new Promise((resolve, reject) => {
161
+ const payload = { giftCardNumber, pin };
162
+ const detail = { resolve, reject, payload };
163
+ const evt = createEvent(ADD_GIFT_CARD, payload, detail);
164
+ window.dispatchEvent(evt);
165
+ }).finally(() => {
166
+ hideLoader($loader);
167
+ });
168
+ }
169
+
170
+ export function removeGiftCard($loader, index) {
171
+ showLoader($loader);
172
+ return new Promise((resolve, reject) => {
173
+ const payload = { index };
174
+ const detail = { resolve, reject, payload };
175
+ const evt = createEvent(REMOVE_GIFT_CARD, payload, detail);
176
+ window.dispatchEvent(evt);
177
+ }).finally(() => {
178
+ hideLoader($loader);
179
+ });
180
+ }
181
+
182
+ export function payWithGiftCard() {
183
+ return new Promise((resolve, reject) => {
184
+ const detail = { resolve, reject };
185
+ const evt = createEvent(PAY_WITH_GIFT_CARD, undefined, detail);
186
+ window.dispatchEvent(evt);
187
+ });
188
+ }
@@ -0,0 +1,92 @@
1
+ import {formatGc16} from './gift-cards-utils';
2
+ import {clearErrorText, showErrorText} from './validation';
3
+
4
+
5
+ export function createGcNumberInputHandler({
6
+ fieldSelector,
7
+ fieldErrorClass,
8
+ errorTextSelector,
9
+ ariaInvalidAttr
10
+ }) {
11
+ return function handleGcNumberInput(e) {
12
+ const input = e.currentTarget;
13
+ const $input = $(input);
14
+
15
+ const canTrack = typeof input.selectionStart === 'number';
16
+ const atEnd = canTrack && input.selectionStart === input.value.length;
17
+
18
+ const hadErr = $input.closest(fieldSelector).hasClass(fieldErrorClass);
19
+
20
+ input.value = formatGc16(input.value);
21
+
22
+ if (hadErr) {
23
+ clearErrorText($input, fieldSelector, errorTextSelector, fieldErrorClass, ariaInvalidAttr);
24
+ }
25
+
26
+ if (atEnd && typeof input.setSelectionRange === 'function') {
27
+ input.setSelectionRange(input.value.length, input.value.length);
28
+ }
29
+ };
30
+ }
31
+
32
+ export function digitsOnlyKeypress(e) {
33
+ if (!/\d/.test(String.fromCharCode(e.which || e.keyCode))) {
34
+ e.preventDefault();
35
+ }
36
+ }
37
+
38
+ export function handleGcNumberBlur(e, {
39
+ fieldSelector,
40
+ errorTextSelector,
41
+ errorClass,
42
+ ariaInvalidAttr,
43
+ numberMessage,
44
+ }) {
45
+ const $input = $(e.currentTarget);
46
+ const len = String($input.val() || '').replace(/\D/g, '').length;
47
+
48
+ clearErrorText($input, fieldSelector, errorTextSelector, errorClass, ariaInvalidAttr);
49
+
50
+ if (len < 16) {
51
+ showErrorText($input, numberMessage, fieldSelector, errorTextSelector, errorClass, ariaInvalidAttr);
52
+ }
53
+ }
54
+
55
+ export function handleGcPinInput(e, {
56
+ fieldSelector,
57
+ errorTextSelector,
58
+ errorClass,
59
+ ariaInvalidAttr,
60
+ }) {
61
+ const input = e.currentTarget;
62
+ const $input = $(input);
63
+
64
+ const hadErr = $input.closest(fieldSelector).hasClass(errorClass);
65
+ input.value = String(input.value || '').replace(/\D/g, '').slice(0, 8);
66
+
67
+ if (hadErr) {
68
+ clearErrorText($input, fieldSelector, errorTextSelector, errorClass, ariaInvalidAttr);
69
+ }
70
+ }
71
+
72
+
73
+ export function handleGcPinKeypress(e) {
74
+ if (!/\d/.test(String.fromCharCode(e.which || e.keyCode))) e.preventDefault();
75
+ }
76
+
77
+ export function handleGcPinBlur(e, {
78
+ fieldSelector,
79
+ errorTextSelector,
80
+ errorClass,
81
+ ariaInvalidAttr,
82
+ pinMessage,
83
+ }) {
84
+ const $input = $(e.currentTarget);
85
+ const length = String($input.val() || '').replace(/\D/g, '').length;
86
+
87
+ clearErrorText($input, fieldSelector, errorTextSelector, errorClass, ariaInvalidAttr);
88
+
89
+ if (length < 8) {
90
+ showErrorText($input, pinMessage, fieldSelector, errorTextSelector, errorClass, ariaInvalidAttr);
91
+ }
92
+ }
@@ -0,0 +1,28 @@
1
+ export function initializeInputToggle($container) {
2
+ const $input = $container.find('input');
3
+ const $toggle = $container.find('.toggle-show');
4
+
5
+ if (!$input.length || !$toggle.length) return;
6
+
7
+ const handleToggleClick = (e) => {
8
+ e.preventDefault();
9
+
10
+ const isPassword = String($input.attr('type')) === 'password';
11
+ $input.attr('type', isPassword ? 'text' : 'password');
12
+ const $icon = $toggle.find('svg, i').first();
13
+
14
+ if ($icon.length) {
15
+ $icon.removeClass('fa-eye fa-eye-slash').addClass(isPassword ? 'fa-eye' : 'fa-eye-slash');
16
+ }
17
+ };
18
+
19
+ const updateToggleVisibility = () => {
20
+ $toggle.toggle(($input.val() || '').length > 0);
21
+ };
22
+
23
+ $toggle.off('click.passwordToggle mousedown.passwordToggle')
24
+ .on('mousedown.passwordToggle', handleToggleClick);
25
+
26
+ $input.off('input.passwordToggle').on('input.passwordToggle', updateToggleVisibility);
27
+ updateToggleVisibility();
28
+ }
@@ -257,7 +257,6 @@ export function wrapWithError(element) {
257
257
 
258
258
  }
259
259
 
260
-
261
260
  export function addErrorMessage(element, errorMessage) {
262
261
  if (errorMessage) {
263
262
  $(element).append('<div class="form-row__error">' + errorMessage + '</div>');
@@ -316,3 +315,49 @@ export function validateGuidPattern (value) {
316
315
  export function validateUserFriendlyIdPattern (value) {
317
316
  return patterns.userFriendlyIdPattern.test(value);
318
317
  }
318
+
319
+ export function showErrorText($input, message, fieldSelector, errorTextClass, errorClass, ariaInvalidAttr) {
320
+ const $field = $input.closest(fieldSelector);
321
+ $field.addClass(errorClass);
322
+ $input.attr(ariaInvalidAttr, 'true');
323
+
324
+ let $err = $field.find(errorTextClass);
325
+ if (!$err.length) {
326
+ $err = $(`<div class="${errorTextClass.slice(1)}" />`).appendTo($field);
327
+ }
328
+ $err.text(message);
329
+ }
330
+
331
+ export function clearErrorText($input, fieldSelector, errorTextClass, errorClass, ariaInvalidAttr) {
332
+ const $field = $input.closest(fieldSelector);
333
+ $field.removeClass(errorClass);
334
+ $input.removeAttr(ariaInvalidAttr);
335
+ $field.find(errorTextClass).remove();
336
+ }
337
+
338
+ function digitsOnly(value) {
339
+ return String(value || '').replace(/\D/g, '');
340
+ }
341
+
342
+ function hasExactDigits(value, n) {
343
+ return digitsOnly(value).length === Number(n);
344
+ }
345
+
346
+ function validateByPredicate($input, predicate, message, {
347
+ fieldSelector,
348
+ errorText: errorTextClass,
349
+ fieldError: errorClass,
350
+ ariaInvalidAttr,
351
+ }) {
352
+ const ok = !!predicate(String($input.val() || ''));
353
+ if (!ok) {
354
+ showErrorText($input, message, fieldSelector, errorTextClass, errorClass, ariaInvalidAttr);
355
+ } else {
356
+ clearErrorText($input, fieldSelector, errorTextClass, errorClass, ariaInvalidAttr);
357
+ }
358
+ return ok;
359
+ }
360
+
361
+ export function validateExactDigits($input, n, message, cfg) {
362
+ return validateByPredicate($input, (v) => hasExactDigits(v, n), message, cfg);
363
+ }