@cleartrip/ct-platform-login-module 1.1.0-beta.3 → 1.1.0-beta.4

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