powr-sdk-web 4.2.5 → 4.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.js +134 -121
- package/package.json +1 -1
package/dist/auth/index.js
CHANGED
|
@@ -7,7 +7,7 @@ exports["default"] = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _auth = require("../utils/auth");
|
|
9
9
|
var _firebase = require("../utils/firebase");
|
|
10
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t5 in e) "default" !== _t5 && {}.hasOwnProperty.call(e, _t5) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t5)) && (i.get || i.set) ? o(f, _t5, i) : f[_t5] = e[_t5]); return f; })(e, t); }
|
|
11
11
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
12
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
13
13
|
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
@@ -32,7 +32,9 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
32
32
|
appLogo = _ref.appLogo,
|
|
33
33
|
_ref$mode = _ref.mode,
|
|
34
34
|
mode = _ref$mode === void 0 ? 'toggle' : _ref$mode,
|
|
35
|
-
projectId = _ref.projectId
|
|
35
|
+
projectId = _ref.projectId,
|
|
36
|
+
_ref$fieldType = _ref.fieldType,
|
|
37
|
+
fieldType = _ref$fieldType === void 0 ? 'both' : _ref$fieldType;
|
|
36
38
|
var _useState = (0, _react.useState)(function () {
|
|
37
39
|
switch (mode) {
|
|
38
40
|
case 'login':
|
|
@@ -48,7 +50,8 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
48
50
|
isLogin = _useState2[0],
|
|
49
51
|
setIsLogin = _useState2[1];
|
|
50
52
|
var _useState3 = (0, _react.useState)({
|
|
51
|
-
|
|
53
|
+
phone: '',
|
|
54
|
+
email: '',
|
|
52
55
|
password: '',
|
|
53
56
|
confirmPassword: '',
|
|
54
57
|
fullName: ''
|
|
@@ -115,6 +118,10 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
115
118
|
_useState28 = _slicedToArray(_useState27, 2),
|
|
116
119
|
firebaseConfirm = _useState28[0],
|
|
117
120
|
setFirebaseConfirm = _useState28[1];
|
|
121
|
+
var _useState29 = (0, _react.useState)(false),
|
|
122
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
|
123
|
+
otpVerified = _useState30[0],
|
|
124
|
+
setOtpVerified = _useState30[1];
|
|
118
125
|
var shouldShowToggle = mode === 'toggle';
|
|
119
126
|
var handleInputChange = /*#__PURE__*/function () {
|
|
120
127
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(e) {
|
|
@@ -183,7 +190,7 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
183
190
|
}();
|
|
184
191
|
var verifyFirebaseOtp = /*#__PURE__*/function () {
|
|
185
192
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
186
|
-
var
|
|
193
|
+
var _t2;
|
|
187
194
|
return _regenerator().w(function (_context3) {
|
|
188
195
|
while (1) switch (_context3.p = _context3.n) {
|
|
189
196
|
case 0:
|
|
@@ -200,24 +207,23 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
200
207
|
_context3.n = 3;
|
|
201
208
|
return firebaseConfirm.confirm(otp);
|
|
202
209
|
case 3:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
case 4:
|
|
207
|
-
_context3.n = 6;
|
|
210
|
+
setOtpVerified(true);
|
|
211
|
+
setSuccess('OTP verified! Please set your password to complete registration.');
|
|
212
|
+
_context3.n = 5;
|
|
208
213
|
break;
|
|
209
|
-
case
|
|
210
|
-
_context3.p =
|
|
214
|
+
case 4:
|
|
215
|
+
_context3.p = 4;
|
|
211
216
|
_t2 = _context3.v;
|
|
212
217
|
setError('Invalid OTP. Please try again.');
|
|
213
|
-
|
|
214
|
-
|
|
218
|
+
setOtpVerified(false);
|
|
219
|
+
case 5:
|
|
220
|
+
_context3.p = 5;
|
|
215
221
|
setLoading(false);
|
|
216
|
-
return _context3.f(
|
|
217
|
-
case
|
|
222
|
+
return _context3.f(5);
|
|
223
|
+
case 6:
|
|
218
224
|
return _context3.a(2);
|
|
219
225
|
}
|
|
220
|
-
}, _callee3, null, [[1, 5, 6
|
|
226
|
+
}, _callee3, null, [[1, 4, 5, 6]]);
|
|
221
227
|
}));
|
|
222
228
|
return function verifyFirebaseOtp() {
|
|
223
229
|
return _ref4.apply(this, arguments);
|
|
@@ -230,44 +236,34 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
230
236
|
return emailRegex.test(email);
|
|
231
237
|
};
|
|
232
238
|
var isValidPhone = function isValidPhone(phone) {
|
|
233
|
-
// Remove all non-digit characters
|
|
234
239
|
var cleanPhone = phone.replace(/\D/g, '');
|
|
235
|
-
// Check if it's a valid phone number (7-15 digits)
|
|
236
240
|
return cleanPhone.length >= 7 && cleanPhone.length <= 15;
|
|
237
241
|
};
|
|
238
242
|
var handleSubmit = /*#__PURE__*/function () {
|
|
239
243
|
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(e) {
|
|
240
|
-
var
|
|
241
|
-
errors,
|
|
242
|
-
value,
|
|
243
|
-
isEmail,
|
|
244
|
-
endpoint,
|
|
245
|
-
payload,
|
|
246
|
-
_yield$apiCall,
|
|
247
|
-
data,
|
|
248
|
-
ok,
|
|
249
|
-
_args4 = arguments,
|
|
250
|
-
_t3,
|
|
251
|
-
_t4;
|
|
244
|
+
var errors, endpoint, phoneOrEmail, payload, _yield$apiCall, data, ok, _t3;
|
|
252
245
|
return _regenerator().w(function (_context4) {
|
|
253
246
|
while (1) switch (_context4.p = _context4.n) {
|
|
254
247
|
case 0:
|
|
255
|
-
skipPhoneValidation = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : false;
|
|
256
248
|
if (e) e.preventDefault();
|
|
257
249
|
setLoading(true);
|
|
258
250
|
setError('');
|
|
259
251
|
setSuccess('');
|
|
260
252
|
setFieldErrors({});
|
|
261
|
-
errors = {};
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
253
|
+
errors = {}; // Validation for phone/email fields
|
|
254
|
+
if (fieldType === 'phone' || fieldType === 'both') {
|
|
255
|
+
if (!formData.phone.trim()) {
|
|
256
|
+
errors.phone = 'Phone is required';
|
|
257
|
+
} else if (!isValidPhone(formData.phone)) {
|
|
258
|
+
errors.phone = 'Please enter a valid phone number';
|
|
259
|
+
}
|
|
266
260
|
}
|
|
267
|
-
if (
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
261
|
+
if (fieldType === 'email' || fieldType === 'both') {
|
|
262
|
+
if (!formData.email.trim()) {
|
|
263
|
+
errors.email = 'Email is required';
|
|
264
|
+
} else if (!isValidEmail(formData.email)) {
|
|
265
|
+
errors.email = 'Please enter a valid email address';
|
|
266
|
+
}
|
|
271
267
|
}
|
|
272
268
|
if (!formData.password.trim()) {
|
|
273
269
|
errors.password = 'Password is required';
|
|
@@ -277,10 +273,7 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
277
273
|
if (!isLogin && !formData.fullName.trim()) {
|
|
278
274
|
errors.fullName = 'Full name is required';
|
|
279
275
|
}
|
|
280
|
-
if (!isLogin &&
|
|
281
|
-
errors.confirmPassword = 'Passwords do not match';
|
|
282
|
-
}
|
|
283
|
-
if (!isLogin && (!otp || !firebaseConfirm)) {
|
|
276
|
+
if (!isLogin && fieldType === 'phone' && !otpVerified) {
|
|
284
277
|
errors.otp = 'Please verify OTP before signing up';
|
|
285
278
|
}
|
|
286
279
|
if (!(Object.keys(errors).length > 0)) {
|
|
@@ -291,50 +284,30 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
291
284
|
setLoading(false);
|
|
292
285
|
return _context4.a(2);
|
|
293
286
|
case 1:
|
|
294
|
-
|
|
295
|
-
_context4.n = 7;
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
_context4.p = 2;
|
|
299
|
-
if (!(firebaseConfirm && otp)) {
|
|
300
|
-
_context4.n = 4;
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
_context4.n = 3;
|
|
304
|
-
return firebaseConfirm.confirm(otp);
|
|
305
|
-
case 3:
|
|
306
|
-
_context4.n = 5;
|
|
307
|
-
break;
|
|
308
|
-
case 4:
|
|
309
|
-
setError('Please verify OTP before signing up');
|
|
310
|
-
setLoading(false);
|
|
311
|
-
return _context4.a(2);
|
|
312
|
-
case 5:
|
|
313
|
-
_context4.n = 7;
|
|
314
|
-
break;
|
|
315
|
-
case 6:
|
|
316
|
-
_context4.p = 6;
|
|
317
|
-
_t3 = _context4.v;
|
|
318
|
-
setError('Invalid OTP. Please try again.');
|
|
319
|
-
setLoading(false);
|
|
320
|
-
return _context4.a(2);
|
|
321
|
-
case 7:
|
|
322
|
-
_context4.p = 7;
|
|
287
|
+
_context4.p = 1;
|
|
323
288
|
endpoint = isLogin ? "/auth/login" : "/auth/register";
|
|
289
|
+
phoneOrEmail = '';
|
|
290
|
+
if (fieldType === 'phone') {
|
|
291
|
+
phoneOrEmail = formData.phone;
|
|
292
|
+
} else if (fieldType === 'email') {
|
|
293
|
+
phoneOrEmail = formData.email;
|
|
294
|
+
} else if (fieldType === 'both') {
|
|
295
|
+
phoneOrEmail = formData.phone || formData.email;
|
|
296
|
+
}
|
|
324
297
|
payload = isLogin ? {
|
|
325
|
-
phoneOrEmail:
|
|
298
|
+
phoneOrEmail: phoneOrEmail,
|
|
326
299
|
password: formData.password
|
|
327
300
|
} : {
|
|
328
301
|
fullName: formData.fullName,
|
|
329
|
-
phoneOrEmail:
|
|
302
|
+
phoneOrEmail: phoneOrEmail,
|
|
330
303
|
password: formData.password
|
|
331
304
|
};
|
|
332
|
-
_context4.n =
|
|
305
|
+
_context4.n = 2;
|
|
333
306
|
return (0, _auth.apiCall)(apiUrl, endpoint, projectId, {
|
|
334
307
|
method: 'POST',
|
|
335
308
|
body: payload
|
|
336
309
|
});
|
|
337
|
-
case
|
|
310
|
+
case 2:
|
|
338
311
|
_yield$apiCall = _context4.v;
|
|
339
312
|
data = _yield$apiCall.data;
|
|
340
313
|
ok = _yield$apiCall.ok;
|
|
@@ -346,7 +319,8 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
346
319
|
onRegister(data);
|
|
347
320
|
}
|
|
348
321
|
setFormData({
|
|
349
|
-
|
|
322
|
+
phone: '',
|
|
323
|
+
email: '',
|
|
350
324
|
password: '',
|
|
351
325
|
confirmPassword: '',
|
|
352
326
|
fullName: ''
|
|
@@ -366,20 +340,20 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
366
340
|
setError("".concat(isLogin ? 'Login' : 'Registration', " failed. Please try again."));
|
|
367
341
|
}
|
|
368
342
|
}
|
|
369
|
-
_context4.n =
|
|
343
|
+
_context4.n = 4;
|
|
370
344
|
break;
|
|
371
|
-
case
|
|
372
|
-
_context4.p =
|
|
373
|
-
|
|
345
|
+
case 3:
|
|
346
|
+
_context4.p = 3;
|
|
347
|
+
_t3 = _context4.v;
|
|
374
348
|
setError('Network error. Please try again.');
|
|
375
|
-
case
|
|
376
|
-
_context4.p =
|
|
349
|
+
case 4:
|
|
350
|
+
_context4.p = 4;
|
|
377
351
|
setLoading(false);
|
|
378
|
-
return _context4.f(
|
|
379
|
-
case
|
|
352
|
+
return _context4.f(4);
|
|
353
|
+
case 5:
|
|
380
354
|
return _context4.a(2);
|
|
381
355
|
}
|
|
382
|
-
}, _callee4, null, [[
|
|
356
|
+
}, _callee4, null, [[1, 3, 4, 5]]);
|
|
383
357
|
}));
|
|
384
358
|
return function handleSubmit(_x3) {
|
|
385
359
|
return _ref5.apply(this, arguments);
|
|
@@ -401,7 +375,7 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
401
375
|
};
|
|
402
376
|
var handleGetOtp = /*#__PURE__*/function () {
|
|
403
377
|
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
404
|
-
var _yield$apiCall2, data, ok,
|
|
378
|
+
var _yield$apiCall2, data, ok, _t4;
|
|
405
379
|
return _regenerator().w(function (_context5) {
|
|
406
380
|
while (1) switch (_context5.p = _context5.n) {
|
|
407
381
|
case 0:
|
|
@@ -440,7 +414,7 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
440
414
|
break;
|
|
441
415
|
case 4:
|
|
442
416
|
_context5.p = 4;
|
|
443
|
-
|
|
417
|
+
_t4 = _context5.v;
|
|
444
418
|
setError('Network error. Please try again.');
|
|
445
419
|
case 5:
|
|
446
420
|
_context5.p = 5;
|
|
@@ -502,32 +476,32 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
502
476
|
required: true
|
|
503
477
|
}), fieldErrors.fullName && /*#__PURE__*/_react["default"].createElement("div", {
|
|
504
478
|
style: styles.fieldError
|
|
505
|
-
}, fieldErrors.fullName)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
479
|
+
}, fieldErrors.fullName)), (fieldType === 'phone' || fieldType === 'both') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
506
480
|
style: styles.formGroup
|
|
507
481
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
508
|
-
htmlFor: "
|
|
482
|
+
htmlFor: "phone",
|
|
509
483
|
style: styles.label
|
|
510
|
-
}, "Phone
|
|
484
|
+
}, "Phone"), /*#__PURE__*/_react["default"].createElement("input", {
|
|
511
485
|
type: "text",
|
|
512
|
-
id: "
|
|
513
|
-
name: "
|
|
514
|
-
value: formData.
|
|
486
|
+
id: "phone",
|
|
487
|
+
name: "phone",
|
|
488
|
+
value: formData.phone,
|
|
515
489
|
onChange: handleInputChange,
|
|
516
|
-
style: _objectSpread(_objectSpread({}, styles.input), fieldErrors.
|
|
517
|
-
placeholder: "Enter your phone
|
|
518
|
-
required:
|
|
519
|
-
}), fieldErrors.
|
|
490
|
+
style: _objectSpread(_objectSpread({}, styles.input), fieldErrors.phone ? styles.inputError : {}),
|
|
491
|
+
placeholder: "Enter your phone number",
|
|
492
|
+
required: fieldType === 'phone' || fieldType === 'both'
|
|
493
|
+
}), fieldErrors.phone && /*#__PURE__*/_react["default"].createElement("div", {
|
|
520
494
|
style: styles.fieldError
|
|
521
|
-
}, fieldErrors.
|
|
495
|
+
}, fieldErrors.phone), !isLogin && isValidPhone(formData.phone) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, !firebaseOtpSent ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("button", {
|
|
522
496
|
type: "button",
|
|
523
497
|
onClick: function onClick() {
|
|
524
|
-
return sendFirebaseOtp(formatPhone(formData.
|
|
498
|
+
return sendFirebaseOtp(formatPhone(formData.phone));
|
|
525
499
|
},
|
|
526
500
|
style: styles.otpButton,
|
|
527
501
|
disabled: otpLoading
|
|
528
502
|
}, otpLoading ? 'Sending OTP...' : 'Send OTP to Phone'), /*#__PURE__*/_react["default"].createElement("div", {
|
|
529
503
|
id: "recaptcha-container"
|
|
530
|
-
})) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("label", {
|
|
504
|
+
})) : !otpVerified ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("label", {
|
|
531
505
|
htmlFor: "otp",
|
|
532
506
|
style: styles.label
|
|
533
507
|
}, "Enter OTP"), /*#__PURE__*/_react["default"].createElement("input", {
|
|
@@ -546,7 +520,28 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
546
520
|
onClick: verifyFirebaseOtp,
|
|
547
521
|
style: styles.otpButton,
|
|
548
522
|
disabled: loading || !otp
|
|
549
|
-
}, loading ? 'Verifying...' : 'Verify OTP
|
|
523
|
+
}, loading ? 'Verifying...' : 'Verify OTP')) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
524
|
+
style: {
|
|
525
|
+
color: '#16a34a',
|
|
526
|
+
marginBottom: 8
|
|
527
|
+
}
|
|
528
|
+
}, "OTP verified! Now set your password and sign up."))), (fieldType === 'email' || fieldType === 'both') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
529
|
+
style: styles.formGroup
|
|
530
|
+
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
531
|
+
htmlFor: "email",
|
|
532
|
+
style: styles.label
|
|
533
|
+
}, "Email"), /*#__PURE__*/_react["default"].createElement("input", {
|
|
534
|
+
type: "email",
|
|
535
|
+
id: "email",
|
|
536
|
+
name: "email",
|
|
537
|
+
value: formData.email,
|
|
538
|
+
onChange: handleInputChange,
|
|
539
|
+
style: _objectSpread(_objectSpread({}, styles.input), fieldErrors.email ? styles.inputError : {}),
|
|
540
|
+
placeholder: "Enter your email",
|
|
541
|
+
required: fieldType === 'email' || fieldType === 'both'
|
|
542
|
+
}), fieldErrors.email && /*#__PURE__*/_react["default"].createElement("div", {
|
|
543
|
+
style: styles.fieldError
|
|
544
|
+
}, fieldErrors.email)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
550
545
|
style: styles.formGroup
|
|
551
546
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
552
547
|
htmlFor: "password",
|
|
@@ -561,14 +556,16 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
561
556
|
onChange: handleInputChange,
|
|
562
557
|
style: _objectSpread(_objectSpread(_objectSpread({}, styles.input), styles.passwordInput), fieldErrors.password ? styles.inputError : {}),
|
|
563
558
|
placeholder: "Enter your password",
|
|
564
|
-
required: true
|
|
559
|
+
required: true,
|
|
560
|
+
disabled: !isLogin && !otpVerified
|
|
565
561
|
}), /*#__PURE__*/_react["default"].createElement("button", {
|
|
566
562
|
type: "button",
|
|
567
563
|
onClick: function onClick() {
|
|
568
564
|
return setShowPassword(!showPassword);
|
|
569
565
|
},
|
|
570
566
|
style: styles.eyeButton,
|
|
571
|
-
tabIndex: -1
|
|
567
|
+
tabIndex: -1,
|
|
568
|
+
disabled: !isLogin && !otpVerified
|
|
572
569
|
}, showPassword ? /*#__PURE__*/_react["default"].createElement("span", {
|
|
573
570
|
style: styles.eyeIcon
|
|
574
571
|
}, "\uD83D\uDC41\uFE0F") : /*#__PURE__*/_react["default"].createElement("span", {
|
|
@@ -590,14 +587,16 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
590
587
|
onChange: handleInputChange,
|
|
591
588
|
style: _objectSpread(_objectSpread(_objectSpread({}, styles.input), styles.passwordInput), fieldErrors.confirmPassword ? styles.inputError : {}),
|
|
592
589
|
placeholder: "Confirm your password",
|
|
593
|
-
required: true
|
|
590
|
+
required: true,
|
|
591
|
+
disabled: !otpVerified
|
|
594
592
|
}), /*#__PURE__*/_react["default"].createElement("button", {
|
|
595
593
|
type: "button",
|
|
596
594
|
onClick: function onClick() {
|
|
597
595
|
return setShowConfirmPassword(!showConfirmPassword);
|
|
598
596
|
},
|
|
599
597
|
style: styles.eyeButton,
|
|
600
|
-
tabIndex: -1
|
|
598
|
+
tabIndex: -1,
|
|
599
|
+
disabled: !otpVerified
|
|
601
600
|
}, showConfirmPassword ? /*#__PURE__*/_react["default"].createElement("span", {
|
|
602
601
|
style: styles.eyeIcon
|
|
603
602
|
}, "\uD83D\uDC41\uFE0F") : /*#__PURE__*/_react["default"].createElement("span", {
|
|
@@ -620,21 +619,35 @@ var PowrLogin = function PowrLogin(_ref) {
|
|
|
620
619
|
},
|
|
621
620
|
style: styles.forgotPasswordLink
|
|
622
621
|
}, "Forgot password?")), isLogin && showOtpOption && /*#__PURE__*/_react["default"].createElement("div", {
|
|
623
|
-
style: styles.
|
|
624
|
-
}, /*#__PURE__*/_react["default"].createElement("
|
|
625
|
-
|
|
626
|
-
|
|
622
|
+
style: styles.formGroup
|
|
623
|
+
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
624
|
+
htmlFor: "password",
|
|
625
|
+
style: styles.label
|
|
626
|
+
}, "Password"), /*#__PURE__*/_react["default"].createElement("div", {
|
|
627
|
+
style: styles.passwordContainer
|
|
628
|
+
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
629
|
+
type: showPassword ? "text" : "password",
|
|
630
|
+
id: "password",
|
|
631
|
+
name: "password",
|
|
632
|
+
value: formData.password,
|
|
633
|
+
onChange: handleInputChange,
|
|
634
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, styles.input), styles.passwordInput), fieldErrors.password ? styles.inputError : {}),
|
|
635
|
+
placeholder: "Enter your password",
|
|
636
|
+
required: true
|
|
637
|
+
}), /*#__PURE__*/_react["default"].createElement("button", {
|
|
627
638
|
type: "button",
|
|
628
|
-
onClick:
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
}
|
|
634
|
-
style: styles.
|
|
635
|
-
},
|
|
636
|
-
style: styles.
|
|
637
|
-
},
|
|
639
|
+
onClick: function onClick() {
|
|
640
|
+
return setShowPassword(!showPassword);
|
|
641
|
+
},
|
|
642
|
+
style: styles.eyeButton,
|
|
643
|
+
tabIndex: -1
|
|
644
|
+
}, showPassword ? /*#__PURE__*/_react["default"].createElement("span", {
|
|
645
|
+
style: styles.eyeIcon
|
|
646
|
+
}, "\uD83D\uDC41\uFE0F") : /*#__PURE__*/_react["default"].createElement("span", {
|
|
647
|
+
style: styles.eyeIcon
|
|
648
|
+
}, "\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8\uFE0F"))), fieldErrors.password && /*#__PURE__*/_react["default"].createElement("div", {
|
|
649
|
+
style: styles.fieldError
|
|
650
|
+
}, fieldErrors.password)), /*#__PURE__*/_react["default"].createElement("button", {
|
|
638
651
|
type: "submit",
|
|
639
652
|
disabled: loading,
|
|
640
653
|
style: _objectSpread(_objectSpread({}, styles.button), loading ? styles.buttonDisabled : {})
|