@cleartrip/ct-platform-login-form 1.3.2-beta.9 → 1.3.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.
|
@@ -1,545 +1,2 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var tslib = require('tslib');
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
var react = require('react');
|
|
6
|
-
var ctPlatformUtils = require('@cleartrip/ct-platform-utils');
|
|
7
|
-
var ctDesignToast = require('@cleartrip/ct-design-toast');
|
|
8
|
-
var ctPlatformConstants = require('@cleartrip/ct-platform-constants');
|
|
9
|
-
var ctDesignField = require('@cleartrip/ct-design-field');
|
|
10
|
-
var ctDesignSpacer = require('@cleartrip/ct-design-spacer');
|
|
11
|
-
var ctDesignSpinner = require('@cleartrip/ct-design-spinner');
|
|
12
|
-
var ctDesignTypography = require('@cleartrip/ct-design-typography');
|
|
13
|
-
var ctDesignAlertCallout = require('@cleartrip/ct-design-alert-callout');
|
|
14
|
-
var ctDesignIcons = require('@cleartrip/ct-design-icons');
|
|
15
|
-
var classNames = require('classnames');
|
|
16
|
-
var ctDesignButton = require('@cleartrip/ct-design-button');
|
|
17
|
-
var ctDesignDivider = require('@cleartrip/ct-design-divider');
|
|
18
|
-
var ctPlatformAssets = require('@cleartrip/ct-platform-assets');
|
|
19
|
-
|
|
20
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
-
|
|
22
|
-
var classNames__default = /*#__PURE__*/_interopDefault(classNames);
|
|
23
|
-
|
|
24
|
-
function styleInject(css, ref) {
|
|
25
|
-
if (ref === void 0) ref = {};
|
|
26
|
-
var insertAt = ref.insertAt;
|
|
27
|
-
if (!css || typeof document === 'undefined') {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
31
|
-
var style = document.createElement('style');
|
|
32
|
-
style.type = 'text/css';
|
|
33
|
-
if (insertAt === 'top') {
|
|
34
|
-
if (head.firstChild) {
|
|
35
|
-
head.insertBefore(style, head.firstChild);
|
|
36
|
-
} else {
|
|
37
|
-
head.appendChild(style);
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
head.appendChild(style);
|
|
41
|
-
}
|
|
42
|
-
if (style.styleSheet) {
|
|
43
|
-
style.styleSheet.cssText = css;
|
|
44
|
-
} else {
|
|
45
|
-
style.appendChild(document.createTextNode(css));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
var css_248z$2 = ".index-module_mobileinput_seperatortext__-KDOp{background:#fff;left:0;margin:0 auto;position:absolute;right:0;text-align:center;top:-10px;width:40px}.index-module_footer_text__nkeJv{color:grey!important;font-size:12px!important}.index-module_otp_container__1CE4N{display:flex;flex-direction:column;margin-top:24px}.index-module_otp_box_wrapper__sM2Ba{margin-right:8px}.index-module_login_otp_input__L-3P8{font-size:24px!important;font-style:normal;font-weight:600!important;height:56px!important;line-height:28px;padding:auto;text-align:center;width:56px!important}.index-module_login_otp_error__o3y2L{padding-top:4px}.index-module_nonUtilsSelector_toast__lvWmB{bottom:12px!important;margin-bottom:12px;margin:0 auto!important;padding:12px 16px!important;width:calc(100% - 48px)!important;z-index:2000}";
|
|
50
|
-
var styles = {"mobileinput_seperatortext":"index-module_mobileinput_seperatortext__-KDOp","footer_text":"index-module_footer_text__nkeJv","otp_container":"index-module_otp_container__1CE4N","otp_box_wrapper":"index-module_otp_box_wrapper__sM2Ba","login_otp_input":"index-module_login_otp_input__L-3P8","login_otp_error":"index-module_login_otp_error__o3y2L","nonUtilsSelector_toast":"index-module_nonUtilsSelector_toast__lvWmB"};
|
|
51
|
-
styleInject(css_248z$2);
|
|
52
|
-
|
|
53
|
-
var css_248z$1 = ".index-module_loader__container__VX-VO{align-items:center;background:#fff;border-radius:32px;box-shadow:0 8px 24px 0 rgba(26,26,26,.1);display:flex;height:34px;justify-content:center;left:50%;padding:12px;position:absolute;top:50%;transform:translate(-50%,-50%);width:66px}.index-module_loader__container__VX-VO .index-module_three-dots-loader__i7R-R{animation:index-module_three-dots-loader__i7R-R 1s linear infinite alternate;animation-delay:.5s;background-color:#1a1a1a;border-radius:5px;height:8px;position:relative;width:8px}.index-module_loader__container__VX-VO .index-module_three-dots-loader__i7R-R:after,.index-module_loader__container__VX-VO .index-module_three-dots-loader__i7R-R:before{content:\"\";display:inline-block;position:absolute;top:0}.index-module_loader__container__VX-VO .index-module_three-dots-loader__i7R-R:before{animation:index-module_three-dots-loader__i7R-R 1s infinite alternate;animation-delay:0s;background-color:#1a1a1a;border-radius:5px;height:8px;left:-15px;width:8px}.index-module_loader__container__VX-VO .index-module_three-dots-loader__i7R-R:after{animation:index-module_three-dots-loader__i7R-R 1s infinite alternate;animation-delay:1s;background-color:#1a1a1a;border-radius:5px;height:8px;left:15px;width:8px}@keyframes index-module_three-dots-loader__i7R-R{0%{background-color:#1a1a1a}50%,to{background-color:grey}}";
|
|
54
|
-
var Styles$1 = {"loader__container":"index-module_loader__container__VX-VO","three-dots-loader":"index-module_three-dots-loader__i7R-R"};
|
|
55
|
-
styleInject(css_248z$1);
|
|
56
|
-
|
|
57
|
-
var ThreeDotsLoader = function () {
|
|
58
|
-
return (jsxRuntime.jsx("div", tslib.__assign({ className: Styles$1['loader__container'] }, { children: jsxRuntime.jsx("div", { className: Styles$1['three-dots-loader'] }) })));
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
var AutoDetectState;
|
|
62
|
-
(function (AutoDetectState) {
|
|
63
|
-
AutoDetectState[AutoDetectState["DETECTING"] = 0] = "DETECTING";
|
|
64
|
-
AutoDetectState[AutoDetectState["FAILED"] = 1] = "FAILED";
|
|
65
|
-
AutoDetectState[AutoDetectState["DETECTED"] = 2] = "DETECTED";
|
|
66
|
-
})(AutoDetectState || (AutoDetectState = {}));
|
|
67
|
-
var OtpInput = function (_a) {
|
|
68
|
-
var mobileNumber = _a.mobileNumber, errorCallout = _a.errorCallout, ravenPayload = _a.ravenPayload, otpInputHeight = _a.otpInputHeight, skipProfileFlow = _a.skipProfileFlow, otpResendDisabled = _a.otpResendDisabled, hotelsLoyaltyFlow = _a.hotelsLoyaltyFlow, getOTP = _a.getOTP, setCtaDisabled = _a.setCtaDisabled, setErrorCallout = _a.setErrorCallout, setMobileNumber = _a.setMobileNumber, setShowMobilePage = _a.setShowMobilePage, handleLoginSuccess = _a.handleLoginSuccess, handleLoginFailure = _a.handleLoginFailure;
|
|
69
|
-
var inputRefs = react.useRef(Array(4).fill(null));
|
|
70
|
-
var _b = react.useState(AutoDetectState.DETECTING), autoDetecting = _b[0], setAutoDetecting = _b[1];
|
|
71
|
-
var _c = react.useState(ctPlatformConstants.LOGIN_CONSTANTS.OTP_COUNTDOWN), countdown = _c[0], setCountdown = _c[1];
|
|
72
|
-
var _d = react.useState(''), otp = _d[0], setOtp = _d[1];
|
|
73
|
-
var _f = react.useState(true), countdownEnabled = _f[0], setCountdownEnabled = _f[1];
|
|
74
|
-
var _g = react.useState(false), verifiedOtp = _g[0], setVerifiedOtp = _g[1];
|
|
75
|
-
var _h = react.useState(''), otpErrorMessage = _h[0], setOtpErrorMessage = _h[1];
|
|
76
|
-
var _j = react.useState(true), enableAutoDetect = _j[0], setEnableAutoDetect = _j[1];
|
|
77
|
-
var _k = react.useState(false), showOtpVerificationLoader = _k[0], setShowOtpVerificationLoader = _k[1];
|
|
78
|
-
var lastOtpRequest = react.useRef();
|
|
79
|
-
var lastOtpRequestTimeStamp = react.useRef();
|
|
80
|
-
var loginMethod = 'CT';
|
|
81
|
-
react.useEffect(function () {
|
|
82
|
-
autoDetect();
|
|
83
|
-
var eventProps = ctPlatformUtils.getRavenEventProps();
|
|
84
|
-
ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'login_otp_screen_opened', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
|
|
85
|
-
}, []);
|
|
86
|
-
react.useEffect(function () {
|
|
87
|
-
if (ctPlatformUtils.isIOSApp()) {
|
|
88
|
-
setEnableAutoDetect(false);
|
|
89
|
-
}
|
|
90
|
-
}, []);
|
|
91
|
-
react.useEffect(function () {
|
|
92
|
-
autoDetect();
|
|
93
|
-
}, []);
|
|
94
|
-
react.useEffect(function () {
|
|
95
|
-
if (!showOtpVerificationLoader) {
|
|
96
|
-
inputRefs.current[0].focus();
|
|
97
|
-
inputRefs.current[0].click();
|
|
98
|
-
}
|
|
99
|
-
}, [showOtpVerificationLoader]);
|
|
100
|
-
react.useEffect(function () {
|
|
101
|
-
if (countdown === 0) {
|
|
102
|
-
setCountdownEnabled(false);
|
|
103
|
-
}
|
|
104
|
-
}, [countdown]);
|
|
105
|
-
react.useEffect(function () {
|
|
106
|
-
var interval;
|
|
107
|
-
if (countdownEnabled && countdown > 0) {
|
|
108
|
-
interval = setInterval(function () {
|
|
109
|
-
setCountdown(function (prevCountdown) { return prevCountdown - 1; });
|
|
110
|
-
}, 1000);
|
|
111
|
-
}
|
|
112
|
-
return function () {
|
|
113
|
-
clearInterval(interval);
|
|
114
|
-
};
|
|
115
|
-
}, [countdownEnabled, countdown]);
|
|
116
|
-
var autoDetect = react.useCallback(function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
117
|
-
var otp_1, _e_1;
|
|
118
|
-
return tslib.__generator(this, function (_a) {
|
|
119
|
-
switch (_a.label) {
|
|
120
|
-
case 0:
|
|
121
|
-
_a.trys.push([0, 2, , 3]);
|
|
122
|
-
return [4, ctPlatformUtils.autoReadOtp()];
|
|
123
|
-
case 1:
|
|
124
|
-
otp_1 = _a.sent();
|
|
125
|
-
setOtp(otp_1);
|
|
126
|
-
setAutoDetecting(AutoDetectState.DETECTED);
|
|
127
|
-
if ((otp_1 === null || otp_1 === void 0 ? void 0 : otp_1.length) === ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH &&
|
|
128
|
-
handleOtpComplete) {
|
|
129
|
-
handleOtpComplete(otp_1, true);
|
|
130
|
-
}
|
|
131
|
-
return [3, 3];
|
|
132
|
-
case 2:
|
|
133
|
-
_e_1 = _a.sent();
|
|
134
|
-
if (_e_1 === 'NOT_SUPPORTED') {
|
|
135
|
-
setEnableAutoDetect(false);
|
|
136
|
-
}
|
|
137
|
-
return [3, 3];
|
|
138
|
-
case 3: return [2];
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}); }, [enableAutoDetect]);
|
|
142
|
-
var handleOtpValidationError = react.useCallback(function (e) {
|
|
143
|
-
var eventProps = ctPlatformUtils.getRavenEventProps();
|
|
144
|
-
ctPlatformUtils.ravenSDKTrigger('u_login_error', tslib.__assign({ action_name: 'otp_incorrect', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
|
|
145
|
-
var message = e === null || e === void 0 ? void 0 : e.message;
|
|
146
|
-
if (message !== 'OTP_VALIDATE_LIMIT_EXCEEDED') {
|
|
147
|
-
setOtp('');
|
|
148
|
-
}
|
|
149
|
-
inputRefs.current[0].focus();
|
|
150
|
-
inputRefs.current[0].click();
|
|
151
|
-
var messageValue = ctPlatformConstants.LOGIN_CONSTANTS[message];
|
|
152
|
-
var toastMessage = typeof messageValue === 'string'
|
|
153
|
-
? messageValue
|
|
154
|
-
: ctPlatformConstants.LOGIN_CONSTANTS.INVALID_OTP;
|
|
155
|
-
setOtpErrorMessage(toastMessage);
|
|
156
|
-
}, [inputRefs]);
|
|
157
|
-
var handleOtpComplete = react.useCallback(function (otp, autodetected) { return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
158
|
-
var eventProps, response, status_1, action, e_1;
|
|
159
|
-
return tslib.__generator(this, function (_a) {
|
|
160
|
-
switch (_a.label) {
|
|
161
|
-
case 0:
|
|
162
|
-
_a.trys.push([0, 2, , 3]);
|
|
163
|
-
eventProps = ctPlatformUtils.getRavenEventProps();
|
|
164
|
-
ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'otp_entered', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', entry_type: !autodetected ? 'manual_entry' : 'autodetected', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
|
|
165
|
-
if (otp === lastOtpRequest.current &&
|
|
166
|
-
lastOtpRequestTimeStamp.current &&
|
|
167
|
-
lastOtpRequestTimeStamp.current - Date.now() <= 100) {
|
|
168
|
-
return [2];
|
|
169
|
-
}
|
|
170
|
-
lastOtpRequest.current = otp;
|
|
171
|
-
lastOtpRequestTimeStamp.current = Date.now();
|
|
172
|
-
if (hotelsLoyaltyFlow) {
|
|
173
|
-
setShowOtpVerificationLoader(true);
|
|
174
|
-
}
|
|
175
|
-
return [4, ctPlatformUtils.validateOtp(mobileNumber, otp)];
|
|
176
|
-
case 1:
|
|
177
|
-
response = _a.sent();
|
|
178
|
-
status_1 = response.status, action = response.action;
|
|
179
|
-
if (Number(status_1) === 200 && !ctPlatformUtils.isEmpty(action)) {
|
|
180
|
-
setVerifiedOtp(true);
|
|
181
|
-
setOtpErrorMessage('');
|
|
182
|
-
ctPlatformUtils.updateNativeOnLogin();
|
|
183
|
-
if (action === 'SIGNUP') {
|
|
184
|
-
if (!skipProfileFlow) {
|
|
185
|
-
window.location.href =
|
|
186
|
-
ctPlatformConstants.NAVIGATION_ROUTES.PERSONAL_DETAILS +
|
|
187
|
-
'?onboardingFlow=true';
|
|
188
|
-
}
|
|
189
|
-
handleLoginSuccess(loginMethod, true);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
handleLoginSuccess(loginMethod);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
if (hotelsLoyaltyFlow) {
|
|
197
|
-
setShowOtpVerificationLoader(false);
|
|
198
|
-
}
|
|
199
|
-
handleLoginFailure(loginMethod);
|
|
200
|
-
}
|
|
201
|
-
return [3, 3];
|
|
202
|
-
case 2:
|
|
203
|
-
e_1 = _a.sent();
|
|
204
|
-
if (hotelsLoyaltyFlow) {
|
|
205
|
-
setShowOtpVerificationLoader(false);
|
|
206
|
-
}
|
|
207
|
-
handleLoginFailure(loginMethod);
|
|
208
|
-
handleOtpValidationError(e_1);
|
|
209
|
-
return [3, 3];
|
|
210
|
-
case 3: return [2];
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}); }, [
|
|
214
|
-
lastOtpRequest,
|
|
215
|
-
lastOtpRequestTimeStamp,
|
|
216
|
-
setVerifiedOtp,
|
|
217
|
-
setAutoDetecting,
|
|
218
|
-
setOtpErrorMessage,
|
|
219
|
-
handleOtpValidationError,
|
|
220
|
-
]);
|
|
221
|
-
var handleOnPaste = function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
222
|
-
var clipboardData, pastedArr, pastedString;
|
|
223
|
-
var _a, _b;
|
|
224
|
-
return tslib.__generator(this, function (_c) {
|
|
225
|
-
switch (_c.label) {
|
|
226
|
-
case 0: return [4, navigator.clipboard.readText()];
|
|
227
|
-
case 1:
|
|
228
|
-
clipboardData = _c.sent();
|
|
229
|
-
if (clipboardData && ctPlatformUtils.isNumeric(clipboardData)) {
|
|
230
|
-
pastedArr = clipboardData
|
|
231
|
-
.slice(0, ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH)
|
|
232
|
-
.split('');
|
|
233
|
-
(_a = inputRefs.current[ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH - 1]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
234
|
-
(_b = inputRefs.current[ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH - 1]) === null || _b === void 0 ? void 0 : _b.click();
|
|
235
|
-
pastedString = pastedArr.join('');
|
|
236
|
-
setOtp(pastedString);
|
|
237
|
-
if (pastedString.length === ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH) {
|
|
238
|
-
handleOtpComplete(pastedString, false);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return [2];
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
}); };
|
|
245
|
-
var handleInput = react.useCallback(function (event, index) {
|
|
246
|
-
var _a, _b;
|
|
247
|
-
setErrorCallout('');
|
|
248
|
-
var value = event.target.value;
|
|
249
|
-
if (value !== '' && index < inputRefs.current.length - 1) {
|
|
250
|
-
(_a = inputRefs.current[index + 1]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
251
|
-
(_b = inputRefs.current[index + 1]) === null || _b === void 0 ? void 0 : _b.click();
|
|
252
|
-
}
|
|
253
|
-
var inputValues = inputRefs.current.map(function (ref) {
|
|
254
|
-
if (ctPlatformUtils.isHTMLInputElement(ref)) {
|
|
255
|
-
return ref.value;
|
|
256
|
-
}
|
|
257
|
-
return '';
|
|
258
|
-
});
|
|
259
|
-
var otpValue = inputValues.join('').slice(0, 4);
|
|
260
|
-
setOtp(otpValue);
|
|
261
|
-
if (otpValue.length === ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH) {
|
|
262
|
-
handleOtpComplete(otpValue, false);
|
|
263
|
-
}
|
|
264
|
-
}, [setOtp, handleOtpComplete]);
|
|
265
|
-
var handleKeyDown = react.useCallback(function (e, index) {
|
|
266
|
-
var _a, _b, _c;
|
|
267
|
-
if (e.key === 'Backspace' &&
|
|
268
|
-
index > 0 &&
|
|
269
|
-
((_a = inputRefs.current[index]) === null || _a === void 0 ? void 0 : _a.value) === '') {
|
|
270
|
-
e.preventDefault();
|
|
271
|
-
(_b = inputRefs.current[index - 1]) === null || _b === void 0 ? void 0 : _b.focus();
|
|
272
|
-
(_c = inputRefs.current[index - 1]) === null || _c === void 0 ? void 0 : _c.click();
|
|
273
|
-
}
|
|
274
|
-
}, [inputRefs]);
|
|
275
|
-
var onResendOtpClick = react.useCallback(function () {
|
|
276
|
-
setCountdown(ctPlatformConstants.LOGIN_CONSTANTS.OTP_COUNTDOWN);
|
|
277
|
-
setCountdownEnabled(true);
|
|
278
|
-
getOTP(mobileNumber);
|
|
279
|
-
var eventProps = ctPlatformUtils.getRavenEventProps();
|
|
280
|
-
ctPlatformUtils.ravenSDKTrigger('u_login_error', tslib.__assign({ action_name: 'resend_otp_clicked', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
|
|
281
|
-
}, [setCountdown, setCountdownEnabled]);
|
|
282
|
-
var onEditCLick = react.useCallback(function () {
|
|
283
|
-
setCtaDisabled(true);
|
|
284
|
-
setShowMobilePage(true);
|
|
285
|
-
setMobileNumber('');
|
|
286
|
-
}, [setShowMobilePage]);
|
|
287
|
-
return (jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-column bg-neutral-100', style: { height: otpInputHeight } }, { children: [errorCallout && (jsxRuntime.jsx(ctDesignAlertCallout.AlertCallout, { variant: 'error', textNode: errorCallout, prefixIconNode: jsxRuntime.jsx(ctDesignIcons.InfoIcon, { fill: 'red' }), style: {
|
|
288
|
-
color: '#ffff',
|
|
289
|
-
backgroundColor: '#db201e',
|
|
290
|
-
}, className: 'fs-12' })), jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-bottom' }, { children: [jsxRuntime.jsxs(ctDesignTypography.Typography, tslib.__assign({ variant: 'HM1', color: 'heading' }, { children: [ctPlatformConstants.LOGIN_CONSTANTS.OTP_TEXT, " ", jsxRuntime.jsx("br", {}), mobileNumber] })), jsxRuntime.jsx("div", tslib.__assign({ className: 'pl-2', onClick: onEditCLick }, { children: jsxRuntime.jsx(ctDesignIcons.Edit, {}) }))] })), jsxRuntime.jsxs("div", tslib.__assign({ className: styles.otp_container }, { children: [jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex', style: hotelsLoyaltyFlow
|
|
291
|
-
? { width: 'max-content', position: 'relative' }
|
|
292
|
-
: {} }, { children: [tslib.__spreadArray([], Array(ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH), true).map(function (_, i) { return (jsxRuntime.jsx("div", tslib.__assign({ className: styles.otp_box_wrapper }, { children: jsxRuntime.jsx(ctDesignField.FieldV2, { prompt: {
|
|
293
|
-
hasError: !!otpErrorMessage,
|
|
294
|
-
}, type: 'number', placeholder: '', value: otp[i], max: 1, inputMode: 'numeric', className: styles.login_otp_input, variant: 'md', ref: function (ref) {
|
|
295
|
-
if (ref) {
|
|
296
|
-
inputRefs.current[i] = ref;
|
|
297
|
-
}
|
|
298
|
-
}, onKeyDown: function (e) { return handleKeyDown(e, i); }, onChange: function (e) { return handleInput(e, i); }, onPaste: handleOnPaste, autoFocus: i === 0, disabled: hotelsLoyaltyFlow &&
|
|
299
|
-
showOtpVerificationLoader
|
|
300
|
-
? true
|
|
301
|
-
: false }) }), i)); }), hotelsLoyaltyFlow && showOtpVerificationLoader && (jsxRuntime.jsx(ThreeDotsLoader, {}))] })), !!otpErrorMessage && (jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'P1', color: 'warning', className: styles.login_otp_error }, { children: otpErrorMessage })))] })), jsxRuntime.jsx(ctDesignSpacer.Spacer, { className: 'pt-2' }), autoDetecting === AutoDetectState.DETECTING &&
|
|
302
|
-
!verifiedOtp &&
|
|
303
|
-
enableAutoDetect &&
|
|
304
|
-
countdown >
|
|
305
|
-
ctPlatformConstants.LOGIN_CONSTANTS.RESEND_OTP_COUNTDOWN && (jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-middle' }, { children: [jsxRuntime.jsx(ctDesignSpinner.Spinner, { width: '20px', height: '20px', borderColor: '#11a670', className: 'bg-neutral-900 bc-black' }), jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'B3', className: 'fs-12 fw-500 ml-1 c-neutral-700' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.AUTO_DETECTING_TEXT }))] }))), autoDetecting === AutoDetectState.DETECTING &&
|
|
306
|
-
countdown <= ctPlatformConstants.LOGIN_CONSTANTS.RESEND_OTP_COUNTDOWN &&
|
|
307
|
-
!verifiedOtp && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex' }, { children: [jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'B3', className: 'fs-12 fw-500 c-neutral-700 ' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.OTP_RESEND_TEXT })), jsxRuntime.jsx(ctDesignSpacer.Spacer, { className: 'ml-1' }), otpResendDisabled ? (jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ className: 'color-neutral-200 fw-500', variant: 'B3' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.RESEND_CTA }))) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [countdown === 0 && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ isClickable: true, variant: 'B3', onClick: onResendOtpClick, color: 'link', className: '\n fs-12 fw-500 c-pointer' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.RESEND_CTA })) })), countdown > 0 && (jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ color: 'disabled', variant: 'B3' }, { children: ' Resend (' + countdown + 's)' })))] }))] })) })), !otpErrorMessage && verifiedOtp && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-middle' }, { children: [jsxRuntime.jsx(ctDesignIcons.CheckCircle, {}), jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'P1', color: 'success', className: 'fs-12' }, { children: autoDetecting === AutoDetectState.DETECTED
|
|
308
|
-
? ctPlatformConstants.LOGIN_CONSTANTS.AUTO_DETECTED_TEXT
|
|
309
|
-
: ctPlatformConstants.LOGIN_CONSTANTS.VERIFIED_MESSAGE }))] })) })), jsxRuntime.jsx(ctDesignSpacer.Spacer, { className: 'mt-24' })] })));
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
var css_248z = ".index-module_loader__63LeU{align-items:center;background-color:hsla(0,0%,100%,.95);bottom:0;display:flex;justify-content:center;left:0;position:fixed;right:0;top:0;z-index:0}.index-module_loader__63LeU.index-module_With-full-opacity__ZSY-U{background-color:#fff}.index-module_loader__content__Q6kJl{max-width:280px;text-align:center}.index-module_loader__spinner__6B3AR{animation:index-module_loader-rotate__efcf3 .8s linear infinite;border:2px solid rgba(51,102,204,.3);border-radius:50%;border-top-color:#36c;display:inline-block;height:30px;margin-bottom:10px;position:relative;width:30px}.index-module_loader__heading__7YZ3N{color:#000;font-size:18px;font-weight:600;margin-bottom:5px}.index-module_loader__text__1QcLi{color:rgba(0,0,0,.8);font-size:16px;line-height:1.5}";
|
|
313
|
-
var Styles = {"loader":"index-module_loader__63LeU","With-full-opacity":"index-module_With-full-opacity__ZSY-U","loader__content":"index-module_loader__content__Q6kJl","loader__spinner":"index-module_loader__spinner__6B3AR","loader-rotate":"index-module_loader-rotate__efcf3","loader__heading":"index-module_loader__heading__7YZ3N","loader__text":"index-module_loader__text__1QcLi"};
|
|
314
|
-
styleInject(css_248z);
|
|
315
|
-
|
|
316
|
-
var Loader = function (_a) {
|
|
317
|
-
var title = _a.title, message = _a.message, className = _a.className;
|
|
318
|
-
return (jsxRuntime.jsx("div", tslib.__assign({ className: "".concat(Styles['utilswrapper'], " utilswrapper") }, { children: jsxRuntime.jsx("div", tslib.__assign({ className: classNames__default.default(Styles['loader'], className) }, { children: jsxRuntime.jsxs("div", tslib.__assign({ className: Styles['loader__content'] }, { children: [jsxRuntime.jsx("div", { className: Styles['loader__spinner'] }), jsxRuntime.jsx("h5", tslib.__assign({ className: Styles['loader__heading'] }, { children: title })), jsxRuntime.jsx("p", tslib.__assign({ className: Styles['loader__text'] }, { children: message }))] })) })) })));
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
var MobileInput = function (_a) {
|
|
322
|
-
var sendingOtp = _a.sendingOtp, ctaDisabled = _a.ctaDisabled, getOTP = _a.getOTP, setErrorCallout = _a.setErrorCallout, errorCallout = _a.errorCallout, mobileNumber = _a.mobileNumber, setMobileInputHeight = _a.setMobileInputHeight, setMobileNumber = _a.setMobileNumber, fallbackUri = _a.fallbackUri, skipProfileFlow = _a.skipProfileFlow, ravenPayload = _a.ravenPayload, hotelsLoyaltyFlow = _a.hotelsLoyaltyFlow, _b = _a.isFkLoginEnabled, isFkLoginEnabled = _b === void 0 ? true : _b, _c = _a.isPrivacyPolicyVisible, isPrivacyPolicyVisible = _c === void 0 ? true : _c;
|
|
323
|
-
var fkSSOEnabled = react.useState(ctPlatformUtils.isFKSSOEnabled)[0];
|
|
324
|
-
var _d = react.useState(false), fkButtonLoading = _d[0], setFkButtonLoading = _d[1];
|
|
325
|
-
var inputRef = react.useRef(null);
|
|
326
|
-
var mobileViewRef = react.useRef(null);
|
|
327
|
-
react.useEffect(function () {
|
|
328
|
-
if (mobileViewRef.current) {
|
|
329
|
-
var height = mobileViewRef.current.clientHeight;
|
|
330
|
-
setMobileInputHeight(height);
|
|
331
|
-
}
|
|
332
|
-
}, [mobileViewRef.current]);
|
|
333
|
-
react.useEffect(function () {
|
|
334
|
-
var timeout;
|
|
335
|
-
if (inputRef.current) {
|
|
336
|
-
timeout = setTimeout(function () {
|
|
337
|
-
var _a;
|
|
338
|
-
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
339
|
-
}, 100);
|
|
340
|
-
}
|
|
341
|
-
return function () {
|
|
342
|
-
clearTimeout(timeout);
|
|
343
|
-
};
|
|
344
|
-
}, []);
|
|
345
|
-
react.useEffect(function () {
|
|
346
|
-
if (ctPlatformUtils.isAndroidApp()) {
|
|
347
|
-
autoDetectMobileNumber();
|
|
348
|
-
}
|
|
349
|
-
}, []);
|
|
350
|
-
var handleFKSSOClick = react.useCallback(function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
351
|
-
var eventProps, redirectUrl;
|
|
352
|
-
return tslib.__generator(this, function (_a) {
|
|
353
|
-
switch (_a.label) {
|
|
354
|
-
case 0:
|
|
355
|
-
_a.trys.push([0, 2, , 3]);
|
|
356
|
-
eventProps = ctPlatformUtils.getRavenEventProps();
|
|
357
|
-
ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'login_with_flipkart_clicked', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'fk_sso', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
|
|
358
|
-
setFkButtonLoading(true);
|
|
359
|
-
return [4, ctPlatformUtils.handleFKSSO(fallbackUri, skipProfileFlow)];
|
|
360
|
-
case 1:
|
|
361
|
-
redirectUrl = _a.sent();
|
|
362
|
-
if (!hotelsLoyaltyFlow) {
|
|
363
|
-
setFkButtonLoading(false);
|
|
364
|
-
}
|
|
365
|
-
if (ctPlatformUtils.isPwa()) {
|
|
366
|
-
window.location.href = redirectUrl;
|
|
367
|
-
}
|
|
368
|
-
return [3, 3];
|
|
369
|
-
case 2:
|
|
370
|
-
_a.sent();
|
|
371
|
-
setFkButtonLoading(false);
|
|
372
|
-
return [3, 3];
|
|
373
|
-
case 3: return [2];
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
}); }, []);
|
|
377
|
-
var handleInputChange = react.useCallback(function (event, autoDetected) {
|
|
378
|
-
if (autoDetected === void 0) { autoDetected = false; }
|
|
379
|
-
setErrorCallout('');
|
|
380
|
-
var value = event.target.value || '';
|
|
381
|
-
value = value.replace(ctPlatformUtils.MULTI_SPACE, ' ').trimStart();
|
|
382
|
-
setMobileNumber(value);
|
|
383
|
-
var validMobileNo = ctPlatformUtils.isValidMobileNumber(event.target.value);
|
|
384
|
-
if (validMobileNo) {
|
|
385
|
-
getOTP(value);
|
|
386
|
-
var eventProps = ctPlatformUtils.getRavenEventProps();
|
|
387
|
-
ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'get_otp_clicked', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', entry_type: 'auto_click', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
|
|
388
|
-
if (!autoDetected) {
|
|
389
|
-
ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'phone_number_entered', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', entry_type: 'manual_entry', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
392
|
-
ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'phone_number_autodetected', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', entry_type: 'autodetected', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}, [setMobileNumber]);
|
|
396
|
-
var autoDetectMobileNumber = react.useCallback(function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
397
|
-
var autoDetectedNumber, simulatedEvent;
|
|
398
|
-
return tslib.__generator(this, function (_a) {
|
|
399
|
-
switch (_a.label) {
|
|
400
|
-
case 0: return [4, ctPlatformUtils.showMobileNumberHint()];
|
|
401
|
-
case 1:
|
|
402
|
-
autoDetectedNumber = _a.sent();
|
|
403
|
-
simulatedEvent = {
|
|
404
|
-
target: {
|
|
405
|
-
value: autoDetectedNumber,
|
|
406
|
-
},
|
|
407
|
-
};
|
|
408
|
-
if (autoDetectedNumber) {
|
|
409
|
-
handleInputChange(simulatedEvent, true);
|
|
410
|
-
}
|
|
411
|
-
return [2];
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
}); }, [handleInputChange]);
|
|
415
|
-
var handlePrivacyPolicyClick = react.useCallback(function () {
|
|
416
|
-
var eventProps = ctPlatformUtils.getRavenEventProps();
|
|
417
|
-
ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'policy_click', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
|
|
418
|
-
window.location.href = ctPlatformConstants.NAVIGATION_ROUTES.PRIVACY_POLICY;
|
|
419
|
-
}, []);
|
|
420
|
-
var handleTermsOfUseClick = react.useCallback(function () {
|
|
421
|
-
var eventProps = ctPlatformUtils.getRavenEventProps();
|
|
422
|
-
ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'tnc_click', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
|
|
423
|
-
window.location.href = ctPlatformConstants.NAVIGATION_ROUTES.TERMS;
|
|
424
|
-
}, []);
|
|
425
|
-
return (jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-column', ref: mobileViewRef }, { children: [errorCallout && (jsxRuntime.jsx(ctDesignAlertCallout.AlertCallout, { variant: 'error', textNode: errorCallout, prefixIconNode: jsxRuntime.jsx(ctDesignIcons.InfoIcon, { fill: 'red' }), style: {
|
|
426
|
-
color: '#ffff',
|
|
427
|
-
backgroundColor: '#db201e',
|
|
428
|
-
}, className: 'fs-12' })), jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'HM1', color: 'heading', className: 'mb-4 fs-24' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.LOGIN_TO_CT })), jsxRuntime.jsx("label", tslib.__assign({ style: {
|
|
429
|
-
visibility: 'hidden',
|
|
430
|
-
width: '0.1px',
|
|
431
|
-
height: '0.1px',
|
|
432
|
-
}, htmlFor: 'phonenumber' }, { children: "Phone number" })), jsxRuntime.jsx(ctDesignField.PhoneField, { onChange: handleInputChange, value: mobileNumber, name: 'phonenumber', placeholder: '', inputMode: 'numeric', ref: inputRef, min: 0, max: 10, autoFocus: true, countryCode: ctPlatformConstants.LOGIN_CONSTANTS.COUNTRY_CODE }), jsxRuntime.jsx(ctDesignButton.Button, tslib.__assign({ color: 'primary', size: 'medium', minWidth: '160px', disabled: ctaDisabled, loading: sendingOtp, className: 'my-6', onClick: function () { return getOTP(mobileNumber); } }, { children: ctPlatformConstants.LOGIN_CONSTANTS.GET_OTP })), fkSSOEnabled && isFkLoginEnabled && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", tslib.__assign({ className: 'my-6 p-relative' }, { children: [jsxRuntime.jsx(ctDesignDivider.Divider, {}), jsxRuntime.jsx("span", tslib.__assign({ className: "".concat(styles.mobileinput_seperatortext) }, { children: "or" }))] })), jsxRuntime.jsx(ctDesignButton.Button, tslib.__assign({ variant: 'outline', size: 'medium', className: 'my-6', loading: fkButtonLoading, onClick: handleFKSSOClick, showLeftIcon: !fkButtonLoading, LeftIcon: jsxRuntime.jsx("img", { src: ctPlatformAssets.FlipkartLogo }) }, { children: ctPlatformConstants.LOGIN_CONSTANTS.FK_LOGIN_CTA }))] })), isPrivacyPolicyVisible && (jsxRuntime.jsxs("div", tslib.__assign({ className: 'pt-8 pb-6' }, { children: [jsxRuntime.jsx(ctDesignDivider.Divider, {}), jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-middle \n flex-center flex-wrap pt-2' }, { children: [jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'P1', className: styles.footer_text }, { children: ctPlatformConstants.LOGIN_CONSTANTS.FOOTER_TEXT })), jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'P1', color: 'link', className: 'pl-1 fs-12', isClickable: true, onClick: handlePrivacyPolicyClick }, { children: ctPlatformConstants.LOGIN_CONSTANTS.PRIVACY_CTA })), jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ className: 'px-1 fs-12 c-neutral-700', variant: 'P1' }, { children: '& ' })), jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'P1', color: 'link', isClickable: true, onClick: handleTermsOfUseClick, className: 'fs-12' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.TNC_CTA }))] }))] })))] })));
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
var LoginForm = function (_a) {
|
|
436
|
-
var fallbackUri = _a.fallbackUri, isLoginModule = _a.isLoginModule, skipProfileFlow = _a.skipProfileFlow, sendUserInsights = _a.sendUserInsights, isFkLoginEnabled = _a.isFkLoginEnabled, _b = _a.ravenPayload, ravenPayload = _b === void 0 ? {} : _b, hotelsLoyaltyFlow = _a.hotelsLoyaltyFlow, enableProfileFetch = _a.enableProfileFetch, isPrivacyPolicyVisible = _a.isPrivacyPolicyVisible, onAuthSuccess = _a.onAuthSuccess, onAuthFailure = _a.onAuthFailure;
|
|
437
|
-
var _c = react.useState(true), showMobilePage = _c[0], setShowMobilePage = _c[1];
|
|
438
|
-
var _d = react.useState(true), ctaDisabled = _d[0], setCtaDisabled = _d[1];
|
|
439
|
-
var _e = react.useState(false), sendingOtp = _e[0], setSendingOtp = _e[1];
|
|
440
|
-
var _f = react.useState(''), mobileNumber = _f[0], setMobileNumber = _f[1];
|
|
441
|
-
var _g = react.useState(0), mobileInputHeight = _g[0], setMobileInputHeight = _g[1];
|
|
442
|
-
var _h = react.useState(''), errorCallout = _h[0], setErrorCallout = _h[1];
|
|
443
|
-
var _j = react.useState(false), otpResendDisabled = _j[0], setOtpResendDisabled = _j[1];
|
|
444
|
-
var _k = react.useState(false), showSuccess = _k[0], setShowSuccess = _k[1];
|
|
445
|
-
var _l = react.useState(false), showSigninLoader = _l[0], setShowSigninLoader = _l[1];
|
|
446
|
-
var getOTP = react.useCallback(function (mobileNumber) { return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
447
|
-
var res, status_1, err_1, message, errorMessage;
|
|
448
|
-
return tslib.__generator(this, function (_a) {
|
|
449
|
-
switch (_a.label) {
|
|
450
|
-
case 0:
|
|
451
|
-
_a.trys.push([0, 2, , 3]);
|
|
452
|
-
setCtaDisabled(false);
|
|
453
|
-
setSendingOtp(true);
|
|
454
|
-
ctPlatformUtils.triggerOTPListener();
|
|
455
|
-
return [4, ctPlatformUtils.sendLoginOtp(mobileNumber)];
|
|
456
|
-
case 1:
|
|
457
|
-
res = _a.sent();
|
|
458
|
-
status_1 = (res || {}).status;
|
|
459
|
-
if (status_1 === 'SUCCESS') {
|
|
460
|
-
setShowMobilePage(false);
|
|
461
|
-
setSendingOtp(false);
|
|
462
|
-
}
|
|
463
|
-
return [3, 3];
|
|
464
|
-
case 2:
|
|
465
|
-
err_1 = _a.sent();
|
|
466
|
-
console.error(err_1);
|
|
467
|
-
message = (err_1 || {}).message;
|
|
468
|
-
setSendingOtp(false);
|
|
469
|
-
errorMessage = message && ctPlatformConstants.LOGIN_CONSTANTS[message];
|
|
470
|
-
if (errorMessage) {
|
|
471
|
-
setErrorCallout(String(errorMessage));
|
|
472
|
-
}
|
|
473
|
-
else {
|
|
474
|
-
setErrorCallout(String(ctPlatformConstants.LOGIN_CONSTANTS.GENERIC_ERROR_MESSAGE));
|
|
475
|
-
}
|
|
476
|
-
if (message === 'OTP_SEND_LIMIT_EXCEEDED') {
|
|
477
|
-
setOtpResendDisabled(true);
|
|
478
|
-
}
|
|
479
|
-
return [3, 3];
|
|
480
|
-
case 3: return [2];
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
}); }, [showMobilePage, setShowMobilePage]);
|
|
484
|
-
var handleLoginSuccess = react.useCallback(function (loginMethod, isSignUp) {
|
|
485
|
-
var eventProps = ctPlatformUtils.getRavenEventProps();
|
|
486
|
-
var payload = tslib.__assign({ action_name: 'login_successful', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', login_new: isSignUp ? 'sign_up' : 'sign_in', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload);
|
|
487
|
-
if (sendUserInsights) {
|
|
488
|
-
ctPlatformUtils.sendEventWithUserInsights('u_login_success', payload);
|
|
489
|
-
}
|
|
490
|
-
else {
|
|
491
|
-
ctPlatformUtils.ravenSDKTrigger('u_login_success', payload);
|
|
492
|
-
}
|
|
493
|
-
if (enableProfileFetch) {
|
|
494
|
-
ctPlatformUtils.handleProfileFetch();
|
|
495
|
-
}
|
|
496
|
-
if (!hotelsLoyaltyFlow &&
|
|
497
|
-
!isLoginModule &&
|
|
498
|
-
(!isSignUp || skipProfileFlow)) {
|
|
499
|
-
setShowSuccess(true);
|
|
500
|
-
}
|
|
501
|
-
onAuthSuccess(isSignUp);
|
|
502
|
-
}, [
|
|
503
|
-
ravenPayload,
|
|
504
|
-
isLoginModule,
|
|
505
|
-
skipProfileFlow,
|
|
506
|
-
sendUserInsights,
|
|
507
|
-
hotelsLoyaltyFlow,
|
|
508
|
-
enableProfileFetch,
|
|
509
|
-
]);
|
|
510
|
-
var handleLoginFailure = react.useCallback(function (loginMethod) {
|
|
511
|
-
onAuthFailure(loginMethod);
|
|
512
|
-
}, []);
|
|
513
|
-
var showSigninLoaderScreen = function () {
|
|
514
|
-
setShowSigninLoader(true);
|
|
515
|
-
};
|
|
516
|
-
react.useEffect(function () {
|
|
517
|
-
if (isLoginModule) {
|
|
518
|
-
return;
|
|
519
|
-
}
|
|
520
|
-
if (window) {
|
|
521
|
-
window['showSigninLoaderScreen'] = showSigninLoaderScreen;
|
|
522
|
-
}
|
|
523
|
-
var queryValue = ctPlatformUtils.getQueryParam('fkSSOstatus');
|
|
524
|
-
var loginMethod = 'FK';
|
|
525
|
-
if (queryValue === 'signin') {
|
|
526
|
-
if (ctPlatformUtils.isAndroidApp()) {
|
|
527
|
-
ctPlatformUtils.updateNativeAndroidOnSignIn();
|
|
528
|
-
}
|
|
529
|
-
handleLoginSuccess(loginMethod);
|
|
530
|
-
}
|
|
531
|
-
if (queryValue === 'signup') {
|
|
532
|
-
if (ctPlatformUtils.isAndroidApp()) {
|
|
533
|
-
ctPlatformUtils.updateNativeAndroidOnSignIn();
|
|
534
|
-
}
|
|
535
|
-
handleLoginSuccess(loginMethod, true);
|
|
536
|
-
}
|
|
537
|
-
if (queryValue === 'failure') {
|
|
538
|
-
handleLoginFailure(loginMethod);
|
|
539
|
-
}
|
|
540
|
-
}, []);
|
|
541
|
-
return (jsxRuntime.jsxs("div", tslib.__assign({ className: "".concat(styles['utilswrapper'], " utilswrapper") }, { children: [showSuccess && (jsxRuntime.jsx(ctDesignToast.Toast, { text: 'Logged in successfully!', show: showSuccess, className: "".concat(styles['nonUtilsSelector_toast']), closeTimeout: 2000 })), showSigninLoader && (jsxRuntime.jsx(Loader, { title: 'Please wait', message: 'Signing in...', className: 'z-10 bg-white' })), showMobilePage ? (jsxRuntime.jsx(MobileInput, { device: 'PWA', ctaDisabled: ctaDisabled, sendingOtp: sendingOtp, getOTP: getOTP, mobileNumber: mobileNumber, setMobileNumber: setMobileNumber, setMobileInputHeight: setMobileInputHeight, fallbackUri: fallbackUri, skipProfileFlow: skipProfileFlow, setErrorCallout: setErrorCallout, errorCallout: errorCallout, ravenPayload: ravenPayload, hotelsLoyaltyFlow: hotelsLoyaltyFlow, isFkLoginEnabled: isFkLoginEnabled, isPrivacyPolicyVisible: isPrivacyPolicyVisible })) : (jsxRuntime.jsx(OtpInput, { mobileNumber: mobileNumber, getOTP: getOTP, setCtaDisabled: setCtaDisabled, setShowMobilePage: setShowMobilePage, handleLoginSuccess: handleLoginSuccess, handleLoginFailure: handleLoginFailure, otpInputHeight: mobileInputHeight, setMobileNumber: setMobileNumber, setErrorCallout: setErrorCallout, errorCallout: errorCallout, otpResendDisabled: otpResendDisabled, ravenPayload: ravenPayload, skipProfileFlow: skipProfileFlow, hotelsLoyaltyFlow: hotelsLoyaltyFlow }))] })));
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
exports.LoginForm = LoginForm;
|
|
1
|
+
"use strict";var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@cleartrip/ct-platform-utils"),a=require("@cleartrip/ct-design-toast"),r=require("@cleartrip/ct-platform-constants"),o=require("@cleartrip/ct-design-field"),l=require("@cleartrip/ct-design-spacer"),s=require("@cleartrip/ct-design-spinner"),_=require("@cleartrip/ct-design-typography"),c=require("@cleartrip/ct-design-alert-callout"),d=require("@cleartrip/ct-design-icons"),u=require("classnames"),g=require("@cleartrip/ct-design-button"),p=require("@cleartrip/ct-design-divider"),m=require("@cleartrip/ct-platform-assets");function v(e){return e&&e.__esModule?e:{default:e}}var f=v(u);function x(e,n){void 0===n&&(n={});var i=n.insertAt;if(e&&"undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===i&&t.firstChild?t.insertBefore(a,t.firstChild):t.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}var N={mobileinput_seperatortext:"index-module_mobileinput_seperatortext__-KDOp",footer_text:"index-module_footer_text__nkeJv",otp_container:"index-module_otp_container__1CE4N",otp_box_wrapper:"index-module_otp_box_wrapper__sM2Ba",login_otp_input:"index-module_login_otp_input__L-3P8",login_otp_error:"index-module_login_otp_error__o3y2L",nonUtilsSelector_toast:"index-module_nonUtilsSelector_toast__lvWmB"};x(".index-module_mobileinput_seperatortext__-KDOp{background:#fff;left:0;margin:0 auto;position:absolute;right:0;text-align:center;top:-10px;width:40px}.index-module_footer_text__nkeJv{color:grey!important;font-size:12px!important}.index-module_otp_container__1CE4N{display:flex;flex-direction:column;margin-top:24px}.index-module_otp_box_wrapper__sM2Ba{margin-right:8px}.index-module_login_otp_input__L-3P8{font-size:24px!important;font-style:normal;font-weight:600!important;height:56px!important;line-height:28px;padding:auto;text-align:center;width:56px!important}.index-module_login_otp_error__o3y2L{padding-top:4px}.index-module_nonUtilsSelector_toast__lvWmB{bottom:12px!important;margin-bottom:12px;margin:0 auto!important;padding:12px 16px!important;width:calc(100% - 48px)!important;z-index:2000}");var h="index-module_loader__container__VX-VO",T="index-module_three-dots-loader__i7R-R";x('.index-module_loader__container__VX-VO{align-items:center;background:#fff;border-radius:32px;box-shadow:0 8px 24px 0 rgba(26,26,26,.1);display:flex;height:34px;justify-content:center;left:50%;padding:12px;position:absolute;top:50%;transform:translate(-50%,-50%);width:66px}.index-module_loader__container__VX-VO .index-module_three-dots-loader__i7R-R{animation:index-module_three-dots-loader__i7R-R 1s linear infinite alternate;animation-delay:.5s;background-color:#1a1a1a;border-radius:5px;height:8px;position:relative;width:8px}.index-module_loader__container__VX-VO .index-module_three-dots-loader__i7R-R:after,.index-module_loader__container__VX-VO .index-module_three-dots-loader__i7R-R:before{content:"";display:inline-block;position:absolute;top:0}.index-module_loader__container__VX-VO .index-module_three-dots-loader__i7R-R:before{animation:index-module_three-dots-loader__i7R-R 1s infinite alternate;animation-delay:0s;background-color:#1a1a1a;border-radius:5px;height:8px;left:-15px;width:8px}.index-module_loader__container__VX-VO .index-module_three-dots-loader__i7R-R:after{animation:index-module_three-dots-loader__i7R-R 1s infinite alternate;animation-delay:1s;background-color:#1a1a1a;border-radius:5px;height:8px;left:15px;width:8px}@keyframes index-module_three-dots-loader__i7R-R{0%{background-color:#1a1a1a}50%,to{background-color:grey}}');var S,b=function(){return n.jsx("div",e.__assign({className:h},{children:n.jsx("div",{className:T})}))};!function(e){e[e.DETECTING=0]="DETECTING",e[e.FAILED=1]="FAILED",e[e.DETECTED=2]="DETECTED"}(S||(S={}));var O=function(a){var u=a.mobileNumber,g=a.errorCallout,p=a.ravenPayload,m=a.otpInputHeight,v=a.skipProfileFlow,f=a.otpResendDisabled,x=a.hotelsLoyaltyFlow,h=a.getOTP,T=a.setCtaDisabled,O=a.setErrorCallout,y=a.setMobileNumber,E=a.setShowMobilePage,C=a.handleLoginSuccess,k=a.handleLoginFailure,I=i.useRef(Array(4).fill(null)),L=i.useState(S.DETECTING),w=L[0],A=L[1],P=i.useState(r.LOGIN_CONSTANTS.OTP_COUNTDOWN),j=P[0],D=P[1],R=i.useState(""),G=R[0],F=R[1],U=i.useState(!0),V=U[0],M=U[1],K=i.useState(!1),q=K[0],B=K[1],H=i.useState(""),X=H[0],W=H[1],z=i.useState(!0),Y=z[0],Q=z[1],J=i.useState(!1),Z=J[0],$=J[1],ee=i.useRef(),ne=i.useRef(),ie="CT";i.useEffect((function(){te();var n=t.getRavenEventProps();t.ravenSDKTrigger("u_login_click",e.__assign({action_name:"login_otp_screen_opened",login_form:null==n?void 0:n.loginForm,login_type:"native",vertical:null==n?void 0:n.vertical,page_name:null==n?void 0:n.pageName},p))}),[]),i.useEffect((function(){t.isIOSApp()&&Q(!1)}),[]),i.useEffect((function(){te()}),[]),i.useEffect((function(){Z||(I.current[0].focus(),I.current[0].click())}),[Z]),i.useEffect((function(){0===j&&M(!1)}),[j]),i.useEffect((function(){var e;return V&&j>0&&(e=setInterval((function(){D((function(e){return e-1}))}),1e3)),function(){clearInterval(e)}}),[V,j]);var te=i.useCallback((function(){return e.__awaiter(void 0,void 0,void 0,(function(){var n;return e.__generator(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,t.autoReadOtp()];case 1:return n=e.sent(),F(n),A(S.DETECTED),(null==n?void 0:n.length)===r.LOGIN_CONSTANTS.OTP_LENGTH&&re&&re(n,!0),[3,3];case 2:return"NOT_SUPPORTED"===e.sent()&&Q(!1),[3,3];case 3:return[2]}}))}))}),[Y]),ae=i.useCallback((function(n){var i=t.getRavenEventProps();t.ravenSDKTrigger("u_login_error",e.__assign({action_name:"otp_incorrect",login_form:null==i?void 0:i.loginForm,login_type:"native",vertical:null==i?void 0:i.vertical,page_name:null==i?void 0:i.pageName},p));var a=null==n?void 0:n.message;"OTP_VALIDATE_LIMIT_EXCEEDED"!==a&&F(""),I.current[0].focus(),I.current[0].click();var o=r.LOGIN_CONSTANTS[a],l="string"==typeof o?o:r.LOGIN_CONSTANTS.INVALID_OTP;W(l)}),[I]),re=i.useCallback((function(n,i){return e.__awaiter(void 0,void 0,void 0,(function(){var a,o,l,s,_;return e.__generator(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),a=t.getRavenEventProps(),t.ravenSDKTrigger("u_login_click",e.__assign({action_name:"otp_entered",login_form:null==a?void 0:a.loginForm,login_type:"native",entry_type:i?"autodetected":"manual_entry",vertical:null==a?void 0:a.vertical,page_name:null==a?void 0:a.pageName},p)),n===ee.current&&ne.current&&ne.current-Date.now()<=100?[2]:(ee.current=n,ne.current=Date.now(),x&&$(!0),[4,t.validateOtp(u,n)]);case 1:return o=c.sent(),l=o.status,s=o.action,200!==Number(l)||t.isEmpty(s)?(x&&$(!1),k(ie)):(B(!0),W(""),t.updateNativeOnLogin(),"SIGNUP"===s?(v||(window.location.href=r.NAVIGATION_ROUTES.PERSONAL_DETAILS+"?onboardingFlow=true"),C(ie,!0)):C(ie)),[3,3];case 2:return _=c.sent(),x&&$(!1),k(ie),ae(_),[3,3];case 3:return[2]}}))}))}),[ee,ne,B,A,W,ae]),oe=function(){return e.__awaiter(void 0,void 0,void 0,(function(){var n,i,a,o,l;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,navigator.clipboard.readText()];case 1:return(n=e.sent())&&t.isNumeric(n)&&(i=n.slice(0,r.LOGIN_CONSTANTS.OTP_LENGTH).split(""),null===(o=I.current[r.LOGIN_CONSTANTS.OTP_LENGTH-1])||void 0===o||o.focus(),null===(l=I.current[r.LOGIN_CONSTANTS.OTP_LENGTH-1])||void 0===l||l.click(),a=i.join(""),F(a),a.length===r.LOGIN_CONSTANTS.OTP_LENGTH&&re(a,!1)),[2]}}))}))},le=i.useCallback((function(e,n){var i,a;O(""),""!==e.target.value&&n<I.current.length-1&&(null===(i=I.current[n+1])||void 0===i||i.focus(),null===(a=I.current[n+1])||void 0===a||a.click());var o=I.current.map((function(e){return t.isHTMLInputElement(e)?e.value:""})).join("").slice(0,4);F(o),o.length===r.LOGIN_CONSTANTS.OTP_LENGTH&&re(o,!1)}),[F,re]),se=i.useCallback((function(e,n){var i,t,a;"Backspace"===e.key&&n>0&&""===(null===(i=I.current[n])||void 0===i?void 0:i.value)&&(e.preventDefault(),null===(t=I.current[n-1])||void 0===t||t.focus(),null===(a=I.current[n-1])||void 0===a||a.click())}),[I]),_e=i.useCallback((function(){D(r.LOGIN_CONSTANTS.OTP_COUNTDOWN),M(!0),h(u);var n=t.getRavenEventProps();t.ravenSDKTrigger("u_login_error",e.__assign({action_name:"resend_otp_clicked",login_form:null==n?void 0:n.loginForm,login_type:"native",vertical:null==n?void 0:n.vertical,page_name:null==n?void 0:n.pageName},p))}),[D,M]),ce=i.useCallback((function(){T(!0),E(!0),y("")}),[E]);return n.jsxs("div",e.__assign({className:"flex flex-column bg-neutral-100",style:{height:m}},{children:[g&&n.jsx(c.AlertCallout,{variant:"error",textNode:g,prefixIconNode:n.jsx(d.InfoIcon,{fill:"red"}),style:{color:"#ffff",backgroundColor:"#db201e"},className:"fs-12"}),n.jsxs("div",e.__assign({className:"flex flex-bottom"},{children:[n.jsxs(_.Typography,e.__assign({variant:"HM1",color:"heading"},{children:[r.LOGIN_CONSTANTS.OTP_TEXT," ",n.jsx("br",{}),u]})),n.jsx("div",e.__assign({className:"pl-2",onClick:ce},{children:n.jsx(d.Edit,{})}))]})),n.jsxs("div",e.__assign({className:N.otp_container},{children:[n.jsxs("div",e.__assign({className:"flex",style:x?{width:"max-content",position:"relative"}:{}},{children:[e.__spreadArray([],Array(r.LOGIN_CONSTANTS.OTP_LENGTH),!0).map((function(i,t){return n.jsx("div",e.__assign({className:N.otp_box_wrapper},{children:n.jsx(o.FieldV2,{prompt:{hasError:!!X},type:"number",placeholder:"",value:G[t],max:1,inputMode:"numeric",className:N.login_otp_input,variant:"md",ref:function(e){e&&(I.current[t]=e)},onKeyDown:function(e){return se(e,t)},onChange:function(e){return le(e,t)},onPaste:oe,autoFocus:0===t,disabled:!(!x||!Z)})}),t)})),x&&Z&&n.jsx(b,{})]})),!!X&&n.jsx(_.Typography,e.__assign({variant:"P1",color:"warning",className:N.login_otp_error},{children:X}))]})),n.jsx(l.Spacer,{className:"pt-2"}),w===S.DETECTING&&!q&&Y&&j>r.LOGIN_CONSTANTS.RESEND_OTP_COUNTDOWN&&n.jsxs("div",e.__assign({className:"flex flex-middle"},{children:[n.jsx(s.Spinner,{width:"20px",height:"20px",borderColor:"#11a670",className:"bg-neutral-900 bc-black"}),n.jsx(_.Typography,e.__assign({variant:"B3",className:"fs-12 fw-500 ml-1 c-neutral-700"},{children:r.LOGIN_CONSTANTS.AUTO_DETECTING_TEXT}))]})),w===S.DETECTING&&j<=r.LOGIN_CONSTANTS.RESEND_OTP_COUNTDOWN&&!q&&n.jsx(n.Fragment,{children:n.jsxs("div",e.__assign({className:"flex"},{children:[n.jsx(_.Typography,e.__assign({variant:"B3",className:"fs-12 fw-500 c-neutral-700 "},{children:r.LOGIN_CONSTANTS.OTP_RESEND_TEXT})),n.jsx(l.Spacer,{className:"ml-1"}),f?n.jsx(_.Typography,e.__assign({className:"color-neutral-200 fw-500",variant:"B3"},{children:r.LOGIN_CONSTANTS.RESEND_CTA})):n.jsxs(n.Fragment,{children:[0===j&&n.jsx(n.Fragment,{children:n.jsx(_.Typography,e.__assign({isClickable:!0,variant:"B3",onClick:_e,color:"link",className:"\n fs-12 fw-500 c-pointer"},{children:r.LOGIN_CONSTANTS.RESEND_CTA}))}),j>0&&n.jsx(_.Typography,e.__assign({color:"disabled",variant:"B3"},{children:" Resend ("+j+"s)"}))]})]}))}),!X&&q&&n.jsx(n.Fragment,{children:n.jsxs("div",e.__assign({className:"flex flex-middle"},{children:[n.jsx(d.CheckCircle,{}),n.jsx(_.Typography,e.__assign({variant:"P1",color:"success",className:"fs-12"},{children:w===S.DETECTED?r.LOGIN_CONSTANTS.AUTO_DETECTED_TEXT:r.LOGIN_CONSTANTS.VERIFIED_MESSAGE}))]}))}),n.jsx(l.Spacer,{className:"mt-24"})]}))},y={loader:"index-module_loader__63LeU","With-full-opacity":"index-module_With-full-opacity__ZSY-U",loader__content:"index-module_loader__content__Q6kJl",loader__spinner:"index-module_loader__spinner__6B3AR","loader-rotate":"index-module_loader-rotate__efcf3",loader__heading:"index-module_loader__heading__7YZ3N",loader__text:"index-module_loader__text__1QcLi"};x(".index-module_loader__63LeU{align-items:center;background-color:hsla(0,0%,100%,.95);bottom:0;display:flex;justify-content:center;left:0;position:fixed;right:0;top:0;z-index:0}.index-module_loader__63LeU.index-module_With-full-opacity__ZSY-U{background-color:#fff}.index-module_loader__content__Q6kJl{max-width:280px;text-align:center}.index-module_loader__spinner__6B3AR{animation:index-module_loader-rotate__efcf3 .8s linear infinite;border:2px solid rgba(51,102,204,.3);border-radius:50%;border-top-color:#36c;display:inline-block;height:30px;margin-bottom:10px;position:relative;width:30px}.index-module_loader__heading__7YZ3N{color:#000;font-size:18px;font-weight:600;margin-bottom:5px}.index-module_loader__text__1QcLi{color:rgba(0,0,0,.8);font-size:16px;line-height:1.5}");var E=function(i){var t=i.title,a=i.message,r=i.className;return n.jsx("div",e.__assign({className:"".concat(y.utilswrapper," utilswrapper")},{children:n.jsx("div",e.__assign({className:f.default(y.loader,r)},{children:n.jsxs("div",e.__assign({className:y.loader__content},{children:[n.jsx("div",{className:y.loader__spinner}),n.jsx("h5",e.__assign({className:y.loader__heading},{children:t})),n.jsx("p",e.__assign({className:y.loader__text},{children:a}))]}))}))}))},C=function(a){var l=a.sendingOtp,s=a.ctaDisabled,u=a.getOTP,v=a.setErrorCallout,f=a.errorCallout,x=a.mobileNumber,h=a.setMobileInputHeight,T=a.setMobileNumber,S=a.fallbackUri,b=a.skipProfileFlow,O=a.ravenPayload,y=a.hotelsLoyaltyFlow,E=a.isFkLoginEnabled,C=void 0===E||E,k=a.isPrivacyPolicyVisible,I=void 0===k||k,L=i.useState(t.isFKSSOEnabled)[0],w=i.useState(!1),A=w[0],P=w[1],j=i.useRef(null),D=i.useRef(null);i.useEffect((function(){if(D.current){var e=D.current.clientHeight;h(e)}}),[D.current]),i.useEffect((function(){var e;return j.current&&(e=setTimeout((function(){var e;null===(e=j.current)||void 0===e||e.focus()}),100)),function(){clearTimeout(e)}}),[]),i.useEffect((function(){t.isAndroidApp()&&F()}),[]);var R=i.useCallback((function(){return e.__awaiter(void 0,void 0,void 0,(function(){var n,i;return e.__generator(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),n=t.getRavenEventProps(),t.ravenSDKTrigger("u_login_click",e.__assign({action_name:"login_with_flipkart_clicked",login_form:null==n?void 0:n.loginForm,login_type:"fk_sso",vertical:null==n?void 0:n.vertical,page_name:null==n?void 0:n.pageName},O)),P(!0),[4,t.handleFKSSO(S,b)];case 1:return i=a.sent(),y||P(!1),t.isPwa()&&(window.location.href=i),[3,3];case 2:return a.sent(),P(!1),[3,3];case 3:return[2]}}))}))}),[]),G=i.useCallback((function(n,i){void 0===i&&(i=!1),v("");var a=n.target.value||"";if(a=a.replace(t.MULTI_SPACE," ").trimStart(),T(a),t.isValidMobileNumber(n.target.value)){u(a);var r=t.getRavenEventProps();t.ravenSDKTrigger("u_login_click",e.__assign({action_name:"get_otp_clicked",login_form:null==r?void 0:r.loginForm,login_type:"native",entry_type:"auto_click",vertical:null==r?void 0:r.vertical,page_name:null==r?void 0:r.pageName},O)),i?t.ravenSDKTrigger("u_login_click",e.__assign({action_name:"phone_number_autodetected",login_form:null==r?void 0:r.loginForm,login_type:"native",entry_type:"autodetected",vertical:null==r?void 0:r.vertical,page_name:null==r?void 0:r.pageName},O)):t.ravenSDKTrigger("u_login_click",e.__assign({action_name:"phone_number_entered",login_form:null==r?void 0:r.loginForm,login_type:"native",entry_type:"manual_entry",vertical:null==r?void 0:r.vertical,page_name:null==r?void 0:r.pageName},O))}}),[T]),F=i.useCallback((function(){return e.__awaiter(void 0,void 0,void 0,(function(){var n,i;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,t.showMobileNumberHint()];case 1:return n=e.sent(),i={target:{value:n}},n&&G(i,!0),[2]}}))}))}),[G]),U=i.useCallback((function(){var n=t.getRavenEventProps();t.ravenSDKTrigger("u_login_click",e.__assign({action_name:"policy_click",login_form:null==n?void 0:n.loginForm,login_type:"native",vertical:null==n?void 0:n.vertical,page_name:null==n?void 0:n.pageName},O)),window.location.href=r.NAVIGATION_ROUTES.PRIVACY_POLICY}),[]),V=i.useCallback((function(){var n=t.getRavenEventProps();t.ravenSDKTrigger("u_login_click",e.__assign({action_name:"tnc_click",login_form:null==n?void 0:n.loginForm,login_type:"native",vertical:null==n?void 0:n.vertical,page_name:null==n?void 0:n.pageName},O)),window.location.href=r.NAVIGATION_ROUTES.TERMS}),[]);return n.jsxs("div",e.__assign({className:"flex flex-column",ref:D},{children:[f&&n.jsx(c.AlertCallout,{variant:"error",textNode:f,prefixIconNode:n.jsx(d.InfoIcon,{fill:"red"}),style:{color:"#ffff",backgroundColor:"#db201e"},className:"fs-12"}),n.jsx(_.Typography,e.__assign({variant:"HM1",color:"heading",className:"mb-4 fs-24"},{children:r.LOGIN_CONSTANTS.LOGIN_TO_CT})),n.jsx("label",e.__assign({style:{visibility:"hidden",width:"0.1px",height:"0.1px"},htmlFor:"phonenumber"},{children:"Phone number"})),n.jsx(o.PhoneField,{onChange:G,value:x,name:"phonenumber",placeholder:"",inputMode:"numeric",ref:j,min:0,max:10,autoFocus:!0,countryCode:r.LOGIN_CONSTANTS.COUNTRY_CODE}),n.jsx(g.Button,e.__assign({color:"primary",size:"medium",minWidth:"160px",disabled:s,loading:l,className:"my-6",onClick:function(){return u(x)}},{children:r.LOGIN_CONSTANTS.GET_OTP})),L&&C&&n.jsxs(n.Fragment,{children:[n.jsxs("div",e.__assign({className:"my-6 p-relative"},{children:[n.jsx(p.Divider,{}),n.jsx("span",e.__assign({className:"".concat(N.mobileinput_seperatortext)},{children:"or"}))]})),n.jsx(g.Button,e.__assign({variant:"outline",size:"medium",className:"my-6",loading:A,onClick:R,showLeftIcon:!A,LeftIcon:n.jsx("img",{src:m.FlipkartLogo})},{children:r.LOGIN_CONSTANTS.FK_LOGIN_CTA}))]}),I&&n.jsxs("div",e.__assign({className:"pt-8 pb-6"},{children:[n.jsx(p.Divider,{}),n.jsxs("div",e.__assign({className:"flex flex-middle \n flex-center flex-wrap pt-2"},{children:[n.jsx(_.Typography,e.__assign({variant:"P1",className:N.footer_text},{children:r.LOGIN_CONSTANTS.FOOTER_TEXT})),n.jsx(_.Typography,e.__assign({variant:"P1",color:"link",className:"pl-1 fs-12",isClickable:!0,onClick:U},{children:r.LOGIN_CONSTANTS.PRIVACY_CTA})),n.jsx(_.Typography,e.__assign({className:"px-1 fs-12 c-neutral-700",variant:"P1"},{children:"& "})),n.jsx(_.Typography,e.__assign({variant:"P1",color:"link",isClickable:!0,onClick:V,className:"fs-12"},{children:r.LOGIN_CONSTANTS.TNC_CTA}))]}))]}))]}))};exports.LoginForm=function(o){var l=o.fallbackUri,s=o.isLoginModule,_=o.skipProfileFlow,c=o.sendUserInsights,d=o.isFkLoginEnabled,u=o.ravenPayload,g=void 0===u?{}:u,p=o.hotelsLoyaltyFlow,m=o.enableProfileFetch,v=o.isPrivacyPolicyVisible,f=o.onAuthSuccess,x=o.onAuthFailure,h=i.useState(!0),T=h[0],S=h[1],b=i.useState(!0),y=b[0],k=b[1],I=i.useState(!1),L=I[0],w=I[1],A=i.useState(""),P=A[0],j=A[1],D=i.useState(0),R=D[0],G=D[1],F=i.useState(""),U=F[0],V=F[1],M=i.useState(!1),K=M[0],q=M[1],B=i.useState(!1),H=B[0],X=B[1],W=i.useState(!1),z=W[0],Y=W[1],Q=i.useCallback((function(n){return e.__awaiter(void 0,void 0,void 0,(function(){var i,a,o,l;return e.__generator(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),k(!1),w(!0),t.triggerOTPListener(),[4,t.sendLoginOtp(n)];case 1:return i=e.sent(),"SUCCESS"===(i||{}).status&&(S(!1),w(!1)),[3,3];case 2:return a=e.sent(),console.error(a),o=(a||{}).message,w(!1),l=o&&r.LOGIN_CONSTANTS[o],V(String(l||r.LOGIN_CONSTANTS.GENERIC_ERROR_MESSAGE)),"OTP_SEND_LIMIT_EXCEEDED"===o&&q(!0),[3,3];case 3:return[2]}}))}))}),[T,S]),J=i.useCallback((function(n,i){var a=t.getRavenEventProps(),r=e.__assign({action_name:"login_successful",login_form:null==a?void 0:a.loginForm,login_type:"native",login_new:i?"sign_up":"sign_in",vertical:null==a?void 0:a.vertical,page_name:null==a?void 0:a.pageName},g);c?t.sendEventWithUserInsights("u_login_success",r):t.ravenSDKTrigger("u_login_success",r),m&&t.handleProfileFetch(),p||s||i&&!_||X(!0),f(i)}),[g,s,_,c,p,m]),Z=i.useCallback((function(e){x(e)}),[]),$=function(){Y(!0)};return i.useEffect((function(){if(!s){window&&(window.showSigninLoaderScreen=$);var e=t.getQueryParam("fkSSOstatus"),n="FK";"signin"===e&&(t.isAndroidApp()&&t.updateNativeAndroidOnSignIn(),J(n)),"signup"===e&&(t.isAndroidApp()&&t.updateNativeAndroidOnSignIn(),J(n,!0)),"failure"===e&&Z(n)}}),[]),n.jsxs("div",e.__assign({className:"".concat(N.utilswrapper," utilswrapper")},{children:[H&&n.jsx(a.Toast,{text:"Logged in successfully!",show:H,className:"".concat(N.nonUtilsSelector_toast),closeTimeout:2e3}),z&&n.jsx(E,{title:"Please wait",message:"Signing in...",className:"z-10 bg-white"}),T?n.jsx(C,{device:"PWA",ctaDisabled:y,sendingOtp:L,getOTP:Q,mobileNumber:P,setMobileNumber:j,setMobileInputHeight:G,fallbackUri:l,skipProfileFlow:_,setErrorCallout:V,errorCallout:U,ravenPayload:g,hotelsLoyaltyFlow:p,isFkLoginEnabled:d,isPrivacyPolicyVisible:v}):n.jsx(O,{mobileNumber:P,getOTP:Q,setCtaDisabled:k,setShowMobilePage:S,handleLoginSuccess:J,handleLoginFailure:Z,otpInputHeight:R,setMobileNumber:j,setErrorCallout:V,errorCallout:U,otpResendDisabled:K,ravenPayload:g,skipProfileFlow:_,hotelsLoyaltyFlow:p})]}))};
|
|
545
2
|
//# sourceMappingURL=ct-platform-login-form.cjs.js.map
|