ordering-ui-react-native 0.16.34 → 0.16.37

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.34",
3
+ "version": "0.16.37",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -39,6 +39,8 @@ import { VerifyPhone } from './src/components/VerifyPhone';
39
39
  import { DriverMap } from './src/components/DriverMap';
40
40
  import { MapViewUI as MapView } from './src/components/MapView'
41
41
  import { NewOrderNotification } from './src/components/NewOrderNotification';
42
+ import { DriverSchedule } from './src/components/DriverSchedule';
43
+ import { ScheduleBlocked } from './src/components/ScheduleBlocked';
42
44
  //OComponents
43
45
  import {
44
46
  OText,
@@ -106,6 +108,8 @@ export {
106
108
  UserFormDetailsUI,
107
109
  UserProfileForm,
108
110
  VerifyPhone,
111
+ DriverSchedule,
112
+ ScheduleBlocked,
109
113
  //OComponents
110
114
  OAlert,
111
115
  OButton,
@@ -0,0 +1,54 @@
1
+ import React from 'react'
2
+ import { View } from 'react-native'
3
+ import { OText } from '../shared'
4
+ import { useLanguage } from 'ordering-components/native'
5
+ import { DayContainer } from './styles'
6
+ import { useTheme } from 'styled-components/native'
7
+ export const DriverSchedule = (props : any) => {
8
+ const { schedule } = props
9
+ const [, t] = useLanguage()
10
+ const theme = useTheme()
11
+
12
+ const daysOfWeek = [
13
+ t('SUNDAY_ABBREVIATION', 'Sun'),
14
+ t('MONDAY_ABBREVIATION', 'Mon'),
15
+ t('TUESDAY_ABBREVIATION', 'Tues'),
16
+ t('WEDNESDAY_ABBREVIATION', 'Wed'),
17
+ t('THURSDAY_ABBREVIATION', 'Thur'),
18
+ t('FRIDAY_ABBREVIATION', 'Fri'),
19
+ t('SATURDAY_ABBREVIATION', 'Sat')
20
+ ]
21
+
22
+ const scheduleFormatted = ({ hour, minute }: any) => {
23
+ const checkTime = (val: number) => val < 10 ? `0${val}` : val
24
+ return `${checkTime(hour)}:${checkTime(minute)}`
25
+ }
26
+
27
+ return (
28
+ <View >
29
+ <OText size={24} style={{paddingLeft: 30}}>
30
+ {t('SCHEDULE', 'Schedule')}
31
+ </OText>
32
+ <View style={{padding: 30}}>
33
+ {schedule.map((item: any, i: number) => (
34
+ <DayContainer key={daysOfWeek[i]}>
35
+ <OText style={{width: '20%'}} size={22} weight={700}>{daysOfWeek[i]}</OText>
36
+ <View style={{width: '80%', alignItems: 'center'}}>
37
+ <>
38
+ {item?.enabled ? (
39
+ <>
40
+ {item?.lapses.map((lapse: any, i: number) => (
41
+ <OText size={18} style={{marginTop: 3, marginBottom: 20}} key={`${daysOfWeek[i]}_${i}`}>{scheduleFormatted(lapse.open)} - {scheduleFormatted(lapse.close)}</OText>
42
+ ))}
43
+ </>
44
+ ) : (
45
+ <OText size={18} style={{marginTop: 3, marginBottom: 10}} color={theme.colors.red}>{t('NOT_AVAILABLE', 'Not available')}</OText>
46
+ )}
47
+ </>
48
+ </View>
49
+ </DayContainer>
50
+ ))}
51
+ </View>
52
+ </View>
53
+ )
54
+ }
@@ -0,0 +1,6 @@
1
+ import styled from "styled-components/native";
2
+
3
+ export const DayContainer = styled.View`
4
+ flex-direction: row;
5
+ width: 100%;
6
+ `
@@ -0,0 +1,53 @@
1
+ import React from 'react'
2
+ import { Dimensions, View } from 'react-native'
3
+ import { OButton, OIcon, OText } from '../shared'
4
+ import { useLanguage, useSession } from 'ordering-components/native'
5
+ import { useTheme } from 'styled-components/native'
6
+
7
+ export const ScheduleBlocked = (props : any) => {
8
+ const { nextSchedule } = props
9
+ const [, t] = useLanguage()
10
+ const [, {logout}] = useSession()
11
+ const theme = useTheme()
12
+ const deviceWidth = Dimensions.get('screen').width
13
+
14
+ const daysOfWeek = [
15
+ t('MONDAY', 'Monday'),
16
+ t('TUESDAY', 'Tuesday'),
17
+ t('WEDNESDAY', 'Wednesday'),
18
+ t('THURSDAY', 'Thurday'),
19
+ t('FRIDAY', 'Friday'),
20
+ t('SATURDAY', 'Saturday'),
21
+ t('SUNDAY', 'Sunday')
22
+ ]
23
+
24
+ const scheduleFormatted = ({ hour, minute }: any) => {
25
+ const checkTime = (val: number) => val < 10 ? `0${val}` : val
26
+ return `${checkTime(hour)}:${checkTime(minute)}`
27
+ }
28
+
29
+ const goBack = () => {
30
+ logout()
31
+ }
32
+
33
+ return (
34
+ <View style={{ alignItems: 'center', padding: 40 }}>
35
+ <OText size={20}>{t('YOU_CANT_LOGIN', 'You can\'t login')}</OText>
36
+ <OIcon
37
+ src={theme.images?.general?.deliveryWaiting}
38
+ width={(deviceWidth - 80) * 0.9}
39
+ height={(deviceWidth - 80) * 0.8}
40
+ />
41
+ <OText>{t('OUTSIDE_ESTABLISHED_SCHEDULE', 'You are outside the established schedule')}</OText>
42
+ <View style={{ flexDirection: 'row', marginBottom: 20 }}>
43
+ <OText color={theme.colors.primary}>{t('NEXT_TIME', 'Next time')}: </OText>
44
+ <OText>{daysOfWeek[nextSchedule?.day - 1]} {scheduleFormatted(nextSchedule?.schedule?.open)}</OText>
45
+ </View>
46
+ <OButton
47
+ text={t('GO_BACK', 'Go back')}
48
+ textStyle={{ color: theme.colors.white }}
49
+ onClick={goBack}
50
+ />
51
+ </View>
52
+ )
53
+ }
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { View, StyleSheet, ScrollView, ActivityIndicator } from 'react-native';
2
+ import { View, StyleSheet, ScrollView, ActivityIndicator, Pressable } from 'react-native';
3
3
  import { useForm } from 'react-hook-form';
4
4
  import { launchImageLibrary } from 'react-native-image-picker';
5
5
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
@@ -22,6 +22,7 @@ import {
22
22
  import { LogoutButton } from '../LogoutButton';
23
23
  import { LanguageSelector } from '../LanguageSelector';
24
24
  import { UserFormDetailsUI } from '../UserFormDetails';
25
+ import { DriverSchedule } from '../DriverSchedule'
25
26
  import ToggleSwitch from 'toggle-switch-react-native';
26
27
  import { UDWrapper } from '../UserFormDetails/styles';
27
28
  import {
@@ -30,11 +31,12 @@ import {
30
31
  OText,
31
32
  OButton,
32
33
  OInput,
34
+ OModal,
33
35
  } from '../../components/shared';
34
36
  import { sortInputFields, getTraduction } from '../../utils';
35
37
  import { ProfileParams } from '../../types';
36
38
  import { NotFoundSource } from '../NotFoundSource';
37
-
39
+ import AntDesignIcon from 'react-native-vector-icons/AntDesign'
38
40
  const ProfileUI = (props: ProfileParams) => {
39
41
  const {
40
42
  navigation,
@@ -66,6 +68,7 @@ const ProfileUI = (props: ProfileParams) => {
66
68
  const [phoneUpdate, setPhoneUpdate] = useState(false);
67
69
  const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
68
70
  const [phoneToShow, setPhoneToShow] = useState('');
71
+ const [openModal, setOpenModal] = useState(false)
69
72
 
70
73
  useEffect(() => {
71
74
  if (phoneInputData.phone.cellphone) {
@@ -459,7 +462,6 @@ const ProfileUI = (props: ProfileParams) => {
459
462
  />
460
463
  </View>
461
464
  )}
462
-
463
465
  {!validationFields.loading && !isEdit && (
464
466
  <EditButton>
465
467
  <OButton
@@ -474,12 +476,32 @@ const ProfileUI = (props: ProfileParams) => {
474
476
  />
475
477
  </EditButton>
476
478
  )}
477
-
479
+ {!!user?.schedule && (
480
+ <Pressable style={{ marginBottom: 10 }} onPress={() => setOpenModal(true)}>
481
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
482
+ <OText size={16}>{t('SCHEDULE', 'Schedule')}</OText>
483
+ <AntDesignIcon size={18} name='right' />
484
+ </View>
485
+ <View style={{
486
+ borderBottomColor: theme.colors.tabBar,
487
+ borderBottomWidth: 1,
488
+ marginTop: 10
489
+ }} />
490
+ </Pressable>
491
+ )}
478
492
  <Actions>
479
493
  <LanguageSelector />
480
494
 
481
495
  <LogoutButton />
482
496
  </Actions>
497
+ <OModal
498
+ open={openModal}
499
+ onClose={() => setOpenModal(false)}
500
+ entireModal
501
+ hideIcons
502
+ >
503
+ <DriverSchedule schedule={user?.schedule} />
504
+ </OModal>
483
505
  </ScrollView>
484
506
  )}
485
507
  </>
@@ -26,6 +26,7 @@ interface Props {
26
26
  isNotDecoration?: boolean;
27
27
  styleCloseButton?: any;
28
28
  order?: any;
29
+ hideIcons?: boolean
29
30
  }
30
31
 
31
32
  const OModal = (props: Props): React.ReactElement => {
@@ -47,6 +48,7 @@ const OModal = (props: Props): React.ReactElement => {
47
48
  style,
48
49
  styleCloseButton,
49
50
  order,
51
+ hideIcons
50
52
  } = props;
51
53
 
52
54
  const theme = useTheme();
@@ -70,8 +72,8 @@ const OModal = (props: Props): React.ReactElement => {
70
72
  alignItems: 'center',
71
73
  paddingHorizontal: 30,
72
74
  paddingTop: 30,
73
- paddingBottom: 25,
74
- borderBottomWidth: 2,
75
+ paddingBottom: !hideIcons ? 25 : 15,
76
+ borderBottomWidth: !hideIcons ? 2 : 0,
75
77
  borderBottomColor: '#e6e6e6',
76
78
  },
77
79
  titleGroups: {
@@ -218,50 +220,51 @@ const OModal = (props: Props): React.ReactElement => {
218
220
  {title}
219
221
  </OText>
220
222
  </View>
223
+ {!hideIcons && (
224
+ <View style={styles.titleGroups}>
225
+ <View style={styles.shadow}>
226
+ {order?.business?.logo ? (
227
+ <OIcon
228
+ url={optimizeImage(
229
+ order?.business?.logo,
230
+ 'h_300,c_limit',
231
+ )}
232
+ style={styles.titleIcons}
233
+ />
234
+ ) : (
235
+ <OIcon
236
+ src={theme.images.dummies.businessLogo}
237
+ style={styles.titleIcons}
238
+ />
239
+ )}
240
+ </View>
221
241
 
222
- <View style={styles.titleGroups}>
223
- <View style={styles.shadow}>
224
- {order?.business?.logo ? (
242
+ <View style={styles.shadow}>
225
243
  <OIcon
226
244
  url={optimizeImage(
227
- order?.business?.logo,
245
+ order?.customer?.photo ||
246
+ theme?.images?.dummies?.customerPhoto,
228
247
  'h_300,c_limit',
229
248
  )}
230
249
  style={styles.titleIcons}
231
250
  />
232
- ) : (
233
- <OIcon
234
- src={theme.images.dummies.businessLogo}
235
- style={styles.titleIcons}
236
- />
237
- )}
238
- </View>
251
+ </View>
239
252
 
240
- <View style={styles.shadow}>
241
- <OIcon
242
- url={optimizeImage(
243
- order?.customer?.photo ||
244
- theme?.images?.dummies?.customerPhoto,
245
- 'h_300,c_limit',
246
- )}
247
- style={styles.titleIcons}
248
- />
253
+ {order?.driver && (
254
+ <View style={styles.shadow}>
255
+ <OIcon
256
+ url={
257
+ optimizeImage(
258
+ order?.driver?.photo,
259
+ 'h_300,c_limit',
260
+ ) || theme?.images?.dummies?.driverPhoto
261
+ }
262
+ style={styles.titleIcons}
263
+ />
264
+ </View>
265
+ )}
249
266
  </View>
250
-
251
- {order?.driver && (
252
- <View style={styles.shadow}>
253
- <OIcon
254
- url={
255
- optimizeImage(
256
- order?.driver?.photo,
257
- 'h_300,c_limit',
258
- ) || theme?.images?.dummies?.driverPhoto
259
- }
260
- style={styles.titleIcons}
261
- />
262
- </View>
263
- )}
264
- </View>
267
+ )}
265
268
  </View>
266
269
  )}
267
270
  {children}
@@ -114,6 +114,10 @@ const CheckoutUI = (props: any) => {
114
114
  position: 'absolute',
115
115
  fontSize: 20
116
116
  },
117
+ detailWrapper: {
118
+ paddingHorizontal: 40,
119
+ width: '100%'
120
+ },
117
121
  wrapperNavbar: Platform.OS === 'ios'
118
122
  ? { paddingVertical: 0, paddingHorizontal: 40 }
119
123
  : { paddingVertical: 20, paddingHorizontal: 40 }
@@ -136,6 +140,8 @@ const CheckoutUI = (props: any) => {
136
140
  const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
137
141
  const [showGateway, setShowGateway] = useState<any>({ closedByUsed: false, open: false });
138
142
  const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
143
+ const [isOpen, setIsOpen] = useState(false)
144
+ const [requiredFields, setRequiredFields] = useState<any>([])
139
145
 
140
146
  const placeSpotTypes = [3, 4]
141
147
  const businessConfigs = businessDetails?.business?.configs ?? []
@@ -173,10 +179,14 @@ const CheckoutUI = (props: any) => {
173
179
  }
174
180
 
175
181
  const handlePlaceOrder = (confirmPayment) => {
176
- if (!userErrors.length) {
182
+ if (!userErrors.length && !requiredFields?.length) {
177
183
  handlerClickPlaceOrder && handlerClickPlaceOrder(null, null, confirmPayment)
178
184
  return
179
185
  }
186
+ if (requiredFields?.length) {
187
+ setIsOpen(true)
188
+ return
189
+ }
180
190
  let stringError = ''
181
191
  Object.values(userErrors).map((item: any, i: number) => {
182
192
  stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
@@ -204,11 +214,12 @@ const CheckoutUI = (props: any) => {
204
214
  setUserErrors([])
205
215
  const errors = []
206
216
  const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
217
+ const _requiredFields: any = []
207
218
 
208
219
  Object.values(validationFields?.fields?.checkout).map((field: any) => {
209
220
  if (field?.required && !notFields.includes(field.code)) {
210
221
  if (!user[field?.code]) {
211
- errors.push(t(`VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`, `The field ${field?.name} is required`))
222
+ _requiredFields.push(field?.code)
212
223
  }
213
224
  }
214
225
  })
@@ -219,8 +230,9 @@ const CheckoutUI = (props: any) => {
219
230
  validationFields?.fields?.checkout?.cellphone?.required) ||
220
231
  configs?.verification_phone_required?.value === '1')
221
232
  ) {
222
- errors.push(t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Phone number is required'))
233
+ _requiredFields.push('cellphone')
223
234
  }
235
+ setRequiredFields(_requiredFields)
224
236
 
225
237
  if (phoneUpdate) {
226
238
  errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
@@ -703,6 +715,28 @@ const CheckoutUI = (props: any) => {
703
715
  onClose={() => setOpenChangeStore(false)}
704
716
  />
705
717
  </OModal>
718
+ <OModal
719
+ open={isOpen}
720
+ onClose={() => setIsOpen(false)}
721
+ >
722
+ <View style={styles.detailWrapper}>
723
+ <UserDetails
724
+ isUserDetailsEdit
725
+ cartStatus={cart?.status}
726
+ businessId={cart?.business_id}
727
+ useValidationFields
728
+ useDefualtSessionManager
729
+ useSessionUser
730
+ isCheckout
731
+ isEdit
732
+ phoneUpdate={phoneUpdate}
733
+ togglePhoneUpdate={togglePhoneUpdate}
734
+ requiredFields={requiredFields}
735
+ hideUpdateButton
736
+ onClose={() => setIsOpen(false)}
737
+ />
738
+ </View>
739
+ </OModal>
706
740
  </ChContainer>
707
741
  </Container>
708
742
  {!cartState.loading && cart && cart?.status !== 2 && (
@@ -15,7 +15,8 @@ export const Otp = (props: otpParams) => {
15
15
  setWillVerifyOtpState,
16
16
  onSubmit,
17
17
  handleLoginOtp,
18
- setAlertState
18
+ setAlertState,
19
+ pinCount
19
20
  } = props
20
21
 
21
22
  const theme = useTheme();
@@ -65,7 +66,7 @@ export const Otp = (props: otpParams) => {
65
66
  </OText>
66
67
  <OTPInputView
67
68
  style={{ width: '100%', height: 150 }}
68
- pinCount={6}
69
+ pinCount={pinCount || 6}
69
70
  codeInputFieldStyle={loginStyle.underlineStyleBase}
70
71
  codeInputHighlightStyle={loginStyle.underlineStyleHighLighted}
71
72
  onCodeFilled={(code: string) => handleLoginOtp(code)}
@@ -102,7 +102,7 @@ const LoginFormUI = (props: LoginParams) => {
102
102
 
103
103
  const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
104
104
  const facebookLoginEnabled = configs?.facebook_login_enabled?.value === '1' || !configs?.facebook_login_enabled?.enabled
105
- const appleLoginEnabled = configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
105
+ const appleLoginEnabled = configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
106
106
 
107
107
  const loginStyle = StyleSheet.create({
108
108
  btnOutline: {
@@ -256,7 +256,7 @@ const LoginFormUI = (props: LoginParams) => {
256
256
  })
257
257
  }
258
258
 
259
- const handleCategoryScroll = (opc : string) => {
259
+ const handleCategoryScroll = (opc: string) => {
260
260
  tabsRef.current.scrollTo({
261
261
  x: tabLayouts?.[opc]?.x - 40,
262
262
  animated: true
@@ -351,15 +351,15 @@ const LoginFormUI = (props: LoginParams) => {
351
351
  titleStyle={{ marginRight: 0, marginLeft: 0 }}
352
352
  />
353
353
  <FormSide>
354
- {((useLoginByEmail && useLoginByCellphone) || useLoginOtp) && (
354
+ {(Number(useLoginByEmail) + Number(useLoginByCellphone) + Number(useLoginOtpEmail) + Number(useLoginOtpCellphone) > 1) && (
355
355
  <LoginWith>
356
356
  <OTabs
357
- horizontal
357
+ horizontal
358
358
  showsHorizontalScrollIndicator={false}
359
359
  ref={tabsRef}
360
360
  >
361
361
  {useLoginByEmail && (
362
- <TabBtn
362
+ <TabBtn
363
363
  onPress={() => handleChangeTab('email')}
364
364
  onLayout={(event: any) => handleOnLayout(event, 'email')}
365
365
  >
@@ -384,7 +384,7 @@ const LoginFormUI = (props: LoginParams) => {
384
384
  </TabBtn>
385
385
  )}
386
386
  {useLoginByCellphone && (
387
- <TabBtn
387
+ <TabBtn
388
388
  onPress={() => handleChangeTab('cellphone')}
389
389
  onLayout={(event: any) => handleOnLayout(event, 'cellphone')}
390
390
  >
@@ -409,7 +409,7 @@ const LoginFormUI = (props: LoginParams) => {
409
409
  </TabBtn>
410
410
  )}
411
411
  {useLoginOtpEmail && (
412
- <TabBtn
412
+ <TabBtn
413
413
  onPress={() => handleChangeOtpType('email')}
414
414
  onLayout={(event: any) => handleOnLayout(event, 'otp_email')}
415
415
  >
@@ -434,7 +434,7 @@ const LoginFormUI = (props: LoginParams) => {
434
434
  </TabBtn>
435
435
  )}
436
436
  {useLoginOtpCellphone && (
437
- <TabBtn
437
+ <TabBtn
438
438
  onPress={() => handleChangeOtpType('cellphone')}
439
439
  onLayout={(event: any) => handleOnLayout(event, 'otp_cellphone')}
440
440
  >
@@ -707,7 +707,7 @@ const LoginFormUI = (props: LoginParams) => {
707
707
  <ButtonsWrapper>
708
708
  <SocialButtons>
709
709
  {(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
710
- configs?.facebook_id?.value &&
710
+ configs?.facebook_id?.value &&
711
711
  facebookLoginEnabled && (
712
712
  <FacebookLogin
713
713
  notificationState={notificationState}
@@ -18,10 +18,12 @@ import {
18
18
  } from 'ordering-components/native';
19
19
  import { useTheme } from 'styled-components/native';
20
20
  import { FormSide, FormInput, SocialButtons } from './styles';
21
+ import { Otp } from '../LoginForm/Otp'
21
22
 
22
23
  import {
23
24
  ButtonsWrapper,
24
25
  LoginWith as SignupWith,
26
+ TabBtn,
25
27
  OTab,
26
28
  OTabs,
27
29
  RecaptchaButton
@@ -30,7 +32,9 @@ import {
30
32
  import NavBar from '../NavBar';
31
33
  import { VerifyPhone } from '../VerifyPhone';
32
34
 
33
- import { OText, OButton, OInput, OModal } from '../shared';
35
+ import Alert from '../../../../../src/providers/AlertProvider'
36
+ import { OText, OButton, OInput } from '../shared';
37
+ import { OModal } from '../../../../../src/components/shared';
34
38
  import { SignupParams } from '../../types';
35
39
  import { sortInputFields } from '../../utils';
36
40
  import { GoogleLogin } from '../GoogleLogin';
@@ -67,7 +71,19 @@ const SignupFormUI = (props: SignupParams) => {
67
71
  notificationState,
68
72
  handleChangePromotions,
69
73
  enableReCaptcha,
70
- handleReCaptcha
74
+ handleReCaptcha,
75
+ generateOtpCode,
76
+ numOtpInputs,
77
+ setWillVerifyOtpState,
78
+ handleChangeInput,
79
+ willVerifyOtpState,
80
+ setOtpState,
81
+ otpState,
82
+ setSignUpTab,
83
+ signUpTab,
84
+ useSignUpFullDetails,
85
+ useSignUpOtpEmail,
86
+ useSignUpOtpCellphone
71
87
  } = props;
72
88
 
73
89
  const theme = useTheme();
@@ -107,12 +123,10 @@ const SignupFormUI = (props: SignupParams) => {
107
123
  const { control, handleSubmit, errors, register, setValue } = useForm();
108
124
 
109
125
  const [passwordSee, setPasswordSee] = useState(false);
126
+ const [otpErrMsg, setOtpErrMsg] = useState('')
110
127
  const [formValues, setFormValues] = useState(null);
111
128
  const [isModalVisible, setIsModalVisible] = useState(false);
112
129
  const [isLoadingVerifyModal, setIsLoadingVerifyModal] = useState(false);
113
- const [signupTab, setSignupTab] = useState(
114
- useSignupByCellphone && !useSignupByEmail ? 'cellphone' : 'email',
115
- );
116
130
  const [isFBLoading, setIsFBLoading] = useState(false);
117
131
  const [phoneInputData, setPhoneInputData] = useState({
118
132
  error: '',
@@ -122,9 +136,12 @@ const SignupFormUI = (props: SignupParams) => {
122
136
  country_code: null
123
137
  },
124
138
  });
139
+ const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
125
140
  const [recaptchaConfig, setRecaptchaConfig] = useState<any>({})
126
141
  const [recaptchaVerified, setRecaptchaVerified] = useState(false)
142
+ const [tabLayouts, setTabLayouts] = useState<any>({})
127
143
 
144
+ const tabsRef = useRef<any>(null)
128
145
  const nameRef = useRef<any>(null);
129
146
  const lastnameRef = useRef<any>(null);
130
147
  const middleNameRef = useRef<any>(null);
@@ -137,7 +154,15 @@ const SignupFormUI = (props: SignupParams) => {
137
154
  const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
138
155
  const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
139
156
  const facebookLoginEnabled = configs?.facebook_login_enabled?.value === '1' || !configs?.facebook_login_enabled?.enabled
140
- const appleLoginEnabled = configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
157
+ const appleLoginEnabled = configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
158
+
159
+ const closeAlert = () => {
160
+ setAlertState({
161
+ open: false,
162
+ title: '',
163
+ content: []
164
+ })
165
+ }
141
166
 
142
167
  const handleRefs = (ref: any, code: string) => {
143
168
  switch (code) {
@@ -163,6 +188,13 @@ const SignupFormUI = (props: SignupParams) => {
163
188
  }
164
189
  };
165
190
 
191
+ const handleOnLayout = (event: any, opc: string) => {
192
+ const _tabLayouts = { ...tabLayouts }
193
+ const categoryKey = opc
194
+ _tabLayouts[categoryKey] = event.nativeEvent.layout
195
+ setTabLayouts(_tabLayouts)
196
+ }
197
+
166
198
  const handleFocusRef = (code: string) => {
167
199
  switch (code) {
168
200
  case 'name': {
@@ -206,13 +238,8 @@ const SignupFormUI = (props: SignupParams) => {
206
238
  navigation.navigate('Home');
207
239
  };
208
240
 
209
- const handleChangeTab = (val: string) => {
210
- setSignupTab(val);
211
- setPasswordSee(false);
212
- };
213
-
214
- const onSubmit = (values: any) => {
215
- if (phoneInputData.error) {
241
+ const onSubmit = (values?: any) => {
242
+ if (phoneInputData.error && signUpTab !== 'otpEmail') {
216
243
  showToast(ToastType.Error, phoneInputData.error);
217
244
  return;
218
245
  }
@@ -221,7 +248,8 @@ const SignupFormUI = (props: SignupParams) => {
221
248
  !phoneInputData.phone.cellphone &&
222
249
  ((validationFields?.fields?.checkout?.cellphone?.enabled &&
223
250
  validationFields?.fields?.checkout?.cellphone?.required) ||
224
- configs?.verification_phone_required?.value === '1')
251
+ configs?.verification_phone_required?.value === '1') &&
252
+ signUpTab !== 'otpEmail'
225
253
  ) {
226
254
  showToast(
227
255
  ToastType.Error,
@@ -232,26 +260,29 @@ const SignupFormUI = (props: SignupParams) => {
232
260
  );
233
261
  return;
234
262
  }
235
- if (signupTab === 'email' || !useSignupByCellphone) {
236
- handleButtonSignupClick &&
237
- handleButtonSignupClick({
238
- ...values,
239
- ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && { ...phoneInputData.phone }),
240
- country_code: phoneInputData.phone.country_code
241
- });
242
- if (
243
- !formState.loading &&
244
- formState.result.result &&
245
- !formState.result.error
246
- ) {
247
- handleSuccessSignup && handleSuccessSignup(formState.result.result);
248
- }
249
- return;
263
+ if (signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') {
264
+ generateOtpCode && generateOtpCode({
265
+ ...values,
266
+ ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && { ...phoneInputData.phone }),
267
+ country_code: phoneInputData.phone.country_code
268
+ })
269
+ return
270
+ }
271
+ handleButtonSignupClick &&
272
+ handleButtonSignupClick({
273
+ ...values,
274
+ ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && { ...phoneInputData.phone }),
275
+ country_code: phoneInputData.phone.country_code
276
+ });
277
+ if (!formState.loading && formState.result.result && !formState.result.error) {
278
+ handleSuccessSignup && handleSuccessSignup(formState.result.result);
250
279
  }
251
- setFormValues(values);
252
- handleVerifyCodeClick(values);
253
280
  };
254
281
 
282
+ const handleSingUpOtp = (value: string) => {
283
+ setOtpState && setOtpState(value)
284
+ }
285
+
255
286
  const handleVerifyCodeClick = (values: any) => {
256
287
  const formData = values || formValues;
257
288
  handleSendVerifyCode &&
@@ -382,6 +413,14 @@ const SignupFormUI = (props: SignupParams) => {
382
413
  })
383
414
  }, [configs])
384
415
 
416
+ useEffect(() => {
417
+ 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'))
421
+ }
422
+ }, [checkPhoneCodeState])
423
+
385
424
  return (
386
425
  <View>
387
426
  <NavBar
@@ -395,47 +434,90 @@ const SignupFormUI = (props: SignupParams) => {
395
434
  titleStyle={{ marginLeft: 0, marginRight: 0 }}
396
435
  />
397
436
  <FormSide>
398
- {useSignupByEmail &&
399
- useSignupByCellphone &&
400
- configs &&
401
- Object.keys(configs).length > 0 &&
402
- (configs?.twilio_service_enabled?.value === 'true' ||
403
- configs?.twilio_service_enabled?.value === '1') && (
404
- <SignupWith style={{ paddingBottom: 25 }}>
405
- <OTabs>
406
- {useSignupByEmail && (
407
- <Pressable onPress={() => handleChangeTab('email')}>
408
- <OTab>
409
- <OText
410
- size={18}
411
- color={
412
- signupTab === 'email'
413
- ? theme.colors.primary
414
- : theme.colors.disabled
415
- }>
416
- {t('SIGNUP_BY_EMAIL', 'Signup by Email')}
417
- </OText>
418
- </OTab>
419
- </Pressable>
420
- )}
421
- {useSignupByCellphone && (
422
- <Pressable onPress={() => handleChangeTab('cellphone')}>
423
- <OTab>
424
- <OText
425
- size={18}
426
- color={
427
- signupTab === 'cellphone'
428
- ? theme.colors.primary
429
- : theme.colors.disabled
430
- }>
431
- {t('SIGNUP_BY_PHONE', 'Signup by Phone')}
432
- </OText>
433
- </OTab>
434
- </Pressable>
435
- )}
436
- </OTabs>
437
- </SignupWith>
438
- )}
437
+ {(useSignUpFullDetails) && (
438
+ <SignupWith>
439
+ <OTabs
440
+ horizontal
441
+ showsHorizontalScrollIndicator={false}
442
+ ref={tabsRef}
443
+ >
444
+ <TabBtn
445
+ onPress={() => setSignUpTab && setSignUpTab('default')}
446
+ onLayout={(event: any) => handleOnLayout(event, 'default')}
447
+ >
448
+ <OTab
449
+ style={{
450
+ borderBottomColor:
451
+ signUpTab === 'default'
452
+ ? theme.colors.textNormal
453
+ : theme.colors.border,
454
+ }}>
455
+ <OText
456
+ size={14}
457
+ color={
458
+ signUpTab === 'default'
459
+ ? theme.colors.textNormal
460
+ : theme.colors.disabled
461
+ }
462
+ weight={signUpTab === 'default' ? 'bold' : 'normal'}>
463
+ {t('DEFAULT', 'Default')}
464
+ </OText>
465
+ </OTab>
466
+ </TabBtn>
467
+ {useSignUpOtpEmail && (
468
+ <TabBtn
469
+ onPress={() => setSignUpTab && setSignUpTab('otpEmail')}
470
+ onLayout={(event: any) => handleOnLayout(event, 'otpEmail')}
471
+ >
472
+ <OTab
473
+ style={{
474
+ borderBottomColor:
475
+ signUpTab === 'otpEmail'
476
+ ? theme.colors.textNormal
477
+ : theme.colors.border,
478
+ }}>
479
+ <OText
480
+ size={14}
481
+ color={
482
+ signUpTab === 'otpEmail'
483
+ ? theme.colors.textNormal
484
+ : theme.colors.disabled
485
+ }
486
+ weight={signUpTab === 'otpEmail' ? 'bold' : 'normal'}>
487
+ {t('BY_OTP_EMAIL', 'by Otp Email')}
488
+ </OText>
489
+ </OTab>
490
+ </TabBtn>
491
+
492
+ )}
493
+ {useSignUpOtpCellphone && (
494
+ <TabBtn
495
+ onPress={() => setSignUpTab && setSignUpTab('otpCellphone')}
496
+ onLayout={(event: any) => handleOnLayout(event, 'otpCellphone')}
497
+ >
498
+ <OTab
499
+ style={{
500
+ borderBottomColor:
501
+ signUpTab === 'otpCellphone'
502
+ ? theme.colors.textNormal
503
+ : theme.colors.border,
504
+ }}>
505
+ <OText
506
+ size={14}
507
+ color={
508
+ signUpTab === 'otpCellphone'
509
+ ? theme.colors.textNormal
510
+ : theme.colors.disabled
511
+ }
512
+ weight={signUpTab === 'otpCellphone' ? 'bold' : 'normal'}>
513
+ {t('BY_OTP_CELLPHONE', 'by Otp Cellphone')}
514
+ </OText>
515
+ </OTab>
516
+ </TabBtn>
517
+ )}
518
+ </OTabs>
519
+ </SignupWith>
520
+ )}
439
521
  <FormInput>
440
522
  {!(useChekoutFileds && validationFields?.loading) ? (
441
523
  <>
@@ -445,7 +527,9 @@ const SignupFormUI = (props: SignupParams) => {
445
527
  (field: any, i: number) =>
446
528
  !notValidationFields.includes(field.code) &&
447
529
  showField &&
448
- showField(field.code) && (
530
+ showField(field.code) &&
531
+ (signUpTab === 'default' ||
532
+ (signUpTab === 'otpEmail' && field.code === 'email')) && (
449
533
  <React.Fragment key={field.id}>
450
534
  {errors?.[`${field.code}`] && (
451
535
  <OText
@@ -469,7 +553,7 @@ const SignupFormUI = (props: SignupParams) => {
469
553
  value={value}
470
554
  onChange={(val: any) =>
471
555
  field.code !== 'email'
472
- ? onChange(val)
556
+ ? (onChange(val))
473
557
  : handleChangeInputEmail(val, onChange)
474
558
  }
475
559
  autoCapitalize={
@@ -501,7 +585,7 @@ const SignupFormUI = (props: SignupParams) => {
501
585
  ),
502
586
  )}
503
587
 
504
- {!!showInputPhoneNumber && (
588
+ {(!!showInputPhoneNumber && (signUpTab === 'default' || signUpTab === 'otpCellphone')) && (
505
589
  <View style={{ marginBottom: 25 }}>
506
590
  <PhoneInputNumber
507
591
  data={phoneInputData}
@@ -564,34 +648,34 @@ const SignupFormUI = (props: SignupParams) => {
564
648
  />
565
649
  </>
566
650
  )}
567
-
568
- <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
569
- <Controller
570
- control={control}
571
- render={({ onChange, value }: any) => (
572
- <CheckBox
573
- value={value}
574
- onValueChange={newValue => {
575
- onChange(newValue)
576
- handleChangePromotions()
577
- }}
578
- boxType={'square'}
579
- tintColors={{
580
- true: theme.colors.primary,
581
- false: theme.colors.disabled
582
- }}
583
- tintColor={theme.colors.disabled}
584
- onCheckColor={theme.colors.primary}
585
- onTintColor={theme.colors.primary}
586
- style={Platform.OS === 'ios' && style.checkBoxStyle}
587
- />
588
- )}
589
- name='promotions'
590
- defaultValue={false}
591
- />
592
- <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
593
- </View>
594
-
651
+ {(signUpTab === 'default') && (
652
+ <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
653
+ <Controller
654
+ control={control}
655
+ render={({ onChange, value }: any) => (
656
+ <CheckBox
657
+ value={value}
658
+ onValueChange={newValue => {
659
+ onChange(newValue)
660
+ handleChangePromotions()
661
+ }}
662
+ boxType={'square'}
663
+ tintColors={{
664
+ true: theme.colors.primary,
665
+ false: theme.colors.disabled
666
+ }}
667
+ tintColor={theme.colors.disabled}
668
+ onCheckColor={theme.colors.primary}
669
+ onTintColor={theme.colors.primary}
670
+ style={Platform.OS === 'ios' && style.checkBoxStyle}
671
+ />
672
+ )}
673
+ name='promotions'
674
+ defaultValue={false}
675
+ />
676
+ <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
677
+ </View>
678
+ )}
595
679
  {configs?.terms_and_conditions?.value === 'true' && (
596
680
  <>
597
681
  {errors?.termsAccept && (
@@ -643,7 +727,7 @@ const SignupFormUI = (props: SignupParams) => {
643
727
 
644
728
  )}
645
729
 
646
- {signupTab !== 'cellphone' && (
730
+ {signUpTab === 'default' && (
647
731
  <>
648
732
  {errors?.password && (
649
733
  <OText
@@ -715,9 +799,7 @@ const SignupFormUI = (props: SignupParams) => {
715
799
  <Spinner visible />
716
800
  )}
717
801
 
718
- {signupTab === 'cellphone' &&
719
- useSignupByEmail &&
720
- useSignupByCellphone ? (
802
+ {(signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') ? (
721
803
  <OButton
722
804
  onClick={handleSubmit(onSubmit)}
723
805
  text={t('GET_VERIFY_CODE', 'Get Verify Code')}
@@ -782,7 +864,7 @@ const SignupFormUI = (props: SignupParams) => {
782
864
  <ButtonsWrapper>
783
865
  <SocialButtons>
784
866
  {(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
785
- configs?.facebook_id?.value &&
867
+ configs?.facebook_id?.value &&
786
868
  facebookLoginEnabled &&
787
869
  (
788
870
  <FacebookLogin
@@ -815,27 +897,40 @@ const SignupFormUI = (props: SignupParams) => {
815
897
  )}
816
898
 
817
899
  </FormSide>
818
- <OModal open={isModalVisible} onClose={() => setIsModalVisible(false)}>
819
- <VerifyPhone
820
- phone={phoneInputData.phone}
821
- formValues={formValues}
822
- verifyPhoneState={verifyPhoneState}
823
- checkPhoneCodeState={checkPhoneCodeState}
824
- handleCheckPhoneCode={handleCheckPhoneCode}
825
- setCheckPhoneCodeState={setCheckPhoneCodeState}
826
- handleVerifyCodeClick={onSubmit}
900
+ <OModal
901
+ open={willVerifyOtpState}
902
+ onClose={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
903
+ entireModal
904
+ title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
905
+ >
906
+ <Otp
907
+ pinCount={numOtpInputs || 6}
908
+ willVerifyOtpState={willVerifyOtpState || false}
909
+ setWillVerifyOtpState={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
910
+ handleLoginOtp={handleSingUpOtp}
911
+ onSubmit={onSubmit}
912
+ setAlertState={setAlertState}
827
913
  />
828
914
  </OModal>
829
915
  <Spinner
830
916
  visible={formState.loading || validationFields.loading || isFBLoading}
831
917
  />
918
+ <Alert
919
+ open={alertState.open}
920
+ content={alertState.content}
921
+ title={alertState.title || ''}
922
+ onAccept={closeAlert}
923
+ onClose={closeAlert}
924
+ />
832
925
  </View>
833
926
  );
834
927
  };
835
928
 
836
929
  export const SignupForm = (props: any) => {
930
+ const _numOtpInputs = 6
837
931
  const signupProps = {
838
932
  ...props,
933
+ numOtpInputs: _numOtpInputs,
839
934
  isRecaptchaEnable: true,
840
935
  UIComponent: SignupFormUI,
841
936
  };
@@ -23,6 +23,8 @@ const UserDetailsUI = (props: any) => {
23
23
  isEdit,
24
24
  formState,
25
25
  cleanFormState,
26
+ requiredFields,
27
+ onClose,
26
28
  cartStatus,
27
29
  toggleIsEdit,
28
30
  validationFields,
@@ -44,6 +46,7 @@ const UserDetailsUI = (props: any) => {
44
46
  const userData = props.userData || (!formState.result.error && formState.result?.result) || user
45
47
 
46
48
  const [isModalVisible, setIsModalVisible] = useState(false);
49
+ const [isSubmit, setIsSubmit] = useState(false)
47
50
  const [willVerifyOtpState, setWillVerifyOtpState] = useState(false);
48
51
  const [checkPhoneCodeState, setCheckPhoneCodeState] = useState({ loading: false, result: { error: false } })
49
52
  const [phoneInputData, setPhoneInputData] = useState({
@@ -54,7 +57,6 @@ const UserDetailsUI = (props: any) => {
54
57
  },
55
58
  });
56
59
 
57
-
58
60
  useEffect(() => {
59
61
  if (isUserDetailsEdit) {
60
62
  !isEdit && toggleIsEdit()
@@ -66,6 +68,12 @@ const UserDetailsUI = (props: any) => {
66
68
  cleanFormState({ changes: {} })
67
69
  }
68
70
 
71
+ useEffect(() => {
72
+ if (isSubmit && !isEdit && requiredFields) {
73
+ onClose && onClose()
74
+ }
75
+ }, [isSubmit, requiredFields, isEdit])
76
+
69
77
  useEffect(() => {
70
78
  if (user?.cellphone && !user?.country_phone_code) {
71
79
  togglePhoneUpdate(true)
@@ -147,7 +155,7 @@ const UserDetailsUI = (props: any) => {
147
155
  <OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal}>
148
156
  {t('CUSTOMER_DETAILS', 'Customer Details')}
149
157
  </OText>
150
- {cartStatus !== 2 && (
158
+ {cartStatus !== 2 && !requiredFields && (
151
159
  !isEdit ? (
152
160
  <EditBtn onPress={() => toggleIsEdit()} activeOpacity={0.7}>
153
161
  <OIcon
@@ -198,6 +206,7 @@ const UserDetailsUI = (props: any) => {
198
206
  togglePhoneUpdate={togglePhoneUpdate}
199
207
  isCheckout={isCheckout}
200
208
  setWillVerifyOtpState={setWillVerifyOtpState}
209
+ setIsSubmit={setIsSubmit}
201
210
  />
202
211
  )}
203
212
  </UDContainer>
@@ -17,6 +17,9 @@ export const UserFormDetailsUI = (props: any) => {
17
17
  isEdit,
18
18
  formState,
19
19
  showField,
20
+ requiredFields,
21
+ onClose,
22
+ setIsSubmit,
20
23
  cleanFormState,
21
24
  onCloseProfile,
22
25
  isRequiredField,
@@ -75,6 +78,7 @@ export const UserFormDetailsUI = (props: any) => {
75
78
 
76
79
  const [{ user }] = useSession();
77
80
  const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
81
+ const [isValid, setIsValid] = useState(false)
78
82
  const [isChanged, setIsChanged] = useState(false)
79
83
  const [phoneInputData, setPhoneInputData] = useState({
80
84
  error: '',
@@ -160,6 +164,7 @@ export const UserFormDetailsUI = (props: any) => {
160
164
  cellphone: '',
161
165
  };
162
166
  }
167
+ setIsSubmit && setIsSubmit(true)
163
168
  handleButtonUpdateClick(changes);
164
169
  }
165
170
  };
@@ -235,6 +240,12 @@ export const UserFormDetailsUI = (props: any) => {
235
240
  setWillVerifyOtpState?.(true)
236
241
  }
237
242
  }, [phoneInputData, configs?.verification_phone_required?.value, isChanged])
243
+
244
+ useEffect(() => {
245
+ if (!requiredFields || formState?.changes?.length === 0) return
246
+ const _isValid = requiredFields.every((key: any) => formState?.changes[key])
247
+ setIsValid(_isValid)
248
+ }, [formState?.changes, requiredFields])
238
249
 
239
250
  return (
240
251
  <>
@@ -248,7 +259,7 @@ export const UserFormDetailsUI = (props: any) => {
248
259
  }).map(
249
260
  (field: any) =>
250
261
  showField &&
251
- showField(field.code) && (
262
+ showField(field.code) && ((requiredFields && requiredFields.includes(field.code)) || !requiredFields) && (
252
263
  <React.Fragment key={field.id}>
253
264
  <Controller
254
265
  key={field.id}
@@ -322,7 +333,7 @@ export const UserFormDetailsUI = (props: any) => {
322
333
  ),
323
334
  )}
324
335
 
325
- {!!showInputPhoneNumber && (
336
+ {!!showInputPhoneNumber &&((requiredFields && requiredFields.includes('cellphone')) || !requiredFields) && (
326
337
  <WrapperPhone>
327
338
  <OText size={14} lineHeight={21} weight={'500'} color={theme.colors.textNormal}>{t('PHONE', 'Phone')}</OText>
328
339
  <PhoneInputNumber
@@ -347,71 +358,76 @@ export const UserFormDetailsUI = (props: any) => {
347
358
  )}
348
359
  </WrapperPhone>
349
360
  )}
350
- <Controller
351
- control={control}
352
- render={() => (
353
- <>
354
- <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
355
- {t('PASSWORD', 'Password')}
356
- </OText>
357
- <OInput
358
- name='password'
359
- placeholder={t('FRONT_VISUALS_PASSWORD', 'Password')}
360
- inputStyle={styles.inputStyle}
361
- style={{ paddingLeft: 0, paddingRight: 0, marginTop: 6, height: 44, minHeight: 44 }}
362
- autoCapitalize='none'
363
- isDisabled={false}
364
- value={
365
- formState?.changes['password'] ??
366
- (user && user['password']) ??
367
- ''
368
- }
369
- onChange={(val: any) => {
370
- setValue('password', val.target.value)
371
- handleChangeInput(val)
372
- }}
373
- autoCorrect
374
- type='default'
375
- returnKeyType="done"
376
- autoCompleteType='off'
377
- isSecured
378
- />
379
- </>
380
- )}
381
- name='password'
382
- rules={getInputRules({ name: 'password', code: 'password' })}
383
- defaultValue=''
384
- />
385
- <Controller
386
- control={control}
387
- render={({ onChange, value }: any) => (
388
- <TouchableOpacity
389
- style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20, width: '100%' }}
390
- onPress={() => {
391
- onChange(!value)
392
- handleChangePromotions(!value)
393
- }}
394
- >
395
- <CheckBox
396
- value={value}
397
- boxType={'square'}
398
- tintColors={{
399
- true: theme.colors.primary,
400
- false: theme.colors.disabled
361
+ {!requiredFields && (
362
+ <Controller
363
+ control={control}
364
+ render={() => (
365
+ <>
366
+ <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
367
+ {t('PASSWORD', 'Password')}
368
+ </OText>
369
+ <OInput
370
+ name='password'
371
+ placeholder={t('FRONT_VISUALS_PASSWORD', 'Password')}
372
+ inputStyle={styles.inputStyle}
373
+ style={{ paddingLeft: 0, paddingRight: 0, marginTop: 6, height: 44, minHeight: 44 }}
374
+ autoCapitalize='none'
375
+ isDisabled={false}
376
+ value={
377
+ formState?.changes['password'] ??
378
+ (user && user['password']) ??
379
+ ''
380
+ }
381
+ onChange={(val: any) => {
382
+ setValue('password', val.target.value)
383
+ handleChangeInput(val)
384
+ }}
385
+ autoCorrect
386
+ type='default'
387
+ returnKeyType="done"
388
+ autoCompleteType='off'
389
+ isSecured
390
+ />
391
+ </>
392
+ )}
393
+ name='password'
394
+ rules={getInputRules({ name: 'password', code: 'password' })}
395
+ defaultValue=''
396
+ />
397
+ )}
398
+ {!requiredFields && (
399
+ <Controller
400
+ control={control}
401
+ render={({ onChange, value }: any) => (
402
+ <TouchableOpacity
403
+ style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20, width: '100%' }}
404
+ onPress={() => {
405
+ onChange(!value)
406
+ handleChangePromotions(!value)
401
407
  }}
402
- tintColor={theme.colors.disabled}
403
- onCheckColor={theme.colors.primary}
404
- onTintColor={theme.colors.primary}
405
- style={Platform.OS === 'ios' && styles.checkBoxStyle}
406
- />
407
- <OText style={{ fontSize: 14, paddingHorizontal: 5, paddingLeft: 10 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
408
- </TouchableOpacity>
409
- )}
410
- name='promotions'
411
- defaultValue={formState?.result?.result
412
- ? !!formState?.result?.result?.settings?.notification?.newsletter
413
- : !!(formState?.changes?.settings?.notification?.newsletter ?? (user && user?.settings?.notification?.newsletter))}
414
- />
408
+ >
409
+ <CheckBox
410
+ value={value}
411
+ boxType={'square'}
412
+ tintColors={{
413
+ true: theme.colors.primary,
414
+ false: theme.colors.disabled
415
+ }}
416
+ tintColor={theme.colors.disabled}
417
+ onCheckColor={theme.colors.primary}
418
+ onTintColor={theme.colors.primary}
419
+ style={Platform.OS === 'ios' && styles.checkBoxStyle}
420
+ />
421
+ <OText style={{ fontSize: 14, paddingHorizontal: 5, paddingLeft: 10 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
422
+ </TouchableOpacity>
423
+ )}
424
+ name='promotions'
425
+ defaultValue={formState?.result?.result
426
+ ? !!formState?.result?.result?.settings?.notification?.newsletter
427
+ : !!(formState?.changes?.settings?.notification?.newsletter ?? (user && user?.settings?.notification?.newsletter))}
428
+ />
429
+ )}
430
+
415
431
  </UDWrapper>
416
432
  )}
417
433
  {validationFields?.loading && (
@@ -443,6 +459,22 @@ export const UserFormDetailsUI = (props: any) => {
443
459
  )}
444
460
  </>
445
461
  )}
462
+ {requiredFields && (
463
+ <OButton
464
+ text={
465
+ formState.loading
466
+ ? t('UPDATING', 'Updating...')
467
+ : t('CONTINUE', 'Continue')
468
+ }
469
+ bgColor={theme.colors.white}
470
+ textStyle={{ color: theme.colors.primary, fontSize: 14 }}
471
+ borderColor={theme.colors.primary}
472
+ isDisabled={formState.loading || !isValid}
473
+ imgRightSrc={null}
474
+ style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20, marginBottom: 20 }}
475
+ onClick={handleSubmit(onSubmit)}
476
+ />
477
+ )}
446
478
  </>
447
479
  );
448
480
  };
@@ -110,9 +110,20 @@ export interface SignupParams {
110
110
  handleSendVerifyCode?: any;
111
111
  handleCheckPhoneCode?: any;
112
112
  notificationState?: any;
113
+ signUpTab?: string;
114
+ useSignUpFullDetails?: boolean;
115
+ useSignUpOtpEmail?: boolean;
116
+ useSignUpOtpCellphone?: boolean;
117
+ willVerifyOtpState?: boolean;
118
+ numOtpInputs?: number;
113
119
  handleChangePromotions: () => void;
120
+ handleChangeInput?: (in1: any, in2: any) => void;
114
121
  enableReCaptcha?: boolean;
122
+ generateOtpCode?: (in1?: any) => void;
115
123
  handleReCaptcha?: () => void;
124
+ setSignUpTab?: (in1: string) => void;
125
+ setWillVerifyOtpState?: (in1: boolean) => void;
126
+ setOtpState?: (in1: string) => void;
116
127
  }
117
128
 
118
129
  export interface PhoneInputParams {
@@ -651,7 +662,8 @@ export interface otpParams {
651
662
  setWillVerifyOtpState: (val: boolean) => void,
652
663
  onSubmit: () => void,
653
664
  handleLoginOtp: (code: string) => void,
654
- setAlertState: any
665
+ setAlertState: any;
666
+ pinCount: number;
655
667
  }
656
668
 
657
669
  export interface FavoriteParams {