ordering-ui-external 1.6.8 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/_bundles/{0.ordering-ui.7635bd47ae9a481b3f59.js → 0.ordering-ui.8b7044a2b34939a44465.js} +0 -0
  2. package/_bundles/{1.ordering-ui.7635bd47ae9a481b3f59.js → 1.ordering-ui.8b7044a2b34939a44465.js} +0 -0
  3. package/_bundles/{2.ordering-ui.7635bd47ae9a481b3f59.js → 2.ordering-ui.8b7044a2b34939a44465.js} +0 -0
  4. package/_bundles/{4.ordering-ui.7635bd47ae9a481b3f59.js → 4.ordering-ui.8b7044a2b34939a44465.js} +0 -0
  5. package/_bundles/{5.ordering-ui.7635bd47ae9a481b3f59.js → 5.ordering-ui.8b7044a2b34939a44465.js} +0 -0
  6. package/_bundles/{6.ordering-ui.7635bd47ae9a481b3f59.js → 6.ordering-ui.8b7044a2b34939a44465.js} +0 -0
  7. package/_bundles/{7.ordering-ui.7635bd47ae9a481b3f59.js → 7.ordering-ui.8b7044a2b34939a44465.js} +1 -1
  8. package/_bundles/{7.ordering-ui.7635bd47ae9a481b3f59.js.LICENSE.txt → 7.ordering-ui.8b7044a2b34939a44465.js.LICENSE.txt} +0 -0
  9. package/_bundles/{8.ordering-ui.7635bd47ae9a481b3f59.js → 8.ordering-ui.8b7044a2b34939a44465.js} +0 -0
  10. package/_bundles/{9.ordering-ui.7635bd47ae9a481b3f59.js → 9.ordering-ui.8b7044a2b34939a44465.js} +0 -0
  11. package/_bundles/ordering-ui.8b7044a2b34939a44465.js +2 -0
  12. package/_bundles/{ordering-ui.7635bd47ae9a481b3f59.js.LICENSE.txt → ordering-ui.8b7044a2b34939a44465.js.LICENSE.txt} +0 -0
  13. package/_modules/components/BusinessInformation/index.js +8 -10
  14. package/_modules/components/LoginForm/index.js +58 -17
  15. package/_modules/components/SignUpForm/index.js +61 -20
  16. package/_modules/themes/callcenterOriginal/src/components/LoginForm/index.js +71 -25
  17. package/_modules/themes/callcenterOriginal/src/components/SignUpForm/index.js +60 -19
  18. package/_modules/themes/eight/src/components/LoginForm/index.js +63 -20
  19. package/_modules/themes/eight/src/components/SignUpForm/index.js +63 -22
  20. package/_modules/themes/five/src/components/BusinessController/index.js +2 -2
  21. package/_modules/themes/five/src/components/BusinessPreorder/index.js +6 -45
  22. package/_modules/themes/five/src/components/BusinessProductsListing/index.js +1 -1
  23. package/_modules/themes/five/src/components/Checkout/index.js +19 -3
  24. package/_modules/themes/five/src/components/Checkout/styles.js +5 -3
  25. package/_modules/themes/five/src/components/Header/index.js +3 -3
  26. package/_modules/themes/five/src/components/Header/styles.js +1 -1
  27. package/_modules/themes/five/src/components/MomentControl/index.js +1 -41
  28. package/_modules/themes/five/src/components/OrderDetails/OrderBillSection.js +2 -2
  29. package/_modules/themes/five/src/components/OrderDetails/index.js +14 -16
  30. package/_modules/themes/five/src/components/OrderDetails/styles.js +7 -3
  31. package/_modules/themes/five/src/components/PaymentOptions/index.js +3 -6
  32. package/_modules/themes/five/src/components/PlaceSpot/styles.js +2 -2
  33. package/_modules/themes/five/src/components/ProductItemAccordion/index.js +7 -4
  34. package/_modules/themes/five/src/components/ProductOption/index.js +1 -1
  35. package/_modules/themes/five/src/components/ProductOptionSubOption/index.js +1 -1
  36. package/_modules/themes/five/src/components/ProfessionalProfile/index.js +1 -1
  37. package/_modules/themes/five/src/components/ServiceForm/index.js +136 -24
  38. package/_modules/themes/five/src/components/ServiceForm/styles.js +45 -3
  39. package/_modules/themes/four/src/components/LoginForm/index.js +64 -20
  40. package/_modules/themes/four/src/components/LoginForm/styles.js +5 -3
  41. package/_modules/themes/four/src/components/SignUpForm/index.js +67 -22
  42. package/_modules/themes/four/src/components/SignUpForm/styles.js +5 -3
  43. package/_modules/themes/franchise/src/components/LoginForm/index.js +61 -20
  44. package/_modules/themes/franchise/src/components/SignUpForm/index.js +57 -16
  45. package/_modules/themes/seven/src/components/LoginForm/index.js +60 -17
  46. package/_modules/themes/seven/src/components/SignUpForm/index.js +60 -19
  47. package/_modules/themes/six/src/components/LoginForm/index.js +62 -20
  48. package/_modules/themes/six/src/components/SignUpForm/index.js +58 -17
  49. package/_modules/themes/three/src/components/LoginForm/index.js +64 -20
  50. package/_modules/themes/three/src/components/LoginForm/styles.js +5 -3
  51. package/_modules/themes/three/src/components/SignUpForm/index.js +63 -18
  52. package/_modules/themes/three/src/components/SignUpForm/styles.js +5 -3
  53. package/_modules/themes/two/src/components/LoginForm/index.js +57 -17
  54. package/_modules/themes/two/src/components/SignUpForm/index.js +57 -17
  55. package/_modules/utils/index.js +56 -2
  56. package/package.json +2 -2
  57. package/src/components/BusinessInformation/index.js +8 -6
  58. package/src/components/LoginForm/index.js +32 -6
  59. package/src/components/SignUpForm/index.js +27 -2
  60. package/src/themes/callcenterOriginal/src/components/LoginForm/index.js +30 -2
  61. package/src/themes/callcenterOriginal/src/components/SignUpForm/index.js +27 -1
  62. package/src/themes/eight/src/components/LoginForm/index.js +30 -0
  63. package/src/themes/eight/src/components/SignUpForm/index.js +27 -1
  64. package/src/themes/five/src/components/BusinessController/index.js +2 -2
  65. package/src/themes/five/src/components/BusinessPreorder/index.js +6 -46
  66. package/src/themes/five/src/components/BusinessProductsListing/index.js +1 -1
  67. package/src/themes/five/src/components/Checkout/index.js +28 -3
  68. package/src/themes/five/src/components/Checkout/styles.js +30 -0
  69. package/src/themes/five/src/components/Header/index.js +7 -6
  70. package/src/themes/five/src/components/Header/styles.js +1 -3
  71. package/src/themes/five/src/components/MomentControl/index.js +1 -42
  72. package/src/themes/five/src/components/OrderDetails/OrderBillSection.js +1 -1
  73. package/src/themes/five/src/components/OrderDetails/index.js +10 -8
  74. package/src/themes/five/src/components/OrderDetails/styles.js +21 -1
  75. package/src/themes/five/src/components/PaymentOptions/index.js +25 -26
  76. package/src/themes/five/src/components/PlaceSpot/styles.js +14 -4
  77. package/src/themes/five/src/components/ProductItemAccordion/index.js +7 -3
  78. package/src/themes/five/src/components/ProductOption/index.js +1 -1
  79. package/src/themes/five/src/components/ProductOptionSubOption/index.js +1 -1
  80. package/src/themes/five/src/components/ProfessionalProfile/index.js +1 -1
  81. package/src/themes/five/src/components/ServiceForm/index.js +151 -11
  82. package/src/themes/five/src/components/ServiceForm/styles.js +148 -0
  83. package/src/themes/four/src/components/LoginForm/index.js +37 -5
  84. package/src/themes/four/src/components/LoginForm/styles.js +4 -0
  85. package/src/themes/four/src/components/SignUpForm/index.js +39 -5
  86. package/src/themes/four/src/components/SignUpForm/styles.js +4 -0
  87. package/src/themes/franchise/src/components/LoginForm/index.js +26 -1
  88. package/src/themes/franchise/src/components/SignUpForm/index.js +27 -1
  89. package/src/themes/seven/src/components/LoginForm/index.js +31 -0
  90. package/src/themes/seven/src/components/SignUpForm/index.js +27 -1
  91. package/src/themes/six/src/components/LoginForm/index.js +28 -1
  92. package/src/themes/six/src/components/SignUpForm/index.js +27 -1
  93. package/src/themes/three/src/components/LoginForm/index.js +38 -6
  94. package/src/themes/three/src/components/LoginForm/styles.js +4 -0
  95. package/src/themes/three/src/components/SignUpForm/index.js +40 -4
  96. package/src/themes/three/src/components/SignUpForm/styles.js +4 -0
  97. package/src/themes/two/src/components/LoginForm/index.js +25 -1
  98. package/src/themes/two/src/components/SignUpForm/index.js +28 -3
  99. package/src/utils/index.js +53 -0
  100. package/template/app.js +15 -3
  101. package/template/config.json +1 -0
  102. package/template/pages/BusinessProductsList/index.js +2 -2
  103. package/_bundles/ordering-ui.7635bd47ae9a481b3f59.js +0 -2
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.verifyDecimals = exports.sortInputFields = exports.shape = exports.scrollTo = exports.reviewCommentList = exports.priceList = exports.lightenDarkenColor = exports.getTraduction = exports.getIconCard = exports.getHourMin = exports.getGoogleMapImage = exports.getDistance = exports.formatUrlVideo = exports.formatSeconds = exports.flatArray = exports.fieldsToSort = exports.convertToRadian = exports.convertHoursToMinutes = exports.checkSiteUrl = exports.capitalize = exports.bytesConverter = void 0;
6
+ exports.verifyDecimals = exports.sortInputFields = exports.shape = exports.scrollTo = exports.reviewCommentList = exports.priceList = exports.lightenDarkenColor = exports.getTraduction = exports.getTimes = exports.getIconCard = exports.getHourMin = exports.getGoogleMapImage = exports.getDistance = exports.formatUrlVideo = exports.formatSeconds = exports.flatArray = exports.fieldsToSort = exports.convertToRadian = exports.convertHoursToMinutes = exports.checkSiteUrl = exports.capitalize = exports.bytesConverter = void 0;
7
7
  var _orderingComponentsExternal = require("ordering-components-external");
8
8
  var _styledComponents = require("styled-components");
9
9
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -332,9 +332,63 @@ var shape = {
332
332
  };
333
333
 
334
334
  /**
335
- * List of price to filter businesses
335
+ * Function to get formatted time list
336
+ * @param {*} selectedDate = selected Date
337
+ * @param {*} schedule = schedule list
338
+ * @param {*} is12Hours = variable for time format
336
339
  */
337
340
  exports.shape = shape;
341
+ var getTimes = function getTimes(selectedDate, schedule, is12Hours) {
342
+ var date = new Date();
343
+ var times = [];
344
+ for (var k = 0; k < schedule[selectedDate.getDay()].lapses.length; k++) {
345
+ var open = {
346
+ hour: schedule[selectedDate.getDay()].lapses[k].open.hour,
347
+ minute: schedule[selectedDate.getDay()].lapses[k].open.minute
348
+ };
349
+ var close = {
350
+ hour: schedule[selectedDate.getDay()].lapses[k].close.hour,
351
+ minute: schedule[selectedDate.getDay()].lapses[k].close.minute
352
+ };
353
+ for (var i = open.hour; i <= close.hour; i++) {
354
+ if (date.getDate() !== selectedDate.getDate() || i >= date.getHours()) {
355
+ var hour = '';
356
+ var meridian = '';
357
+ if (is12Hours) {
358
+ if (i === 0) {
359
+ hour = '12';
360
+ meridian = ' ' + 'AM';
361
+ } else if (i > 0 && i < 12) {
362
+ hour = i < 10 ? '0' + i : i;
363
+ meridian = ' ' + 'AM';
364
+ } else if (i === 12) {
365
+ hour = '12';
366
+ meridian = ' ' + 'PM';
367
+ } else {
368
+ hour = i - 12 < 10 ? '0' + (i - 12) : "".concat(i - 12);
369
+ meridian = ' ' + 'PM';
370
+ }
371
+ } else {
372
+ hour = i < 10 ? '0' + i : i;
373
+ }
374
+ for (var j = i === open.hour ? open.minute : 0; j <= (i === close.hour ? close.minute : 59); j += 15) {
375
+ if (i !== date.getHours() || j >= date.getMinutes() || date.getDate() !== selectedDate.getDate()) {
376
+ times.push({
377
+ text: hour + ':' + (j < 10 ? '0' + j : j) + meridian,
378
+ value: (i < 10 ? '0' + i : i) + ':' + (j < 10 ? '0' + j : j)
379
+ });
380
+ }
381
+ }
382
+ }
383
+ }
384
+ }
385
+ return times;
386
+ };
387
+
388
+ /**
389
+ * List of price to filter businesses
390
+ */
391
+ exports.getTimes = getTimes;
338
392
  var priceList = [{
339
393
  level: '1',
340
394
  content: '$'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-external",
3
- "version": "1.6.8",
3
+ "version": "1.7.0",
4
4
  "description": "Ordering UI Components",
5
5
  "main": "./_modules/index.js",
6
6
  "exports": {
@@ -85,7 +85,7 @@
85
85
  "libphonenumber-js": "^1.9.4",
86
86
  "lodash": "^4.17.19",
87
87
  "moment": "^2.29.4",
88
- "ordering-components-external": "1.5.3",
88
+ "ordering-components-external": "1.6.0",
89
89
  "polished": "^3.6.6",
90
90
  "react-bootstrap-icons": "^1.7.2",
91
91
  "react-calendar": "^3.3.1",
@@ -43,6 +43,7 @@ import FiClock from '@meronex/icons/fi/FiClock'
43
43
  import GrLocation from '@meronex/icons/gr/GrLocation'
44
44
  import MdClose from '@meronex/icons/md/MdClose'
45
45
  import { AutoScroll } from '../AutoScroll'
46
+ import moment from 'moment/moment'
46
47
 
47
48
  export const BusinessInformationUI = (props) => {
48
49
  const {
@@ -74,10 +75,11 @@ export const BusinessInformationUI = (props) => {
74
75
  const [{ parsePrice, parseDistance }] = useUtils()
75
76
  const [modalImage, setModalImage] = useState(false)
76
77
  const [image, setImage] = useState('')
78
+ const timeFormat = configs?.format_time?.value
77
79
 
78
- const scheduleFormatted = ({ hour, minute }) => {
79
- const checkTime = (val) => val < 10 ? `0${val}` : val
80
- return `${checkTime(hour)}:${checkTime(minute)}`
80
+ const timeOptions = {
81
+ 12: 'hh:mm a',
82
+ 24: 'HH:mm'
81
83
  }
82
84
 
83
85
  const handleModalImage = (src) => {
@@ -214,14 +216,14 @@ export const BusinessInformationUI = (props) => {
214
216
  <ScheduleBlock key={i}>
215
217
  <h4>{daysOfWeek[i]}</h4>
216
218
  {schedule.enabled ? (
217
- schedule.lapses.map( (time, k) => (
219
+ schedule.lapses.map((time, k) => (
218
220
  <React.Fragment key={k}>
219
- <p>{scheduleFormatted(time.open)}</p>
221
+ <p>{moment(time.open).format(timeOptions[timeFormat])}</p>
220
222
  <p style={{
221
223
  borderBottom: '2px solid',
222
224
  borderBottomColor: theme.colors.primary,
223
225
  marginBottom: 10
224
- }} >{scheduleFormatted(time.close)}</p>
226
+ }} >{moment(time.close).format(timeOptions[timeFormat])}</p>
225
227
  </React.Fragment>
226
228
  ))
227
229
  ) : (
@@ -36,6 +36,7 @@ import { FacebookLoginButton } from '../FacebookLogin'
36
36
  import { AppleLogin } from '../AppleLogin'
37
37
  import { SmsLoginButton } from '../SmsLogin'
38
38
  import { useCountdownTimer } from '../../hooks/useCountdownTimer'
39
+ import { useRecaptcha } from '../../hooks/useRecaptcha'
39
40
  import { formatSeconds } from '../../utils'
40
41
  import { useTheme } from 'styled-components'
41
42
  import parsePhoneNumber from 'libphonenumber-js'
@@ -68,7 +69,9 @@ const LoginFormUI = (props) => {
68
69
  const [, t] = useLanguage()
69
70
  const [{ configs }] = useConfig()
70
71
  const formMethods = useForm()
72
+ const [recaptchaConfig] = useRecaptcha(enableReCaptcha)
71
73
  const [alertState, setAlertState] = useState({ open: false, content: [] })
74
+ const [reCaptchaVersion, setRecaptchaVersion] = useState({ version: '', siteKey: '' })
72
75
  const [, { login }] = useSession()
73
76
  const theme = useTheme()
74
77
  const [passwordSee, setPasswordSee] = useState(false)
@@ -190,6 +193,21 @@ const LoginFormUI = (props) => {
190
193
 
191
194
  useEffect(() => {
192
195
  if (!formState.loading && formState.result?.error) {
196
+ if (formState.result?.result?.[0] === 'ERROR_AUTH_VERIFICATION_CODE') {
197
+ if (configs?.security_recaptcha_site_key?.value) {
198
+ setRecaptchaVersion({ version: 'v2', siteKey: configs?.security_recaptcha_site_key?.value })
199
+ setAlertState({
200
+ open: true,
201
+ content: [t('TRY_AGAIN', 'Please try again')]
202
+ })
203
+ return
204
+ }
205
+ setAlertState({
206
+ open: true,
207
+ content: [t('CONFIG_DOESNOT_RECAPTCHA_KEY', 'the config doesn\'t have recaptcha site key')]
208
+ })
209
+ return
210
+ }
193
211
  setAlertState({
194
212
  open: true,
195
213
  content: formState.result?.result || [t('ERROR', 'Error')]
@@ -257,6 +275,12 @@ const LoginFormUI = (props) => {
257
275
  } else { resetOtpLeftTime() }
258
276
  }, [verifyPhoneState])
259
277
 
278
+ useEffect(() => {
279
+ if (recaptchaConfig?.siteKey) {
280
+ setRecaptchaVersion({ version: recaptchaConfig?.version, siteKey: recaptchaConfig?.siteKey })
281
+ }
282
+ }, [recaptchaConfig])
283
+
260
284
  return (
261
285
  <>
262
286
  {props.beforeElements?.map((BeforeElement, i) => (
@@ -418,7 +442,7 @@ const LoginFormUI = (props) => {
418
442
  )}
419
443
  {props.isRecaptchaEnable && enableReCaptcha && (
420
444
  <ReCaptchaWrapper>
421
- <ReCaptcha handleReCaptcha={handleReCaptcha} />
445
+ <ReCaptcha handleReCaptcha={handleReCaptcha} reCaptchaVersion={reCaptchaVersion} />
422
446
  </ReCaptchaWrapper>
423
447
  )}
424
448
  {(!willVerifyOtpState &&
@@ -483,11 +507,12 @@ const LoginFormUI = (props) => {
483
507
  )}
484
508
  {useLoginByCellphone && loginTab === 'cellphone' &&
485
509
  configs && Object.keys(configs).length > 0 && (configs?.twilio_service_enabled?.value === 'true' ||
486
- configs?.twilio_service_enabled?.value === '1') && (
487
- <SmsLoginButton
488
- handleSmsLogin={() => { setLoginWithOtpState(true) }}
489
- />
490
- )}
510
+ configs?.twilio_service_enabled?.value === '1') &&
511
+ (
512
+ <SmsLoginButton
513
+ handleSmsLogin={() => { setLoginWithOtpState(true) }}
514
+ />
515
+ )}
491
516
  </SocialButtons>
492
517
  ) : (
493
518
  <SkeletonSocialWrapper>
@@ -523,6 +548,7 @@ const LoginFormUI = (props) => {
523
548
  export const LoginForm = (props) => {
524
549
  const loginControllerProps = {
525
550
  ...props,
551
+ isRecaptchaEnable: true,
526
552
  UIComponent: LoginFormUI
527
553
  }
528
554
  return <LoginFormController {...loginControllerProps} />
@@ -40,7 +40,7 @@ import { useTheme } from 'styled-components'
40
40
  import AiOutlineEye from '@meronex/icons/ai/AiOutlineEye'
41
41
  import AiOutlineEyeInvisible from '@meronex/icons/ai/AiOutlineEyeInvisible'
42
42
  import { sortInputFields } from '../../utils'
43
-
43
+ import { useRecaptcha } from '../../hooks/useRecaptcha'
44
44
  const notValidationFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'address_notes']
45
45
 
46
46
  const SignUpFormUI = (props) => {
@@ -66,6 +66,8 @@ const SignUpFormUI = (props) => {
66
66
  const [{ configs }] = useConfig()
67
67
  const formMethods = useForm()
68
68
  const [alertState, setAlertState] = useState({ open: false, content: [] })
69
+ const [recaptchaConfig] = useRecaptcha(enableReCaptcha)
70
+ const [reCaptchaVersion, setRecaptchaVersion] = useState({ version: '', siteKey: '' })
69
71
  const [, { login }] = useSession()
70
72
  const theme = useTheme()
71
73
  const emailInput = useRef(null)
@@ -185,6 +187,22 @@ const SignUpFormUI = (props) => {
185
187
 
186
188
  useEffect(() => {
187
189
  if (!formState.loading && formState.result?.error) {
190
+ if (formState.result?.result?.[0] === 'ERROR_AUTH_VERIFICATION_CODE') {
191
+ if (configs?.security_recaptcha_site_key?.value) {
192
+ setRecaptchaVersion({ version: 'v2', siteKey: configs?.security_recaptcha_site_key?.value })
193
+ setAlertState({
194
+ open: true,
195
+ content: [t('TRY_AGAIN', 'Please try again')]
196
+ })
197
+ return
198
+ }
199
+ setAlertState({
200
+ open: true,
201
+ content: [t('CONFIG_DOESNOT_RECAPTCHA_KEY', 'the config doesn\'t have recaptcha site key')]
202
+ })
203
+ return
204
+ }
205
+
188
206
  setAlertState({
189
207
  open: true,
190
208
  content: formState.result?.result || [t('ERROR', 'Error')]
@@ -240,6 +258,12 @@ const SignUpFormUI = (props) => {
240
258
  }
241
259
  }, [externalPhoneNumber])
242
260
 
261
+ useEffect(() => {
262
+ if (recaptchaConfig?.siteKey) {
263
+ setRecaptchaVersion({ version: recaptchaConfig?.version, siteKey: recaptchaConfig?.siteKey })
264
+ }
265
+ }, [recaptchaConfig])
266
+
243
267
  return (
244
268
  <>
245
269
  {props.beforeElements?.map((BeforeElement, i) => (
@@ -377,7 +401,7 @@ const SignUpFormUI = (props) => {
377
401
  }
378
402
  {props.isRecaptchaEnable && enableReCaptcha && (
379
403
  <ReCaptchaWrapper>
380
- <ReCaptcha handleReCaptcha={handleReCaptcha} />
404
+ <ReCaptcha handleReCaptcha={handleReCaptcha} reCaptchaVersion={reCaptchaVersion} />
381
405
  </ReCaptchaWrapper>
382
406
  )}
383
407
 
@@ -478,6 +502,7 @@ const SignUpFormUI = (props) => {
478
502
  export const SignUpForm = (props) => {
479
503
  const loginControllerProps = {
480
504
  ...props,
505
+ isRecaptchaEnable: true,
481
506
  UIComponent: SignUpFormUI
482
507
  }
483
508
  return <SignUpController {...loginControllerProps} />
@@ -8,6 +8,7 @@ import {
8
8
  LoginForm as LoginFormController,
9
9
  useLanguage,
10
10
  ReCaptcha,
11
+ useConfig,
11
12
  useApi
12
13
  } from 'ordering-components-external'
13
14
 
@@ -41,6 +42,7 @@ import { Tabs, Tab } from '../../styles/Tabs'
41
42
  import { Input } from '../../styles/Inputs'
42
43
  import { Button } from '../../styles/Buttons'
43
44
  import { useCountdownTimer } from '../../../../../hooks/useCountdownTimer'
45
+ import { useRecaptcha } from '../../../../../hooks/useRecaptcha'
44
46
  import { formatSeconds } from '../../../../../utils'
45
47
  import { Alert } from '../Confirm'
46
48
  import { SpinnerLoader } from '../../../../../components/SpinnerLoader'
@@ -69,10 +71,12 @@ const LoginFormUI = (props) => {
69
71
  const numOtpInputs = 4
70
72
 
71
73
  const [ordering, { setOrdering }] = useApi()
74
+ const [{ configs }] = useConfig()
72
75
  const [, t] = useLanguage()
73
76
  const theme = useTheme()
74
77
  const formMethods = useForm()
75
-
78
+ const [recaptchaConfig] = useRecaptcha(enableReCaptcha)
79
+ const [reCaptchaVersion, setRecaptchaVersion] = useState({ version: '', siteKey: '' })
76
80
  const emailInput = useRef(null)
77
81
 
78
82
  const [alertState, setAlertState] = useState({ open: false, content: [] })
@@ -171,6 +175,23 @@ const LoginFormUI = (props) => {
171
175
 
172
176
  useEffect(() => {
173
177
  if (!formState.loading && formState.result?.error) {
178
+ if (formState.result?.result?.[0] === 'ERROR_AUTH_VERIFICATION_CODE') {
179
+ if (configs?.security_recaptcha_site_key?.value) {
180
+ setRecaptchaVersion({ version: 'v2', siteKey: configs?.security_recaptcha_site_key?.value })
181
+ setAlertState({
182
+ open: true,
183
+ content: [t('TRY_AGAIN', 'Please try again')]
184
+ })
185
+ setSubmitted(false)
186
+ return
187
+ }
188
+ setAlertState({
189
+ open: true,
190
+ content: [t('CONFIG_DOESNOT_RECAPTCHA_KEY', 'the config doesn\'t have recaptcha site key')]
191
+ })
192
+ setSubmitted(false)
193
+ return
194
+ }
174
195
  setAlertState({
175
196
  open: true,
176
197
  content: formState.result?.result || [t('ERROR', 'Error')]
@@ -249,6 +270,12 @@ const LoginFormUI = (props) => {
249
270
  handleButtonLoginClick()
250
271
  }, [ordering, submitted])
251
272
 
273
+ useEffect(() => {
274
+ if (recaptchaConfig?.siteKey) {
275
+ setRecaptchaVersion({ version: recaptchaConfig?.version, siteKey: recaptchaConfig?.siteKey })
276
+ }
277
+ }, [recaptchaConfig])
278
+
252
279
  return (
253
280
  <LoginContainer isPopup={isPopup}>
254
281
  <HeroSide>
@@ -405,7 +432,7 @@ const LoginFormUI = (props) => {
405
432
  )}
406
433
  {props.isRecaptchaEnable && enableReCaptcha && (
407
434
  <ReCaptchaWrapper>
408
- <ReCaptcha handleReCaptcha={handleReCaptcha} />
435
+ <ReCaptcha handleReCaptcha={handleReCaptcha} reCaptchaVersion={reCaptchaVersion} />
409
436
  </ReCaptchaWrapper>
410
437
  )}
411
438
  <ButtonContainer>
@@ -455,6 +482,7 @@ const LoginFormUI = (props) => {
455
482
  export const LoginForm = (props) => {
456
483
  const loginControllerProps = {
457
484
  ...props,
485
+ isRecaptchaEnable: true,
458
486
  UIComponent: LoginFormUI
459
487
  }
460
488
  return <LoginFormController {...loginControllerProps} />
@@ -31,6 +31,7 @@ import { Input } from '../../styles/Inputs'
31
31
  import { Button } from '../../styles/Buttons'
32
32
  import { Checkbox } from '../../../../../styles/Checkbox'
33
33
  import { sortInputFields } from '../../../../../utils'
34
+ import { useRecaptcha } from '../../../../../hooks/useRecaptcha'
34
35
 
35
36
  import {
36
37
  Person,
@@ -66,6 +67,8 @@ const SignUpFormUI = (props) => {
66
67
  const formMethods = useForm()
67
68
  const [alertState, setAlertState] = useState({ open: false, content: [] })
68
69
  const emailInput = useRef(null)
70
+ const [recaptchaConfig] = useRecaptcha(enableReCaptcha)
71
+ const [reCaptchaVersion, setRecaptchaVersion] = useState({ version: '', siteKey: '' })
69
72
 
70
73
  const [userPhoneNumber, setUserPhoneNumber] = useState('')
71
74
  const [isValidPhoneNumber, setIsValidPhoneNumber] = useState(null)
@@ -152,6 +155,22 @@ const SignUpFormUI = (props) => {
152
155
 
153
156
  useEffect(() => {
154
157
  if (!formState.loading && formState.result?.error) {
158
+ if (formState.result?.result?.[0] === 'ERROR_AUTH_VERIFICATION_CODE') {
159
+ if (configs?.security_recaptcha_site_key?.value) {
160
+ setRecaptchaVersion({ version: 'v2', siteKey: configs?.security_recaptcha_site_key?.value })
161
+ setAlertState({
162
+ open: true,
163
+ content: [t('TRY_AGAIN', 'Please try again')]
164
+ })
165
+ return
166
+ }
167
+ setAlertState({
168
+ open: true,
169
+ content: [t('CONFIG_DOESNOT_RECAPTCHA_KEY', 'the config doesn\'t have recaptcha site key')]
170
+ })
171
+ return
172
+ }
173
+
155
174
  setAlertState({
156
175
  open: true,
157
176
  content: formState.result?.result || [t('ERROR', 'Error')]
@@ -216,6 +235,12 @@ const SignUpFormUI = (props) => {
216
235
  setFieldNumber(fieldnum)
217
236
  }, [validationFields])
218
237
 
238
+ useEffect(() => {
239
+ if (recaptchaConfig?.siteKey) {
240
+ setRecaptchaVersion({ version: recaptchaConfig?.version, siteKey: recaptchaConfig?.siteKey })
241
+ }
242
+ }, [recaptchaConfig])
243
+
219
244
  return (
220
245
  <>
221
246
  {props.beforeElements?.map((BeforeElement, i) => (
@@ -339,7 +364,7 @@ const SignUpFormUI = (props) => {
339
364
  }
340
365
  {props.isRecaptchaEnable && enableReCaptcha && (
341
366
  <ReCaptchaWrapper>
342
- <ReCaptcha handleReCaptcha={handleReCaptcha} />
367
+ <ReCaptcha handleReCaptcha={handleReCaptcha} reCaptchaVersion={reCaptchaVersion} />
343
368
  </ReCaptchaWrapper>
344
369
  )}
345
370
 
@@ -406,6 +431,7 @@ const SignUpFormUI = (props) => {
406
431
  export const SignUpForm = (props) => {
407
432
  const loginControllerProps = {
408
433
  ...props,
434
+ isRecaptchaEnable: true,
409
435
  UIComponent: SignUpFormUI
410
436
  }
411
437
  return <SignUpController {...loginControllerProps} />
@@ -24,6 +24,7 @@ import { Alert } from '../../../../../components/Confirm'
24
24
  import { SpinnerLoader } from '../../../../../components/SpinnerLoader'
25
25
  import { SmsLoginButton } from '../../../../../components/SmsLogin'
26
26
  import { useCountdownTimer } from '../../../../../hooks/useCountdownTimer'
27
+ import { useRecaptcha } from '../../../../../hooks/useRecaptcha'
27
28
  import { formatSeconds } from '../../../../../utils'
28
29
 
29
30
  import {
@@ -68,6 +69,8 @@ const LoginFormUI = (props) => {
68
69
  const [, t] = useLanguage()
69
70
  const [{ configs }] = useConfig()
70
71
  const formMethods = useForm()
72
+ const [recaptchaConfig] = useRecaptcha(enableReCaptcha)
73
+ const [reCaptchaVersion, setRecaptchaVersion] = useState({ version: '', siteKey: '' })
71
74
  const [alertState, setAlertState] = useState({ open: false, content: [] })
72
75
  const [, { login }] = useSession()
73
76
  const theme = useTheme()
@@ -177,6 +180,21 @@ const LoginFormUI = (props) => {
177
180
 
178
181
  useEffect(() => {
179
182
  if (!formState.loading && formState.result?.error) {
183
+ if (formState.result?.result?.[0] === 'ERROR_AUTH_VERIFICATION_CODE') {
184
+ if (configs?.security_recaptcha_site_key?.value) {
185
+ setRecaptchaVersion({ version: 'v2', siteKey: configs?.security_recaptcha_site_key?.value })
186
+ setAlertState({
187
+ open: true,
188
+ content: [t('TRY_AGAIN', 'Please try again')]
189
+ })
190
+ return
191
+ }
192
+ setAlertState({
193
+ open: true,
194
+ content: [t('CONFIG_DOESNOT_RECAPTCHA_KEY', 'the config doesn\'t have recaptcha site key')]
195
+ })
196
+ return
197
+ }
180
198
  setAlertState({
181
199
  open: true,
182
200
  content: formState.result?.result || [t('ERROR', 'Error')]
@@ -244,6 +262,12 @@ const LoginFormUI = (props) => {
244
262
  } else { resetOtpLeftTime() }
245
263
  }, [verifyPhoneState])
246
264
 
265
+ useEffect(() => {
266
+ if (recaptchaConfig?.siteKey) {
267
+ setRecaptchaVersion({ version: recaptchaConfig?.version, siteKey: recaptchaConfig?.siteKey })
268
+ }
269
+ }, [recaptchaConfig])
270
+
247
271
  return (
248
272
  <>
249
273
  {props.beforeElements?.map((BeforeElement, i) => (
@@ -427,6 +451,11 @@ const LoginFormUI = (props) => {
427
451
  props.afterMidComponents?.map((MidComponent, i) => (
428
452
  <MidComponent key={i} {...props} />))
429
453
  }
454
+ {props.isRecaptchaEnable && enableReCaptcha && (
455
+ <ReCaptchaWrapper>
456
+ <ReCaptcha handleReCaptcha={handleReCaptcha} reCaptchaVersion={reCaptchaVersion} />
457
+ </ReCaptchaWrapper>
458
+ )}
430
459
  {!loginWithOtpState && (
431
460
  <RedirectLink isPopup={isPopup}>
432
461
  {elementLinkToForgotPassword}
@@ -495,6 +524,7 @@ const LoginFormUI = (props) => {
495
524
  export const LoginForm = (props) => {
496
525
  const loginControllerProps = {
497
526
  ...props,
527
+ isRecaptchaEnable: true,
498
528
  UIComponent: LoginFormUI
499
529
  }
500
530
  return <LoginFormController {...loginControllerProps} />
@@ -38,6 +38,7 @@ import {
38
38
 
39
39
  import { Alert } from '../../../../../components/Confirm'
40
40
  import { sortInputFields } from '../../../../../utils'
41
+ import { useRecaptcha } from '../../../../../hooks/useRecaptcha'
41
42
 
42
43
  const notValidationFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'address_notes']
43
44
 
@@ -64,6 +65,8 @@ const SignUpFormUI = (props) => {
64
65
  const [{ configs }] = useConfig()
65
66
  const formMethods = useForm()
66
67
  const [alertState, setAlertState] = useState({ open: false, content: [] })
68
+ const [recaptchaConfig] = useRecaptcha(enableReCaptcha)
69
+ const [reCaptchaVersion, setRecaptchaVersion] = useState({ version: '', siteKey: '' })
67
70
  const [, { login }] = useSession()
68
71
  const emailInput = useRef(null)
69
72
  const isFacebookLogin = configs?.facebook_login?.value === 'true'
@@ -182,6 +185,22 @@ const SignUpFormUI = (props) => {
182
185
 
183
186
  useEffect(() => {
184
187
  if (!formState.loading && formState.result?.error) {
188
+ if (formState.result?.result?.[0] === 'ERROR_AUTH_VERIFICATION_CODE') {
189
+ if (configs?.security_recaptcha_site_key?.value) {
190
+ setRecaptchaVersion({ version: 'v2', siteKey: configs?.security_recaptcha_site_key?.value })
191
+ setAlertState({
192
+ open: true,
193
+ content: [t('TRY_AGAIN', 'Please try again')]
194
+ })
195
+ return
196
+ }
197
+ setAlertState({
198
+ open: true,
199
+ content: [t('CONFIG_DOESNOT_RECAPTCHA_KEY', 'the config doesn\'t have recaptcha site key')]
200
+ })
201
+ return
202
+ }
203
+
185
204
  setAlertState({
186
205
  open: true,
187
206
  content: formState.result?.result || [t('ERROR', 'Error')]
@@ -237,6 +256,12 @@ const SignUpFormUI = (props) => {
237
256
  }
238
257
  }, [externalPhoneNumber])
239
258
 
259
+ useEffect(() => {
260
+ if (recaptchaConfig?.siteKey) {
261
+ setRecaptchaVersion({ version: recaptchaConfig?.version, siteKey: recaptchaConfig?.siteKey })
262
+ }
263
+ }, [recaptchaConfig])
264
+
240
265
  return (
241
266
  <>
242
267
  {props.beforeElements?.map((BeforeElement, i) => (
@@ -434,7 +459,7 @@ const SignUpFormUI = (props) => {
434
459
  }
435
460
  {props.isRecaptchaEnable && enableReCaptcha && (
436
461
  <ReCaptchaWrapper>
437
- <ReCaptcha handleReCaptcha={handleReCaptcha} />
462
+ <ReCaptcha handleReCaptcha={handleReCaptcha} reCaptchaVersion={reCaptchaVersion} />
438
463
  </ReCaptchaWrapper>
439
464
  )}
440
465
 
@@ -508,6 +533,7 @@ const SignUpFormUI = (props) => {
508
533
  export const SignUpForm = (props) => {
509
534
  const loginControllerProps = {
510
535
  ...props,
536
+ isRecaptchaEnable: true,
511
537
  UIComponent: SignUpFormUI
512
538
  }
513
539
  return <SignUpController {...loginControllerProps} />
@@ -153,8 +153,8 @@ const BusinessControllerUI = (props) => {
153
153
  {business?.ribbon?.enabled && (
154
154
  <RibbonBox
155
155
  bgColor={business?.ribbon?.color}
156
- colorText={lightenDarkenColor(business?.ribbon?.color, -200)}
157
- borderRibbon={lightenDarkenColor(business?.ribbon?.color, -200)}
156
+ colorText={lightenDarkenColor(business?.ribbon?.color)}
157
+ borderRibbon={lightenDarkenColor(business?.ribbon?.color)}
158
158
  isRoundRect={business?.ribbon?.shape === shape?.rectangleRound}
159
159
  isCapsule={business?.ribbon?.shape === shape?.capsuleShape}
160
160
  >