ordering-ui-react-native 0.16.32 → 0.16.35

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.32",
3
+ "version": "0.16.35",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -220,9 +220,12 @@ const AddressFormUI = (props: AddressFormParams) => {
220
220
 
221
221
  if (isObjet) {
222
222
  setValue('address', address)
223
- handleChangeInput({ target: { name: 'address', value: address } })
224
223
  googleInput?.current?.setAddressText(address)
225
224
  setLoadingLocation(false)
225
+ updateChanges({
226
+ address: address,
227
+ location: json.results[0].geometry.location
228
+ })
226
229
  return
227
230
  }
228
231
 
@@ -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}
@@ -30,12 +30,9 @@ const UserDetailsUI = (props: any) => {
30
30
  phoneUpdate,
31
31
  togglePhoneUpdate,
32
32
  isCheckout,
33
- checkPhoneCodeState,
34
33
  handleSendVerifyCode,
35
- handleCheckPhoneCode,
36
34
  verifyPhoneState,
37
- isVerifiedPhone,
38
- setCheckPhoneCodeState
35
+ setFormState
39
36
  } = props
40
37
 
41
38
  const theme = useTheme();
@@ -48,6 +45,7 @@ const UserDetailsUI = (props: any) => {
48
45
 
49
46
  const [isModalVisible, setIsModalVisible] = useState(false);
50
47
  const [willVerifyOtpState, setWillVerifyOtpState] = useState(false);
48
+ const [checkPhoneCodeState, setCheckPhoneCodeState] = useState({ loading: false, result: { error: false } })
51
49
  const [phoneInputData, setPhoneInputData] = useState({
52
50
  error: '',
53
51
  phone: {
@@ -94,6 +92,18 @@ const UserDetailsUI = (props: any) => {
94
92
  }
95
93
  }
96
94
 
95
+ const handleSendPhoneCode = (values: any) => {
96
+ setWillVerifyOtpState(false)
97
+ setIsModalVisible(false)
98
+ setFormState({
99
+ ...formState,
100
+ changes: {
101
+ ...formState?.changes,
102
+ verification_code: values?.code
103
+ }
104
+ })
105
+ }
106
+
97
107
  useEffect(() => {
98
108
  if (willVerifyOtpState) handleVerifyCodeClick()
99
109
  }, [willVerifyOtpState])
@@ -120,10 +130,6 @@ const UserDetailsUI = (props: any) => {
120
130
  }
121
131
  }, [verifyPhoneState])
122
132
 
123
- useEffect(() => {
124
- if (isVerifiedPhone) setIsModalVisible(false)
125
- }, [isVerifiedPhone])
126
-
127
133
  return (
128
134
  <>
129
135
  {(validationFields.loading || formState.loading) && (
@@ -202,13 +208,12 @@ const UserDetailsUI = (props: any) => {
202
208
  entireModal
203
209
  >
204
210
  <VerifyPhone
205
- phone={phoneInputData.phone}
206
- verifyPhoneState={verifyPhoneState}
207
- checkPhoneCodeState={checkPhoneCodeState}
208
- handleCheckPhoneCode={handleCheckPhoneCode}
209
- setCheckPhoneCodeState={setCheckPhoneCodeState}
210
- handleVerifyCodeClick={handleVerifyCodeClick}
211
- onClose={() => setIsModalVisible(false)}
211
+ phone={phoneInputData.phone}
212
+ verifyPhoneState={verifyPhoneState}
213
+ checkPhoneCodeState={checkPhoneCodeState}
214
+ handleCheckPhoneCode={handleSendPhoneCode}
215
+ handleVerifyCodeClick={handleVerifyCodeClick}
216
+ onClose={() => setIsModalVisible(false)}
212
217
  />
213
218
  </OModal>
214
219
  <Spinner visible={verifyPhoneState?.loading} />
@@ -26,7 +26,6 @@ export const UserFormDetailsUI = (props: any) => {
26
26
  phoneUpdate,
27
27
  hideUpdateButton,
28
28
  setWillVerifyOtpState,
29
- isVerifiedPhone,
30
29
  handleChangePromotions,
31
30
  } = props;
32
31
 
@@ -76,6 +75,7 @@ export const UserFormDetailsUI = (props: any) => {
76
75
 
77
76
  const [{ user }] = useSession();
78
77
  const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
78
+ const [isChanged, setIsChanged] = useState(false)
79
79
  const [phoneInputData, setPhoneInputData] = useState({
80
80
  error: '',
81
81
  phone: {
@@ -153,9 +153,6 @@ export const UserFormDetailsUI = (props: any) => {
153
153
  );
154
154
  return;
155
155
  }
156
- if (formState?.changes?.cellphone && !isVerifiedPhone) {
157
- showToast(ToastType.Error, t('VERIFY_ERROR_PHONE_NUMBER', 'The Phone Number field is not verified'))
158
- }
159
156
  let changes = null;
160
157
  if (user?.cellphone && !userPhoneNumber) {
161
158
  changes = {
@@ -169,6 +166,7 @@ export const UserFormDetailsUI = (props: any) => {
169
166
 
170
167
  const handleChangePhoneNumber = (number: any) => {
171
168
  setPhoneInputData(number);
169
+ setIsChanged(true)
172
170
  let phoneNumber = {
173
171
  country_phone_code: {
174
172
  name: 'country_phone_code',
@@ -228,11 +226,16 @@ export const UserFormDetailsUI = (props: any) => {
228
226
  }, [user, isEdit]);
229
227
 
230
228
  useEffect(() => {
231
- if (!phoneInputData.error && phoneInputData?.phone?.country_phone_code && phoneInputData?.phone?.cellphone) {
229
+ if (!phoneInputData.error &&
230
+ phoneInputData?.phone?.country_phone_code &&
231
+ phoneInputData?.phone?.cellphone &&
232
+ configs?.verification_phone_required?.value === '1' &&
233
+ formState?.changes?.cellphone &&
234
+ isChanged) {
232
235
  setWillVerifyOtpState?.(true)
233
236
  }
234
- }, [phoneInputData])
235
-
237
+ }, [phoneInputData, configs?.verification_phone_required?.value, isChanged])
238
+
236
239
  return (
237
240
  <>
238
241
  <UDForm>
@@ -35,12 +35,9 @@ const ProfileUI = (props: ProfileParams) => {
35
35
  cleanFormState,
36
36
  handleChangeInput,
37
37
  handleButtonUpdateClick,
38
- checkPhoneCodeState,
39
38
  handleSendVerifyCode,
40
- handleCheckPhoneCode,
41
39
  verifyPhoneState,
42
- isVerifiedPhone,
43
- setCheckPhoneCodeState
40
+ setFormState
44
41
  } = props;
45
42
 
46
43
  const theme = useTheme();
@@ -73,6 +70,7 @@ const ProfileUI = (props: ProfileParams) => {
73
70
  const { handleSubmit, errors, setValue, control } = useForm();
74
71
  const [isModalVisible, setIsModalVisible] = useState(false);
75
72
  const [willVerifyOtpState, setWillVerifyOtpState] = useState(false);
73
+ const [checkPhoneCodeState, setCheckPhoneCodeState] = useState({ loading: false, result: { error: false } })
76
74
 
77
75
  const [phoneInputData, setPhoneInputData] = useState({
78
76
  error: '',
@@ -272,9 +270,17 @@ const ProfileUI = (props: ProfileParams) => {
272
270
  }
273
271
  }, [verifyPhoneState])
274
272
 
275
- useEffect(() => {
276
- if (isVerifiedPhone) setIsModalVisible(false)
277
- }, [isVerifiedPhone])
273
+ const handleSendPhoneCode = (values: any) => {
274
+ setWillVerifyOtpState(false)
275
+ setIsModalVisible(false)
276
+ setFormState({
277
+ ...formState,
278
+ changes: {
279
+ ...formState?.changes,
280
+ verification_code: values?.code
281
+ }
282
+ })
283
+ }
278
284
 
279
285
  return (
280
286
  <>
@@ -331,8 +337,7 @@ const ProfileUI = (props: ProfileParams) => {
331
337
  phone={phoneInputData.phone}
332
338
  verifyPhoneState={verifyPhoneState}
333
339
  checkPhoneCodeState={checkPhoneCodeState}
334
- handleCheckPhoneCode={handleCheckPhoneCode}
335
- setCheckPhoneCodeState={setCheckPhoneCodeState}
340
+ handleCheckPhoneCode={handleSendPhoneCode}
336
341
  handleVerifyCodeClick={handleVerifyCodeClick}
337
342
  onClose={() => setIsModalVisible(false)}
338
343
  />