@roomstay/frontend 2.0.0-1 → 2.0.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/dist/201.bundle.js +1 -1
- package/dist/218.bundle.js +1 -1
- package/dist/279.bundle.js +1 -1
- package/dist/370.bundle.js +1 -1
- package/dist/449.bundle.js +1 -1
- package/dist/873.bundle.js +1 -1
- package/dist/882.bundle.js +1 -1
- package/dist/972.bundle.js +1 -1
- package/dist/main.bundle.js +1 -1
- package/dist/src/components/steps/confirmation/PaymentDetails/StepConfirmationPaymentDetails.js +1 -11
- package/dist/src/components/steps/confirmation/PaymentDetails/StepConfirmationPaymentDetails.js.map +1 -1
- package/dist/src/components/steps/confirmation/RoomContactDetails.js +2 -1
- package/dist/src/components/steps/confirmation/RoomContactDetails.js.map +1 -1
- package/dist/src/components/steps/room/MemberSignInModal/MemberSignInModal.js +18 -12
- package/dist/src/components/steps/room/MemberSignInModal/MemberSignInModal.js.map +1 -1
- package/dist/src/components/steps/room/RoomList.js +1 -1
- package/dist/src/components/steps/room/RoomList.js.map +1 -1
- package/dist/src/components/steps/room/StepRoomErrorForm.js +2 -1
- package/dist/src/components/steps/room/StepRoomErrorForm.js.map +1 -1
- package/dist/src/components/steps/room/roomDetails/RoomDetails.js +8 -8
- package/dist/src/components/steps/room/roomDetails/RoomDetails.js.map +1 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/MembersOnlyRow.js.map +1 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateListPromotion/RoomRateListPromotion.d.ts +7 -0
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateListPromotion/RoomRateListPromotion.js +31 -0
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateListPromotion/RoomRateListPromotion.js.map +1 -0
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRates.js +14 -7
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRates.js.map +1 -1
- package/dist/src/contexts/BasketContext/BasketContextType.js.map +1 -1
- package/dist/src/contexts/BasketContext/BasketContextWrapper.js +12 -8
- package/dist/src/contexts/BasketContext/BasketContextWrapper.js.map +1 -1
- package/dist/src/contexts/CompanyContext/CompanyContextType.type.d.ts +3 -1
- package/dist/src/contexts/CompanyContext/CompanyContextType.type.js.map +1 -1
- package/dist/src/contexts/CompanyContext/CompanyContextWrapper.js +9 -1
- package/dist/src/contexts/CompanyContext/CompanyContextWrapper.js.map +1 -1
- package/dist/src/contexts/ConfirmationStepContext/ConfirmationStepContextWrapper.js +3 -2
- package/dist/src/contexts/ConfirmationStepContext/ConfirmationStepContextWrapper.js.map +1 -1
- package/dist/src/contexts/FullPageEngineContext/FullPageEngineContextWrapper.js.map +1 -1
- package/dist/src/engines/InlineRoomMiniEngine/InlineRoomMiniEngineElement.js +71 -1
- package/dist/src/engines/InlineRoomMiniEngine/InlineRoomMiniEngineElement.js.map +1 -1
- package/dist/src/events/RoomstayEventManager.d.ts +1 -1
- package/dist/src/events/RoomstayEventManager.js +23 -4
- package/dist/src/events/RoomstayEventManager.js.map +1 -1
- package/dist/src/events/actions/MemberOnlyFence/MemberOnlyFenceSignUp.d.ts +7 -0
- package/dist/src/events/actions/MemberOnlyFence/MemberOnlyFenceSignUp.js +15 -0
- package/dist/src/events/actions/MemberOnlyFence/MemberOnlyFenceSignUp.js.map +1 -0
- package/dist/src/events/actions/Promotion/PromotionAddedEvent.d.ts +7 -0
- package/dist/src/events/actions/Promotion/PromotionAddedEvent.js +15 -0
- package/dist/src/events/actions/Promotion/PromotionAddedEvent.js.map +1 -0
- package/dist/src/events/actions/Promotion/PromotionClickedEvent.d.ts +7 -0
- package/dist/src/events/actions/Promotion/PromotionClickedEvent.js +15 -0
- package/dist/src/events/actions/Promotion/PromotionClickedEvent.js.map +1 -0
- package/dist/src/events/actions/Promotion/PromotionRemovedEvent.d.ts +7 -0
- package/dist/src/events/actions/Promotion/PromotionRemovedEvent.js +15 -0
- package/dist/src/events/actions/Promotion/PromotionRemovedEvent.js.map +1 -0
- package/dist/src/events/index.d.ts +1 -0
- package/dist/src/events/index.js +1 -0
- package/dist/src/events/index.js.map +1 -1
- package/dist/src/hooks/EventHook.d.ts +1 -1
- package/dist/src/hooks/EventHook.js +2 -2
- package/dist/src/hooks/EventHook.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/models/Promotion/IPromotion.type.d.ts +27 -0
- package/dist/src/models/Promotion/IPromotion.type.js +3 -0
- package/dist/src/models/Promotion/IPromotion.type.js.map +1 -0
- package/dist/src/pages/findReservation/FindReservation.js +2 -1
- package/dist/src/pages/findReservation/FindReservation.js.map +1 -1
- package/dist/src/providers/LanguageProvider.d.ts +14 -3
- package/dist/src/providers/LanguageProvider.js +3 -19
- package/dist/src/providers/LanguageProvider.js.map +1 -1
- package/dist/src/providers/PromotionProvider.d.ts +14 -0
- package/dist/src/providers/PromotionProvider.js +213 -0
- package/dist/src/providers/PromotionProvider.js.map +1 -0
- package/dist/src/util/ObjectHelper.d.ts +4 -0
- package/dist/src/util/ObjectHelper.js +25 -0
- package/dist/src/util/ObjectHelper.js.map +1 -0
- package/dist/src/util/Validation.d.ts +1 -0
- package/dist/src/util/Validation.js +2 -1
- package/dist/src/util/Validation.js.map +1 -1
- package/dist/test.bundle.js +1 -1
- package/dist/tests/jest/helpers/ObjectHelper.test.d.ts +1 -0
- package/dist/tests/jest/helpers/ObjectHelper.test.js +72 -0
- package/dist/tests/jest/helpers/ObjectHelper.test.js.map +1 -0
- package/dist/tests/offline/entry/RSCompany.js +42 -1
- package/dist/tests/offline/entry/RSCompany.js.map +1 -1
- package/dist/vendors.bundle.js +1 -1
- package/package.json +1 -1
- package/dist/src/components/steps/confirmation/StepConfirmationPaymentDetails.d.ts +0 -8
- package/dist/src/components/steps/confirmation/StepConfirmationPaymentDetails.js +0 -241
- package/dist/src/components/steps/confirmation/StepConfirmationPaymentDetails.js.map +0 -1
- package/dist/src/contexts/BasketContext/BasketContextType.d.ts +0 -41
package/package.json
CHANGED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const React = require("react");
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const InputGroup_1 = require("components/generic/InputGroup/InputGroup");
|
|
6
|
-
const AutoAutoHeight_1 = require("animations/AutoAutoHeight");
|
|
7
|
-
const Alert_1 = require("components/generic/Alert");
|
|
8
|
-
const Icon_1 = require("components/generic/Icon/Icon");
|
|
9
|
-
const Text_1 = require("components/generic/Text");
|
|
10
|
-
const react_i18next_1 = require("react-i18next");
|
|
11
|
-
const Translation_1 = require("translations/Translation");
|
|
12
|
-
const RoomstayThemeEngine_1 = require("providers/RoomstayThemeEngine");
|
|
13
|
-
const DataLayer_1 = require("util/DataLayer");
|
|
14
|
-
const HotelDTO_1 = require("models/Api/HotelDTO");
|
|
15
|
-
const LargeLoader_1 = require("components/generic/loader/LargeLoader");
|
|
16
|
-
const hooks_1 = require("@frontend/hooks");
|
|
17
|
-
window.VGSCollect = window.VGSCollect || {};
|
|
18
|
-
class VGSInputMapper {
|
|
19
|
-
constructor(name, type, ref, vgsProps) {
|
|
20
|
-
this.name = name;
|
|
21
|
-
this.ref = ref;
|
|
22
|
-
this.type = type;
|
|
23
|
-
this.vgsProps = vgsProps;
|
|
24
|
-
this.isValid = null;
|
|
25
|
-
this.isFocused = false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function StepConfirmationPaymentDetails(props, ref) {
|
|
29
|
-
var _a;
|
|
30
|
-
const { hotel } = (0, hooks_1.useCurrentHotel)();
|
|
31
|
-
const [VGSForm, setVGSForm] = (0, react_1.useState)(null);
|
|
32
|
-
const [errors, setErrors] = (0, react_1.useState)({});
|
|
33
|
-
const [vgsLoaded, setVgsLoaded] = (0, react_1.useState)(false);
|
|
34
|
-
const { focusElement } = (0, hooks_1.useWindowScroll)();
|
|
35
|
-
const setErrorsOnFaults = (faults) => {
|
|
36
|
-
const newErrors = {};
|
|
37
|
-
Object.keys(faults).forEach((input) => {
|
|
38
|
-
let name = '';
|
|
39
|
-
switch (input) {
|
|
40
|
-
case 'credit-card':
|
|
41
|
-
name = 'Credit Card';
|
|
42
|
-
break;
|
|
43
|
-
case 'expiration-date':
|
|
44
|
-
name = 'Expiration Date';
|
|
45
|
-
break;
|
|
46
|
-
case 'security-code':
|
|
47
|
-
name = 'Security Code';
|
|
48
|
-
break;
|
|
49
|
-
default:
|
|
50
|
-
name = 'Card Name';
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
newErrors[input] = name + ' ' + faults[input].errorMessages[faults[input].errorMessages.length - 1];
|
|
54
|
-
});
|
|
55
|
-
setErrors(newErrors);
|
|
56
|
-
};
|
|
57
|
-
(0, react_1.useEffect)(() => {
|
|
58
|
-
var _a, _b;
|
|
59
|
-
if (errors && Object.keys(errors).length !== 0 && ((_a = cardNumber === null || cardNumber === void 0 ? void 0 : cardNumber.ref) === null || _a === void 0 ? void 0 : _a.current)) {
|
|
60
|
-
focusElement((_b = cardNumber === null || cardNumber === void 0 ? void 0 : cardNumber.ref) === null || _b === void 0 ? void 0 : _b.current);
|
|
61
|
-
}
|
|
62
|
-
}, [errors]);
|
|
63
|
-
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
64
|
-
getTokenizedCode: () => new Promise((resolve, reject) => {
|
|
65
|
-
if (VGSForm) {
|
|
66
|
-
VGSForm.submit('/post', {
|
|
67
|
-
serializer: 'deep',
|
|
68
|
-
methods: 'POST',
|
|
69
|
-
}, (status, response) => {
|
|
70
|
-
const cardData = JSON.parse(response.data);
|
|
71
|
-
const expMatch = cardData['expiration-date'].match(/^(\d+)\s*\/\s*(\d+)$/);
|
|
72
|
-
if (!expMatch || expMatch[1].length > 2 || (expMatch[2].length !== 4 && expMatch[2].length !== 2)) {
|
|
73
|
-
setErrorsOnFaults({
|
|
74
|
-
'expiration-date': {
|
|
75
|
-
errorMessages: ['Invalid - it must be in the format MM / YY or MM / YYYY'],
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
reject('invalid expiration date');
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const expiration = (expMatch[1].length === 1 ? '0' : '') + expMatch[1] + (expMatch[2].length === 2 ? expMatch[2] : expMatch[2].substr(2));
|
|
82
|
-
const card = {
|
|
83
|
-
CVV: cardData['security-code'],
|
|
84
|
-
Expiry: parseInt(expiration),
|
|
85
|
-
Name: cardData['card-name'],
|
|
86
|
-
Number: cardData['credit-card'],
|
|
87
|
-
Type: window.VGSCollect.enteredCardType,
|
|
88
|
-
};
|
|
89
|
-
resolve(card);
|
|
90
|
-
}, (error) => {
|
|
91
|
-
setErrorsOnFaults(error);
|
|
92
|
-
reject(error);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
console.error('VGS not on element, problem has occurred');
|
|
97
|
-
}
|
|
98
|
-
}),
|
|
99
|
-
}));
|
|
100
|
-
const formRef = (0, react_1.useRef)(null);
|
|
101
|
-
const getClassesFormInput = (mapper) => {
|
|
102
|
-
const classes = ['c-input'];
|
|
103
|
-
if (mapper.isFocused) {
|
|
104
|
-
classes.push('--selected');
|
|
105
|
-
}
|
|
106
|
-
if (mapper.isValid !== null) {
|
|
107
|
-
if (mapper.isValid) {
|
|
108
|
-
classes.push('--success');
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
classes.push('--error');
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return classes.join(' ');
|
|
115
|
-
};
|
|
116
|
-
const getVGSInputProps = (mapper) => {
|
|
117
|
-
return Object.assign({ name: mapper.name, type: mapper.type }, mapper.vgsProps);
|
|
118
|
-
};
|
|
119
|
-
const css = {
|
|
120
|
-
fontSize: '13px',
|
|
121
|
-
lineHeight: '18px',
|
|
122
|
-
'&::placeholder': {
|
|
123
|
-
color: '#8B8F9A',
|
|
124
|
-
opacity: 1,
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
const { t } = (0, react_i18next_1.useTranslation)();
|
|
128
|
-
const cardNumberplaceholder = t(Translation_1.Translation.Step.Confirmation.Inputs.CardNumber);
|
|
129
|
-
const nameOnCardplaceholder = t(Translation_1.Translation.Step.Confirmation.Inputs.NameOnCard);
|
|
130
|
-
const securityCodeplaceholder = t(Translation_1.Translation.Step.Confirmation.Inputs.SecurityCode);
|
|
131
|
-
const cardExpiryplaceholder = t(Translation_1.Translation.Step.Confirmation.Inputs.CardExpiry);
|
|
132
|
-
const [cardNumber, setCardNumber] = (0, react_1.useState)(new VGSInputMapper('credit-card', 'card-number', (0, react_1.useRef)(null), {
|
|
133
|
-
autoComplete: ['cc-number'],
|
|
134
|
-
successColor: '#4F8A10',
|
|
135
|
-
errorColor: '#D8000C',
|
|
136
|
-
showCardIcon: false,
|
|
137
|
-
placeholder: cardNumberplaceholder + ' *',
|
|
138
|
-
validations: ['required', 'validCardNumber'],
|
|
139
|
-
css,
|
|
140
|
-
}));
|
|
141
|
-
const [nameOnCard, setNameOnCard] = (0, react_1.useState)(new VGSInputMapper('card-name', 'text', (0, react_1.useRef)(null), {
|
|
142
|
-
placeholder: nameOnCardplaceholder + ' *',
|
|
143
|
-
validations: ['required'],
|
|
144
|
-
css,
|
|
145
|
-
}));
|
|
146
|
-
const [expirationDate, setExpirationDate] = (0, react_1.useState)(new VGSInputMapper('expiration-date', 'card-expiration-date', (0, react_1.useRef)(null), {
|
|
147
|
-
placeholder: cardExpiryplaceholder + ' *',
|
|
148
|
-
validations: ['required', 'validCardExpirationDate'],
|
|
149
|
-
css,
|
|
150
|
-
}));
|
|
151
|
-
const [securityCode, setSecurityCode] = (0, react_1.useState)(new VGSInputMapper('security-code', 'card-security-code', (0, react_1.useRef)(null), {
|
|
152
|
-
placeholder: securityCodeplaceholder + ' *',
|
|
153
|
-
validations: ['required', 'validCardSecurityCode'],
|
|
154
|
-
css,
|
|
155
|
-
}));
|
|
156
|
-
const vgsInputsAndSetters = [
|
|
157
|
-
[cardNumber, setCardNumber],
|
|
158
|
-
[nameOnCard, setNameOnCard],
|
|
159
|
-
[expirationDate, setExpirationDate],
|
|
160
|
-
[securityCode, setSecurityCode],
|
|
161
|
-
];
|
|
162
|
-
const inputNames = ['credit-card', 'card-name', 'expiration-date', 'security-code'];
|
|
163
|
-
const [selectedCard, setSelectedCard] = (0, react_1.useState)(String);
|
|
164
|
-
const cardTypes = ((_a = hotel === null || hotel === void 0 ? void 0 : hotel.paymentCardTypes) !== null && _a !== void 0 ? _a : [])
|
|
165
|
-
.map((card) => {
|
|
166
|
-
const mapping = HotelDTO_1.SynxisToVGSCardNameMapping[card];
|
|
167
|
-
if (!mapping) {
|
|
168
|
-
return null;
|
|
169
|
-
}
|
|
170
|
-
return {
|
|
171
|
-
name: HotelDTO_1.SynxisToVGSCardNameMapping[card],
|
|
172
|
-
status: false,
|
|
173
|
-
};
|
|
174
|
-
})
|
|
175
|
-
.filter((obj) => obj);
|
|
176
|
-
(0, react_1.useEffect)(() => {
|
|
177
|
-
let cancelled = false;
|
|
178
|
-
RoomstayThemeEngine_1.default.loadScript('https://js.verygoodvault.com/vgs-collect/1/AC7dReJwJ6EWF1L9FHdcCw7n.js', 'vgs-collect').then(() => {
|
|
179
|
-
if (!cancelled) {
|
|
180
|
-
setVgsLoaded(true);
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
return () => {
|
|
184
|
-
cancelled = true;
|
|
185
|
-
};
|
|
186
|
-
}, []);
|
|
187
|
-
(0, react_1.useEffect)(() => {
|
|
188
|
-
if (vgsLoaded) {
|
|
189
|
-
setVGSForm(window.VGSCollect.create(hotel === null || hotel === void 0 ? void 0 : hotel.vgsVaultName, (state) => {
|
|
190
|
-
var _a, _b;
|
|
191
|
-
DataLayer_1.default.instance.sendInteraction('Payment Info', DataLayer_1.InteractionType.FORM_FIELD, DataLayer_1.InteractionStep.GUEST_DETAILS);
|
|
192
|
-
window.VGSCollect.enteredCardType = (_a = state['credit-card']) === null || _a === void 0 ? void 0 : _a.cardType;
|
|
193
|
-
setSelectedCard((_b = state['credit-card']) === null || _b === void 0 ? void 0 : _b.cardType);
|
|
194
|
-
vgsInputsAndSetters.forEach((getNSet) => {
|
|
195
|
-
const old = Object.assign({}, getNSet[0]);
|
|
196
|
-
const clone = getNSet[0];
|
|
197
|
-
const vgsState = state[getNSet[0].name];
|
|
198
|
-
if (vgsState) {
|
|
199
|
-
clone.isFocused = vgsState.isFocused;
|
|
200
|
-
clone.isValid = !vgsState.isEmpty ? vgsState.isValid : null;
|
|
201
|
-
}
|
|
202
|
-
getNSet[1](Object.assign({}, clone));
|
|
203
|
-
});
|
|
204
|
-
}));
|
|
205
|
-
}
|
|
206
|
-
}, [vgsLoaded]);
|
|
207
|
-
(0, react_1.useEffect)(() => {
|
|
208
|
-
if (VGSForm) {
|
|
209
|
-
vgsInputsAndSetters.forEach((getNSet) => {
|
|
210
|
-
const mapper = getNSet[0];
|
|
211
|
-
VGSForm.field(mapper.ref.current, getVGSInputProps(mapper));
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}, [VGSForm]);
|
|
215
|
-
if (vgsLoaded) {
|
|
216
|
-
return (React.createElement(React.Fragment, null,
|
|
217
|
-
inputNames.map((name) => {
|
|
218
|
-
const errorMessage = errors[name];
|
|
219
|
-
return (React.createElement(AutoAutoHeight_1.default, { open: !!errorMessage, key: name },
|
|
220
|
-
React.createElement("div", { className: "u-flex" },
|
|
221
|
-
React.createElement(Alert_1.default, { type: Alert_1.AlertType.Danger, icon: Icon_1.IconType.Error },
|
|
222
|
-
React.createElement(Text_1.default, { type: Text_1.TextType.Small }, errorMessage)))));
|
|
223
|
-
}),
|
|
224
|
-
React.createElement("div", { className: "u-flex flex-row justify-content-start u-marg-bottom" }, Object.keys(cardTypes).map((cardKey) => {
|
|
225
|
-
return (React.createElement("div", { key: cardKey, id: cardTypes[cardKey].name, className: 'cc-icon u-flex u-marg-right--light' + (selectedCard !== null ? (cardTypes[cardKey].name === selectedCard ? ' -current' : '') : ' -default'), style: { backgroundImage: `url('${RoomstayThemeEngine_1.default.getAssetUrl() + 'assets/img/' + cardTypes[cardKey].name + '.png'}')` } }));
|
|
226
|
-
})),
|
|
227
|
-
React.createElement("form", { ref: formRef },
|
|
228
|
-
React.createElement(InputGroup_1.default, { dimensions: "2/2" },
|
|
229
|
-
React.createElement("div", { className: getClassesFormInput(cardNumber), ref: cardNumber.ref }),
|
|
230
|
-
React.createElement(InputGroup_1.default, { dimensions: "2/2" },
|
|
231
|
-
React.createElement("div", { className: getClassesFormInput(expirationDate), ref: expirationDate.ref }),
|
|
232
|
-
React.createElement("div", { className: getClassesFormInput(securityCode), ref: securityCode.ref }))),
|
|
233
|
-
React.createElement(InputGroup_1.default, { dimensions: "1" },
|
|
234
|
-
React.createElement("div", { className: getClassesFormInput(nameOnCard), ref: nameOnCard.ref })))));
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
return React.createElement(LargeLoader_1.default, null);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
exports.default = (0, react_1.forwardRef)(StepConfirmationPaymentDetails);
|
|
241
|
-
//# sourceMappingURL=StepConfirmationPaymentDetails.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StepConfirmationPaymentDetails.js","sourceRoot":"/","sources":["src/components/steps/confirmation/StepConfirmationPaymentDetails.tsx"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,iCAAqF;AACrF,yEAAkE;AAClE,8DAAuD;AACvD,oDAA4D;AAC5D,uDAAwD;AACxD,kDAAyD;AACzD,iDAA+C;AAC/C,0DAAuD;AACvD,uEAAgE;AAChE,8CAA6E;AAC7E,kDAAiE;AACjE,uEAAgE;AAChE,2CAAmE;AASnE,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;AAI5C,MAAM,cAAc;IAShB,YAAmB,IAAY,EAAE,IAAk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E,GAC9H,CACL,CAAC;YACN,CAAC,CAAC,CACA;YACN,8BAAM,GAAG,EAAE,OAAO;gBACd,oBAAC,oBAAU,IAAC,UAAU,EAAC,KAAK;oBACxB,6BAAK,SAAS,EAAE,mBAAmB,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,GAAI;oBACxE,oBAAC,oBAAU,IAAC,UAAU,EAAC,KAAK;wBACxB,6BAAK,SAAS,EAAE,mBAAmB,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,cAAc,CAAC,GAAG,GAAI;wBAChF,6BAAK,SAAS,EAAE,mBAAmB,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,GAAI,CACnE,CACJ;gBACb,oBAAC,oBAAU,IAAC,UAAU,EAAC,GAAG;oBACtB,6BAAK,SAAS,EAAE,mBAAmB,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,GAAI,CAC/D,CACV,CACR,CACN,CAAC;KACL;SAAM;QACH,OAAO,oBAAC,qBAAW,OAAG,CAAC;KAC1B;AACL,CAAC;AAED,kBAAe,IAAA,kBAAU,EAAC,8BAA8B,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport InputGroup from 'components/generic/InputGroup/InputGroup';\nimport AutoAutoHeight from 'animations/AutoAutoHeight';\nimport Alert, { AlertType } from 'components/generic/Alert';\nimport { IconType } from 'components/generic/Icon/Icon';\nimport Text, { TextType } from 'components/generic/Text';\nimport { useTranslation } from 'react-i18next';\nimport { Translation } from 'translations/Translation';\nimport RoomstayThemeEngine from 'providers/RoomstayThemeEngine';\nimport DataLayer, { InteractionStep, InteractionType } from 'util/DataLayer';\nimport { SynxisToVGSCardNameMapping } from 'models/Api/HotelDTO';\nimport LargeLoader from 'components/generic/loader/LargeLoader';\nimport { useCurrentHotel, useWindowScroll } from '@frontend/hooks';\nimport { IBookingPaymentTokenizedCard } from '@roomstay/core';\n\ndeclare global {\n interface Window {\n VGSCollect: any;\n }\n}\n\nwindow.VGSCollect = window.VGSCollect || {};\n\ntype VGSInputType = 'card-number' | 'text' | 'card-expiration-date' | 'card-security-code';\n\nclass VGSInputMapper {\n public ref: React.MutableRefObject<any>;\n public vgsProps: any;\n public name: string;\n public type: VGSInputType;\n\n public isFocused: boolean;\n public isValid: boolean;\n\n public constructor(name: string, type: VGSInputType, ref: React.MutableRefObject<any>, vgsProps: any) {\n this.name = name;\n this.ref = ref;\n this.type = type;\n this.vgsProps = vgsProps;\n\n this.isValid = null;\n this.isFocused = false;\n }\n}\n\nfunction StepConfirmationPaymentDetails(props: any, ref: any) {\n const { hotel } = useCurrentHotel();\n\n const [VGSForm, setVGSForm] = useState(null);\n const [errors, setErrors] = useState<{ [x: string]: string }>({});\n const [vgsLoaded, setVgsLoaded] = useState(false);\n\n const { focusElement } = useWindowScroll();\n\n const setErrorsOnFaults = (faults: any) => {\n const newErrors: { [x: string]: string } = {};\n\n Object.keys(faults).forEach((input) => {\n let name = '';\n\n switch (input) {\n case 'credit-card':\n name = 'Credit Card';\n break;\n case 'expiration-date':\n name = 'Expiration Date';\n break;\n case 'security-code':\n name = 'Security Code';\n break;\n default:\n name = 'Card Name';\n break;\n }\n\n newErrors[input] = name + ' ' + faults[input].errorMessages[faults[input].errorMessages.length - 1];\n });\n\n setErrors(newErrors);\n };\n\n useEffect(() => {\n if (errors && Object.keys(errors).length !== 0 && cardNumber?.ref?.current) {\n focusElement(cardNumber?.ref?.current);\n }\n }, [errors]);\n\n useImperativeHandle(ref, () => ({\n getTokenizedCode: () =>\n new Promise<IBookingPaymentTokenizedCard>((resolve, reject) => {\n if (VGSForm) {\n VGSForm.submit(\n '/post',\n {\n serializer: 'deep',\n methods: 'POST',\n },\n (status: any, response: any) => {\n const cardData = JSON.parse(response.data);\n const expMatch = cardData['expiration-date'].match(/^(\\d+)\\s*\\/\\s*(\\d+)$/);\n if (!expMatch || expMatch[1].length > 2 || (expMatch[2].length !== 4 && expMatch[2].length !== 2)) {\n setErrorsOnFaults({\n 'expiration-date': {\n errorMessages: ['Invalid - it must be in the format MM / YY or MM / YYYY'],\n },\n });\n reject('invalid expiration date');\n return;\n }\n\n const expiration = (expMatch[1].length === 1 ? '0' : '') + expMatch[1] + (expMatch[2].length === 2 ? expMatch[2] : expMatch[2].substr(2));\n\n const card: IBookingPaymentTokenizedCard = {\n CVV: cardData['security-code'],\n Expiry: parseInt(expiration),\n Name: cardData['card-name'],\n Number: cardData['credit-card'],\n Type: window.VGSCollect.enteredCardType,\n };\n\n resolve(card);\n },\n (error: any) => {\n setErrorsOnFaults(error);\n reject(error);\n }\n );\n } else {\n console.error('VGS not on element, problem has occurred');\n }\n }),\n }));\n\n const formRef = useRef(null);\n\n const getClassesFormInput = (mapper: VGSInputMapper) => {\n const classes = ['c-input'];\n\n if (mapper.isFocused) {\n classes.push('--selected');\n }\n\n if (mapper.isValid !== null) {\n if (mapper.isValid) {\n classes.push('--success');\n } else {\n classes.push('--error');\n }\n }\n\n return classes.join(' ');\n };\n\n const getVGSInputProps = (mapper: VGSInputMapper) => {\n return {\n name: mapper.name,\n type: mapper.type,\n ...mapper.vgsProps,\n };\n };\n\n const css = {\n fontSize: '13px',\n lineHeight: '18px',\n '&::placeholder': {\n color: '#8B8F9A',\n opacity: 1,\n },\n };\n const { t } = useTranslation();\n const cardNumberplaceholder = t(Translation.Step.Confirmation.Inputs.CardNumber);\n const nameOnCardplaceholder = t(Translation.Step.Confirmation.Inputs.NameOnCard);\n const securityCodeplaceholder = t(Translation.Step.Confirmation.Inputs.SecurityCode);\n const cardExpiryplaceholder = t(Translation.Step.Confirmation.Inputs.CardExpiry);\n\n const [cardNumber, setCardNumber] = useState(\n new VGSInputMapper('credit-card', 'card-number', useRef(null), {\n autoComplete: ['cc-number'],\n successColor: '#4F8A10',\n errorColor: '#D8000C',\n showCardIcon: false,\n placeholder: cardNumberplaceholder + ' *',\n validations: ['required', 'validCardNumber'],\n css,\n })\n );\n\n const [nameOnCard, setNameOnCard] = useState(\n new VGSInputMapper('card-name', 'text', useRef(null), {\n placeholder: nameOnCardplaceholder + ' *',\n validations: ['required'],\n css,\n })\n );\n\n const [expirationDate, setExpirationDate] = useState(\n new VGSInputMapper('expiration-date', 'card-expiration-date', useRef(null), {\n placeholder: cardExpiryplaceholder + ' *',\n validations: ['required', 'validCardExpirationDate'],\n css,\n })\n );\n\n const [securityCode, setSecurityCode] = useState(\n new VGSInputMapper('security-code', 'card-security-code', useRef(null), {\n placeholder: securityCodeplaceholder + ' *',\n validations: ['required', 'validCardSecurityCode'],\n css,\n })\n );\n\n const vgsInputsAndSetters: any = [\n [cardNumber, setCardNumber],\n [nameOnCard, setNameOnCard],\n [expirationDate, setExpirationDate],\n [securityCode, setSecurityCode],\n ];\n\n const inputNames = ['credit-card', 'card-name', 'expiration-date', 'security-code'];\n\n const [selectedCard, setSelectedCard] = useState(String);\n\n const cardTypes = (hotel?.paymentCardTypes ?? [])\n .map((card: string) => {\n const mapping = SynxisToVGSCardNameMapping[card];\n if (!mapping) {\n return null;\n }\n\n return {\n name: SynxisToVGSCardNameMapping[card],\n status: false,\n };\n })\n .filter((obj) => obj);\n\n useEffect(() => {\n let cancelled = false;\n\n RoomstayThemeEngine.loadScript('https://js.verygoodvault.com/vgs-collect/1/AC7dReJwJ6EWF1L9FHdcCw7n.js', 'vgs-collect').then(() => {\n if (!cancelled) {\n setVgsLoaded(true);\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, []);\n\n useEffect(() => {\n if (vgsLoaded) {\n setVGSForm(\n window.VGSCollect.create(hotel?.vgsVaultName, (state: any) => {\n DataLayer.instance.sendInteraction('Payment Info', InteractionType.FORM_FIELD, InteractionStep.GUEST_DETAILS);\n\n window.VGSCollect.enteredCardType = state['credit-card']?.cardType;\n\n setSelectedCard(state['credit-card']?.cardType);\n\n vgsInputsAndSetters.forEach((getNSet: any) => {\n const old = { ...getNSet[0] };\n const clone = getNSet[0];\n\n const vgsState = state[getNSet[0].name];\n\n if (vgsState) {\n clone.isFocused = vgsState.isFocused;\n\n clone.isValid = !vgsState.isEmpty ? vgsState.isValid : null;\n }\n\n getNSet[1]({ ...clone });\n });\n })\n );\n }\n }, [vgsLoaded]);\n\n useEffect(() => {\n if (VGSForm) {\n vgsInputsAndSetters.forEach((getNSet: any) => {\n const mapper = getNSet[0];\n\n VGSForm.field(mapper.ref.current, getVGSInputProps(mapper));\n });\n }\n }, [VGSForm]);\n\n if (vgsLoaded) {\n return (\n <>\n {inputNames.map((name) => {\n const errorMessage = errors[name];\n return (\n <AutoAutoHeight open={!!errorMessage} key={name}>\n <div className=\"u-flex\">\n <Alert type={AlertType.Danger} icon={IconType.Error}>\n <Text type={TextType.Small}>{errorMessage}</Text>\n </Alert>\n </div>\n </AutoAutoHeight>\n );\n })}\n <div className=\"u-flex flex-row justify-content-start u-marg-bottom\">\n {Object.keys(cardTypes).map((cardKey: any) => {\n return (\n <div\n key={cardKey}\n id={cardTypes[cardKey].name}\n className={\n 'cc-icon u-flex u-marg-right--light' + (selectedCard !== null ? (cardTypes[cardKey].name === selectedCard ? ' -current' : '') : ' -default')\n }\n style={{ backgroundImage: `url('${RoomstayThemeEngine.getAssetUrl() + 'assets/img/' + cardTypes[cardKey].name + '.png'}')` }}\n />\n );\n })}\n </div>\n <form ref={formRef}>\n <InputGroup dimensions=\"2/2\">\n <div className={getClassesFormInput(cardNumber)} ref={cardNumber.ref} />\n <InputGroup dimensions=\"2/2\">\n <div className={getClassesFormInput(expirationDate)} ref={expirationDate.ref} />\n <div className={getClassesFormInput(securityCode)} ref={securityCode.ref} />\n </InputGroup>\n </InputGroup>\n <InputGroup dimensions=\"1\">\n <div className={getClassesFormInput(nameOnCard)} ref={nameOnCard.ref} />\n </InputGroup>\n </form>\n </>\n );\n } else {\n return <LargeLoader />;\n }\n}\n\nexport default forwardRef(StepConfirmationPaymentDetails);\n"]}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type * as dayjs from 'dayjs';
|
|
2
|
-
import type { Addon } from 'models/Addon/Addon';
|
|
3
|
-
import type ReservationsDTO from 'models/Api/ReservationsDTO';
|
|
4
|
-
import type BasketAddonRow from 'models/BasketAddonRow';
|
|
5
|
-
import type BasketRow from 'models/BasketRow';
|
|
6
|
-
import type { RoomRate } from 'models/Room/RoomRate';
|
|
7
|
-
export interface BasketContextType {
|
|
8
|
-
selectedBasketRow: BasketRow;
|
|
9
|
-
currentBasketRows: BasketRow[];
|
|
10
|
-
basketAddonRows: BasketAddonRow[];
|
|
11
|
-
startDate: dayjs.Dayjs;
|
|
12
|
-
endDate: dayjs.Dayjs;
|
|
13
|
-
addBasketRow: (row: BasketRow, selectThisRate?: boolean, neverSelectThisRate?: boolean) => void;
|
|
14
|
-
addRate: (rate: RoomRate, notify?: boolean) => Promise<void>;
|
|
15
|
-
getAllValidRows: () => BasketRow[];
|
|
16
|
-
getAllDatelessRows: () => BasketRow[];
|
|
17
|
-
getNumberOfAdults: (withTranslation: boolean) => number | string;
|
|
18
|
-
getNumberOfChildren: (withTranslation: boolean) => number | string;
|
|
19
|
-
getNumberOfRooms: (withTranslation: boolean) => number | string;
|
|
20
|
-
getTotalPrice: () => any;
|
|
21
|
-
updateBasketRow: (row: BasketRow, updateGlobalDates?: boolean) => void;
|
|
22
|
-
removeBasketRow: (row: BasketRow) => void;
|
|
23
|
-
clearBasketRows: (confirm: boolean) => void;
|
|
24
|
-
selectBasketRow: (row: BasketRow) => void;
|
|
25
|
-
setStartDate: (date: dayjs.Dayjs) => void;
|
|
26
|
-
setEndDate: (date: dayjs.Dayjs) => void;
|
|
27
|
-
hasCheckedOut: boolean;
|
|
28
|
-
reservationData: ReservationsDTO;
|
|
29
|
-
booked: (data: ReservationsDTO) => void;
|
|
30
|
-
rollback: () => void;
|
|
31
|
-
checkedOut: (data: ReservationsDTO) => void;
|
|
32
|
-
clearSelectedRates: () => void;
|
|
33
|
-
getRowForAddon: (selectedAddon: Addon) => BasketAddonRow;
|
|
34
|
-
setAddonQuantities: (addon: Addon, quantities: {
|
|
35
|
-
quantity: number;
|
|
36
|
-
adult: number;
|
|
37
|
-
child: number;
|
|
38
|
-
}, selectedDate: string, selectedTime: string) => void;
|
|
39
|
-
removeBasketAddonRow: (row: BasketAddonRow) => void;
|
|
40
|
-
attemptSelectUnfilledRow: () => BasketRow | null;
|
|
41
|
-
}
|