ordering-ui-react-native 0.16.40 → 0.16.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.16.40",
3
+ "version": "0.16.41",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -165,6 +165,12 @@ const LoginFormUI = (props: LoginParams) => {
165
165
 
166
166
  const handleOpenRecaptcha = () => {
167
167
  setRecaptchaVerified(false)
168
+
169
+ if (recaptchaVerified) {
170
+ handleReCaptcha && handleReCaptcha('')
171
+ return
172
+ }
173
+
168
174
  if (!recaptchaConfig?.siteKey) {
169
175
  showToast(ToastType.Error, t('NO_RECAPTCHA_SITE_KEY', 'The config doesn\'t have recaptcha site key'));
170
176
  return
@@ -385,6 +391,15 @@ const LoginFormUI = (props: LoginParams) => {
385
391
  baseUrl={recaptchaConfig?.baseUrl}
386
392
  onVerify={onRecaptchaVerify}
387
393
  onExpire={() => setRecaptchaVerified(false)}
394
+ footerComponent={<OButton
395
+ onClick={() => recaptchaRef.current.close()}
396
+ style={{ borderRadius: 0 }}
397
+ text={t('CLOSE', 'Close')}
398
+ bgColor={theme.colors.primary}
399
+ borderColor={theme.colors.primary}
400
+ textStyle={{ color: 'white' }}
401
+ imgRightSrc={null}
402
+ />}
388
403
  />
389
404
  </>
390
405
  )}
@@ -245,6 +245,12 @@ const SignupFormUI = (props: SignupParams) => {
245
245
 
246
246
  const handleOpenRecaptcha = () => {
247
247
  setRecaptchaVerified(false)
248
+
249
+ if (recaptchaVerified) {
250
+ handleReCaptcha && handleReCaptcha('')
251
+ return
252
+ }
253
+
248
254
  if (!recaptchaConfig?.siteKey) {
249
255
  showToast(ToastType.Error, t('NO_RECAPTCHA_SITE_KEY', 'The config doesn\'t have recaptcha site key'));
250
256
  return
@@ -555,6 +561,15 @@ const SignupFormUI = (props: SignupParams) => {
555
561
  baseUrl={recaptchaConfig?.baseUrl}
556
562
  onVerify={onRecaptchaVerify}
557
563
  onExpire={() => setRecaptchaVerified(false)}
564
+ footerComponent={<OButton
565
+ onClick={() => recaptchaRef.current.close()}
566
+ style={{ borderRadius: 0 }}
567
+ text={t('CLOSE', 'Close')}
568
+ bgColor={theme.colors.primary}
569
+ borderColor={theme.colors.primary}
570
+ textStyle={{ color: 'white' }}
571
+ imgRightSrc={null}
572
+ />}
558
573
  />
559
574
  </>
560
575
  )}
@@ -94,7 +94,8 @@ export const BusinessBasicInformation = (
94
94
  height: 20,
95
95
  justifyContent: 'center',
96
96
  alignItems: 'center',
97
- marginLeft: 5
97
+ marginRight: 5,
98
+ marginBottom: 7
98
99
  },
99
100
  tiktokIcon: {
100
101
  height: 12,
@@ -238,53 +239,6 @@ export const BusinessBasicInformation = (
238
239
  </OText>
239
240
  </RibbonBox>
240
241
  )}
241
- <SocialListWrapper
242
- showsVerticalScrollIndicator={false}
243
- showsHorizontalScrollIndicator={false}
244
- horizontal
245
- contentContainerStyle={{ flex: 1, justifyContent: 'flex-end'}}
246
- >
247
- {!!business?.facebook_profile && (
248
- <SocialNetWork
249
- socialLink={business?.facebook_profile}
250
- iconTitle='facebook'
251
- />
252
- )}
253
- {!!business?.instagram_profile && (
254
- <SocialNetWork
255
- socialLink={business?.instagram_profile}
256
- iconTitle='instagram'
257
- />
258
- )}
259
- {!!business?.tiktok_profile && (
260
- <TouchableOpacity style={styles.socialIcon} onPress={() => Linking.openURL(business?.tiktok_profile)}>
261
- <View style={styles.tiktokIcon}>
262
- <OIcon
263
- src={theme.images.general.tiktok}
264
- style={{ width: '100%', height: '100%'}}
265
- />
266
- </View>
267
- </TouchableOpacity>
268
- )}
269
- {!!business?.pinterest_profile && (
270
- <SocialNetWork
271
- socialLink={business?.pinterest_profile}
272
- iconTitle='pinterest'
273
- />
274
- )}
275
- {!!business?.whatsapp_number && (
276
- <SocialNetWork
277
- socialLink={business?.whatsapp_number}
278
- iconTitle='whatsapp'
279
- />
280
- )}
281
- {!!business?.snapchat_profile && (
282
- <SocialNetWork
283
- socialLink={business?.snapchat_profile}
284
- iconTitle='snapchat'
285
- />
286
- )}
287
- </SocialListWrapper>
288
242
  </TitleWrapper>
289
243
  )}
290
244
  </BusinessInfoItem>
@@ -297,6 +251,65 @@ export const BusinessBasicInformation = (
297
251
  <OText color={theme.colors.textNormal}>{getBusinessType()}</OText>
298
252
  </View>
299
253
  )}
254
+ {loading ? (
255
+ <Placeholder Animation={Fade}>
256
+ <View style={{ flexDirection: 'row' }}>
257
+ {[...Array(5).keys()].map(i => (
258
+ <View style={styles.socialIcon} key={i}>
259
+ <PlaceholderLine width={100} height={20} style={{ marginBottom: 0 }} />
260
+ </View>
261
+ ))}
262
+ </View>
263
+ </Placeholder>
264
+ ) : (
265
+ <SocialListWrapper
266
+ showsVerticalScrollIndicator={false}
267
+ showsHorizontalScrollIndicator={false}
268
+ horizontal
269
+ contentContainerStyle={{ flex: 1}}
270
+ >
271
+ {!!business?.facebook_profile && (
272
+ <SocialNetWork
273
+ socialLink={business?.facebook_profile}
274
+ iconTitle='facebook'
275
+ />
276
+ )}
277
+ {!!business?.instagram_profile && (
278
+ <SocialNetWork
279
+ socialLink={business?.instagram_profile}
280
+ iconTitle='instagram'
281
+ />
282
+ )}
283
+ {!!business?.tiktok_profile && (
284
+ <TouchableOpacity style={styles.socialIcon} onPress={() => Linking.openURL(business?.tiktok_profile)}>
285
+ <View style={styles.tiktokIcon}>
286
+ <OIcon
287
+ src={theme.images.general.tiktok}
288
+ style={{ width: '100%', height: '100%'}}
289
+ />
290
+ </View>
291
+ </TouchableOpacity>
292
+ )}
293
+ {!!business?.pinterest_profile && (
294
+ <SocialNetWork
295
+ socialLink={business?.pinterest_profile}
296
+ iconTitle='pinterest'
297
+ />
298
+ )}
299
+ {!!business?.whatsapp_number && (
300
+ <SocialNetWork
301
+ socialLink={business?.whatsapp_number}
302
+ iconTitle='whatsapp'
303
+ />
304
+ )}
305
+ {!!business?.snapchat_profile && (
306
+ <SocialNetWork
307
+ socialLink={business?.snapchat_profile}
308
+ iconTitle='snapchat'
309
+ />
310
+ )}
311
+ </SocialListWrapper>
312
+ )}
300
313
  <View>
301
314
  <BusinessInfoItem>
302
315
  {loading && (
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import {
3
3
  BusinessReviews as BusinessReviewController,
4
4
  useLanguage,
@@ -22,6 +22,7 @@ import {
22
22
  import { BusinessReviewsParams } from '../../types';
23
23
  import { ProgressBar, TouchableRipple } from 'react-native-paper';
24
24
  import moment from 'moment';
25
+ import { setLocalMoment } from '../../utils';
25
26
 
26
27
  const BusinessReviewsUI = (props: BusinessReviewsParams) => {
27
28
  const { businessState, reviewsList } = props;
@@ -99,6 +100,10 @@ const BusinessReviewsUI = (props: BusinessReviewsParams) => {
99
100
  </View>
100
101
  );
101
102
 
103
+ useEffect(() => {
104
+ setLocalMoment(moment, t)
105
+ }, [])
106
+
102
107
  return (
103
108
  <BusinessReviewsContainer>
104
109
  <BusinessReviewContent
@@ -78,7 +78,6 @@ const SignupFormUI = (props: SignupParams) => {
78
78
  handleChangeInput,
79
79
  willVerifyOtpState,
80
80
  setOtpState,
81
- otpState,
82
81
  setSignUpTab,
83
82
  signUpTab,
84
83
  useSignUpFullDetails,
@@ -120,10 +119,9 @@ const SignupFormUI = (props: SignupParams) => {
120
119
  const [, t] = useLanguage();
121
120
  const [, { login }] = useSession();
122
121
  const [{ configs }] = useConfig();
123
- const { control, handleSubmit, errors, register, setValue } = useForm();
122
+ const { control, handleSubmit, clearErrors, errors, register, unregister, setValue } = useForm();
124
123
 
125
124
  const [passwordSee, setPasswordSee] = useState(false);
126
- const [otpErrMsg, setOtpErrMsg] = useState('')
127
125
  const [formValues, setFormValues] = useState(null);
128
126
  const [isModalVisible, setIsModalVisible] = useState(false);
129
127
  const [isLoadingVerifyModal, setIsLoadingVerifyModal] = useState(false);
@@ -238,6 +236,11 @@ const SignupFormUI = (props: SignupParams) => {
238
236
  navigation.navigate('Home');
239
237
  };
240
238
 
239
+ const handleSignUpTab = (tab: string) => {
240
+ setSignUpTab && setSignUpTab(tab)
241
+ clearErrors()
242
+ }
243
+
241
244
  const onSubmit = (values?: any) => {
242
245
  if (phoneInputData.error && signUpTab !== 'otpEmail') {
243
246
  showToast(ToastType.Error, phoneInputData.error);
@@ -344,7 +347,7 @@ const SignupFormUI = (props: SignupParams) => {
344
347
 
345
348
  const onRecaptchaVerify = (token: any) => {
346
349
  setRecaptchaVerified(true)
347
- handleReCaptcha(token)
350
+ handleReCaptcha && handleReCaptcha(token)
348
351
  }
349
352
 
350
353
  useEffect(() => {
@@ -368,15 +371,19 @@ const SignupFormUI = (props: SignupParams) => {
368
371
  if (Object.keys(errors).length > 0) {
369
372
  setIsLoadingVerifyModal(false);
370
373
  }
371
- }, [errors]);
374
+ }, [errors])
372
375
 
373
376
  useEffect(() => {
374
- register('cellphone', {
375
- required: isRequiredField('cellphone')
376
- ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
377
- : null
378
- })
379
- }, [register])
377
+ if (signUpTab === 'default' || signUpTab === 'otpCellphone') {
378
+ register('cellphone', {
379
+ required: isRequiredField('cellphone')
380
+ ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
381
+ : null
382
+ })
383
+ } else {
384
+ unregister('cellphone')
385
+ }
386
+ }, [signUpTab])
380
387
 
381
388
  useEffect(() => {
382
389
  if (phoneInputData?.phone?.cellphone) setValue('cellphone', phoneInputData?.phone?.cellphone, '')
@@ -415,9 +422,11 @@ const SignupFormUI = (props: SignupParams) => {
415
422
 
416
423
  useEffect(() => {
417
424
  if (checkPhoneCodeState?.result?.error) {
418
- setOtpErrMsg((typeof checkPhoneCodeState?.result?.result === 'string' ? checkPhoneCodeState?.result?.result : checkPhoneCodeState?.result?.result[0]) || t('ERROR', 'Error'))
419
- } else if (checkPhoneCodeState?.result?.result && checkPhoneCodeState?.result?.result?.[0] === 'VERIFICATION_CODE_WAS_SENT_TO') {
420
- setOtpErrMsg(t('CODE_SENT', 'The code has been sent'))
425
+ setAlertState({
426
+ open: true,
427
+ title: (typeof checkPhoneCodeState?.result?.result === 'string' ? checkPhoneCodeState?.result?.result : checkPhoneCodeState?.result?.result[0].toString()) || t('ERROR', 'Error'),
428
+ content: []
429
+ })
421
430
  }
422
431
  }, [checkPhoneCodeState])
423
432
 
@@ -442,7 +451,7 @@ const SignupFormUI = (props: SignupParams) => {
442
451
  ref={tabsRef}
443
452
  >
444
453
  <TabBtn
445
- onPress={() => setSignUpTab && setSignUpTab('default')}
454
+ onPress={() => handleSignUpTab('default')}
446
455
  onLayout={(event: any) => handleOnLayout(event, 'default')}
447
456
  >
448
457
  <OTab
@@ -466,7 +475,7 @@ const SignupFormUI = (props: SignupParams) => {
466
475
  </TabBtn>
467
476
  {useSignUpOtpEmail && (
468
477
  <TabBtn
469
- onPress={() => setSignUpTab && setSignUpTab('otpEmail')}
478
+ onPress={() => handleSignUpTab('otpEmail')}
470
479
  onLayout={(event: any) => handleOnLayout(event, 'otpEmail')}
471
480
  >
472
481
  <OTab
@@ -492,7 +501,7 @@ const SignupFormUI = (props: SignupParams) => {
492
501
  )}
493
502
  {useSignUpOtpCellphone && (
494
503
  <TabBtn
495
- onPress={() => setSignUpTab && setSignUpTab('otpCellphone')}
504
+ onPress={() => handleSignUpTab('otpCellphone')}
496
505
  onLayout={(event: any) => handleOnLayout(event, 'otpCellphone')}
497
506
  >
498
507
  <OTab
@@ -120,7 +120,7 @@ export interface SignupParams {
120
120
  handleChangeInput?: (in1: any, in2: any) => void;
121
121
  enableReCaptcha?: boolean;
122
122
  generateOtpCode?: (in1?: any) => void;
123
- handleReCaptcha?: () => void;
123
+ handleReCaptcha?: (token?: any) => void;
124
124
  setSignUpTab?: (in1: string) => void;
125
125
  setWillVerifyOtpState?: (in1: boolean) => void;
126
126
  setOtpState?: (in1: string) => void;
@@ -40,6 +40,72 @@ export const getTraduction = (key: string) => {
40
40
  return keyList[key] ? t(key, keyList[key]) : t(key)
41
41
  }
42
42
 
43
+ /**
44
+ * Change local moment variables
45
+ */
46
+ export const setLocalMoment = (moment : any, t : any) => {
47
+ moment.locale('custom', {
48
+ months: [
49
+ t('MONTH1','January'),
50
+ t('MONTH2','February'),
51
+ t('MONTH3','March'),
52
+ t('MONTH4','April'),
53
+ t('MONTH5','May'),
54
+ t('MONTH6','June'),
55
+ t('MONTH7','July'),
56
+ t('MONTH8','August'),
57
+ t('MONTH9','September'),
58
+ t('MONTH10','October'),
59
+ t('MONTH11','November'),
60
+ t('MONTH12','December')
61
+ ],
62
+ monthsShort: [
63
+ t('MONTHSHORT1','Jan'),
64
+ t('MONTHSHORT2','Feb'),
65
+ t('MONTHSHORT3','Mar'),
66
+ t('MONTHSHORT4','Apr'),
67
+ t('MONTHSHORT5','May'),
68
+ t('MONTHSHORT6','Jun'),
69
+ t('MONTHSHORT7','Jul'),
70
+ t('MONTHSHORT8','Aug'),
71
+ t('MONTHSHORT9','Sep'),
72
+ t('MONTHSHORT10','Oct'),
73
+ t('MONTHSHORT11','Nov'),
74
+ t('MONTHSHORT12','Dec')
75
+ ],
76
+ weekdays: [
77
+ t('DAY7','Sunday'),
78
+ t('DAY1','Monday'),
79
+ t('DAY2','Tuesday'),
80
+ t('DAY3','Wednesday'),
81
+ t('DAY4','Thursday'),
82
+ t('DAY5','Friday'),
83
+ t('DAY6','Saturday')
84
+ ],
85
+ weekdaysShort: [
86
+ t('DAYSHORT7','Sun'),
87
+ t('DAYSHORT1','Mon'),
88
+ t('DAYSHORT2','Tue'),
89
+ t('DAYSHORT3','Wed'),
90
+ t('DAYSHORT4','Thu'),
91
+ t('DAYSHORT5','Fri'),
92
+ t('DAYSHORT6','Sat')
93
+ ],
94
+ weekdaysMin: [
95
+ t('DAYMIN7','Su'),
96
+ t('DAYMIN1','Mo'),
97
+ t('DAYMIN2','Tu'),
98
+ t('DAYMIN3','We'),
99
+ t('DAYMIN4','Th'),
100
+ t('DAYMIN5','Fr'),
101
+ t('DAYMIN6','Sa')
102
+ ],
103
+ meridiem : function (hours : any) {
104
+ return hours < 12 ? t('AM', 'AM') : t('PM','PM');
105
+ }
106
+ })
107
+ }
108
+
43
109
  /**
44
110
  * Function to convert delivery time in minutes
45
111
  * @param {string} time business delivery time