ordering-ui-react-native 0.12.66 → 0.12.70

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.12.66",
3
+ "version": "0.12.70",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -25,6 +25,8 @@ import {
25
25
  import { useTheme } from 'styled-components/native';
26
26
  import { ReviewCustomer } from '../ReviewCustomer'
27
27
 
28
+ import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons'
29
+
28
30
  interface OrderContent {
29
31
  order: any,
30
32
  logisticOrderStatus?: Array<number>,
@@ -150,46 +152,56 @@ export const OrderContentComponent = (props: OrderContent) => {
150
152
  {
151
153
  (order?.customer?.name || order?.customer?.lastname) && (
152
154
  <View style={{ flexDirection: 'row' }}>
153
- <OText numberOfLines={2} mBottom={4}>
154
- {order?.customer?.name && (
155
- <OText
156
- numberOfLines={1}
157
- mBottom={4}
158
- ellipsizeMode="tail"
159
- space>
160
- {order?.customer?.name}
161
- </OText>
162
- )}
163
- {order?.customer?.middle_name && (
164
- <OText
165
- numberOfLines={1}
166
- mBottom={4}
167
- ellipsizeMode="tail"
168
- space>
169
- {order?.customer?.middle_name}
170
- </OText>
171
- )}
172
- {order?.customer?.lastname && (
173
- <OText
174
- numberOfLines={1}
175
- mBottom={4}
176
- ellipsizeMode="tail"
177
- space>
178
- {order?.customer?.lastname}
179
- </OText>
180
- )}
181
- {
182
- order?.customer?.second_lastname && (
155
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between', flex: 1 }}>
156
+ <View style={{ flexDirection: 'row' }}>
157
+ {order?.customer?.name && (
183
158
  <OText
184
159
  numberOfLines={1}
185
160
  mBottom={4}
186
161
  ellipsizeMode="tail"
187
162
  space>
188
- {order?.customer?.second_lastname}
163
+ {order?.customer?.name}
189
164
  </OText>
190
- )
191
- }
192
- </OText>
165
+ )}
166
+ {order?.customer?.middle_name && (
167
+ <OText
168
+ numberOfLines={1}
169
+ mBottom={4}
170
+ ellipsizeMode="tail"
171
+ space>
172
+ {order?.customer?.middle_name}
173
+ </OText>
174
+ )}
175
+ {order?.customer?.lastname && (
176
+ <OText
177
+ numberOfLines={1}
178
+ mBottom={4}
179
+ ellipsizeMode="tail"
180
+ space>
181
+ {order?.customer?.lastname}
182
+ </OText>
183
+ )}
184
+ {
185
+ order?.customer?.second_lastname && (
186
+ <OText
187
+ numberOfLines={1}
188
+ mBottom={4}
189
+ ellipsizeMode="tail"
190
+ space>
191
+ {order?.customer?.second_lastname}
192
+ </OText>
193
+ )
194
+ }
195
+ </View>
196
+ {order?.user_review?.qualification && (
197
+ <View style={{ flexDirection: 'row' }}>
198
+ <MaterialIcon style={{ bottom: 2 }} name='star' size={24} color={theme.colors.arrowColor} />
199
+ <OText mLeft={5}>
200
+ {order?.user_review?.qualification}
201
+ </OText>
202
+ </View>
203
+ )}
204
+ </View>
193
205
  </View>
194
206
  )
195
207
  }
@@ -290,14 +290,6 @@ const AddressListUI = (props: AddressListParams) => {
290
290
  />
291
291
  </>
292
292
  )}
293
- {!isFromProfile && addressList?.addresses?.length > 0 && (
294
- <OButton
295
- text={t('CONTINUE', 'Continue')}
296
- style={styles.button}
297
- onClick={() => onNavigatorRedirect()}
298
- textStyle={{ color: theme.colors.white }}
299
- />
300
- )}
301
293
  </AddressListContainer>
302
294
  )}
303
295
  </Container>
@@ -1,5 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
3
+ import Geolocation from '@react-native-community/geolocation'
3
4
  import {
4
5
  View,
5
6
  StyleSheet,
@@ -16,6 +17,7 @@ import {
16
17
  useUtils,
17
18
  } from 'ordering-components/native';
18
19
  import { useTheme } from 'styled-components/native';
20
+ import Ionicons from 'react-native-vector-icons/Ionicons'
19
21
 
20
22
  import {
21
23
  Search,
@@ -25,7 +27,8 @@ import {
25
27
  HeaderWrapper,
26
28
  ListWrapper,
27
29
  FeaturedWrapper,
28
- OrderProgressWrapper
30
+ OrderProgressWrapper,
31
+ FarAwayMessage
29
32
  } from './styles';
30
33
 
31
34
  import { SearchBar } from '../SearchBar';
@@ -38,7 +41,7 @@ import { OrderTypeSelector } from '../OrderTypeSelector';
38
41
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
39
42
  import { BusinessFeaturedController } from '../BusinessFeaturedController';
40
43
  import { HighestRatedBusinesses } from '../HighestRatedBusinesses';
41
- import { getTypesText } from '../../utils';
44
+ import { getTypesText, convertToRadian } from '../../utils';
42
45
  import { OrderProgress } from '../OrderProgress';
43
46
  import { useIsFocused } from '@react-navigation/native';
44
47
 
@@ -85,6 +88,15 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
85
88
  },
86
89
  searchInput: {
87
90
  fontSize: 12,
91
+ },
92
+ iconStyle: {
93
+ fontSize: 18,
94
+ color: theme.colors.warning5,
95
+ marginRight: 8
96
+ },
97
+ farAwayMsg: {
98
+ paddingVertical: 6,
99
+ paddingHorizontal: 20
88
100
  }
89
101
  });
90
102
 
@@ -98,6 +110,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
98
110
  const { top } = useSafeAreaInsets();
99
111
 
100
112
  const [featuredBusiness, setFeaturedBusinesses] = useState(Array);
113
+ const [isFarAway, setIsFarAway] = useState(false)
101
114
 
102
115
  // const timerId = useRef<any>(false)
103
116
  // const panResponder = useRef(
@@ -127,6 +140,17 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
127
140
  }
128
141
  };
129
142
 
143
+ const getDistance = (lat1: any, lon1: any, lat2: any, lon2: any) => {
144
+ const R = 6371 // km
145
+ const dLat = convertToRadian(lat2 - lat1)
146
+ const dLon = convertToRadian(lon2 - lon1)
147
+ const curLat1 = convertToRadian(lat1)
148
+ const curLat2 = convertToRadian(lat2)
149
+ const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(curLat1) * Math.cos(curLat2)
150
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
151
+ return R * c
152
+ }
153
+
130
154
  useEffect(() => {
131
155
  if (businessesList.businesses.length > 0) {
132
156
  const fb = businessesList.businesses.filter((b) => b.featured == true);
@@ -148,6 +172,19 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
148
172
  // resetInactivityTimeout()
149
173
  // }, [])
150
174
 
175
+ useEffect(() => {
176
+ Geolocation.getCurrentPosition((pos) => {
177
+ const crd = pos.coords
178
+ const distance = getDistance(crd.latitude, crd.longitude, orderState?.options?.address?.location?.lat, orderState?.options?.address?.location?.lng)
179
+ if (distance > 20) setIsFarAway(true)
180
+ else setIsFarAway(false)
181
+ }, (err) => {
182
+ console.log(`ERROR(${err.code}): ${err.message}`)
183
+ }, {
184
+ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
185
+ })
186
+ }, [orderState?.options?.address?.location])
187
+
151
188
  return (
152
189
  <ScrollView style={styles.container} onScroll={(e) => handleScroll(e)} showsVerticalScrollIndicator={false}>
153
190
  <HeaderWrapper
@@ -180,6 +217,12 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
180
217
  </OText>
181
218
  </AddressInput>
182
219
  </Search>
220
+ {isFarAway && (
221
+ <FarAwayMessage style={styles.farAwayMsg}>
222
+ <Ionicons name='md-warning-outline' style={styles.iconStyle} />
223
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'Your are far from this address')}</OText>
224
+ </FarAwayMessage>
225
+ )}
183
226
  <OrderControlContainer>
184
227
  <View style={styles.wrapperOrderOptions}>
185
228
  <WrapMomentOption onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes })}>
@@ -73,4 +73,13 @@ export const OrderProgressWrapper = styled.View`
73
73
  margin-top: 37px;
74
74
  margin-bottom: 20px;
75
75
  padding-horizontal: 40px;
76
- `
76
+ `
77
+
78
+ export const FarAwayMessage = styled.View`
79
+ flex-direction: row;
80
+ align-items: center;
81
+ background-color: ${(props: any) => props.theme.colors.warning1};
82
+ margin-bottom: 25px;
83
+ border-radius: 7.6px;
84
+ border: 1px solid ${(props: any) => props.theme.colors.warning5};
85
+ `
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { View, StyleSheet, BackHandler, KeyboardAvoidingView, Platform } from 'react-native';
2
+ import { View, StyleSheet, BackHandler, KeyboardAvoidingView, Platform, Linking } from 'react-native';
3
3
  import Spinner from 'react-native-loading-spinner-overlay';
4
4
  import LinearGradient from 'react-native-linear-gradient';
5
5
  import { Messages } from '../Messages';
@@ -483,10 +483,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
483
483
  </OText>
484
484
  <Icons>
485
485
  <TouchableOpacity
486
- onPress={() =>
487
- props.navigation.navigate('Business', {
488
- store: businessData?.slug,
489
- })
486
+ onPress={() => order?.business?.cellphone &&
487
+ Linking.openURL(`tel:${order?.business?.cellphone}`)
490
488
  }
491
489
  style={{ paddingEnd: 5 }}>
492
490
  <OIcon
@@ -314,6 +314,41 @@ export const UserFormDetailsUI = (props: any) => {
314
314
  )}
315
315
  </WrapperPhone>
316
316
  )}
317
+ <Controller
318
+ control={control}
319
+ render={() => (
320
+ <>
321
+ <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
322
+ {t('PASSWORD', 'Password')}
323
+ </OText>
324
+ <OInput
325
+ name='password'
326
+ placeholder={t('FRONT_VISUALS_PASSWORD', 'Password')}
327
+ inputStyle={styles.inputStyle}
328
+ style={{ paddingLeft: 0, paddingRight: 0, marginTop: 6, height: 44, minHeight: 44 }}
329
+ autoCapitalize='none'
330
+ isDisabled={false}
331
+ value={
332
+ formState?.changes['password'] ??
333
+ (user && user['password']) ??
334
+ ''
335
+ }
336
+ onChange={(val: any) => {
337
+ setValue('password', val.target.value)
338
+ handleChangeInput(val)
339
+ }}
340
+ autoCorrect
341
+ type='default'
342
+ returnKeyType="done"
343
+ autoCompleteType='off'
344
+ isSecured
345
+ />
346
+ </>
347
+ )}
348
+ name='password'
349
+ rules={getInputRules({name: 'password', code: 'password'})}
350
+ defaultValue=''
351
+ />
317
352
  </UDWrapper>
318
353
  )}
319
354
  {validationFields?.loading && (
@@ -339,7 +374,7 @@ export const UserFormDetailsUI = (props: any) => {
339
374
  borderColor={theme.colors.primary}
340
375
  isDisabled={formState.loading}
341
376
  imgRightSrc={null}
342
- style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20 }}
377
+ style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20, marginBottom: 20 }}
343
378
  onClick={handleSubmit(onSubmit)}
344
379
  />
345
380
  )}
@@ -114,8 +114,9 @@ const ProfileUI = (props: ProfileParams) => {
114
114
  console.log('ImagePicker Error: ', response.errorMessage);
115
115
  showToast(ToastType.Error, response.errorMessage);
116
116
  } else {
117
- if (response.uri) {
118
- const url = `data:${response.type};base64,${response.base64}`;
117
+ if (response?.assets?.length > 0) {
118
+ const image = response?.assets[0]
119
+ const url = `data:${image.type};base64,${image.base64}`
119
120
  handleButtonUpdateClick(null, true, url);
120
121
  } else {
121
122
  showToast(ToastType.Error, t('IMAGE_NOT_FOUND', 'Image not found'));
@@ -33,8 +33,8 @@ export const VerifyPhone = (props: any) => {
33
33
 
34
34
  const styles = StyleSheet.create({
35
35
  inputStyle: {
36
- width: 80,
37
- height: 80,
36
+ width: 75,
37
+ height: 75,
38
38
  marginBottom: 25,
39
39
  borderWidth: 1,
40
40
  borderColor: theme.colors.disabled,
@@ -50,12 +50,21 @@ export const VerifyPhone = (props: any) => {
50
50
  const [timer, setTimer] = useState(`${TIME_COUNTDOWN / 60}:00`)
51
51
  const [verifyCode, setVerifyCode] = useState({ 0: '', 1: '', 2: '', 3: '' })
52
52
  const [isSendCodeAgain, setIsSendCodeAgain] = useState(false)
53
+ const inputRefs: any = [
54
+ React.createRef(),
55
+ React.createRef(),
56
+ React.createRef(),
57
+ React.createRef()
58
+ ]
53
59
 
54
60
  const lastNumbers = phone?.cellphone &&
55
61
  `${phone?.cellphone.charAt(phone?.cellphone.length - 2)}${phone?.cellphone.charAt(phone?.cellphone.length - 1)}`
56
62
 
57
- const handleChangeCode = (val: number, i: number) => {
63
+ const goNextAfterEdit = (val: number, i: number) => {
58
64
  setVerifyCode({ ...verifyCode, [i]: val })
65
+ if(val && i < inputRefs.length - 1) {
66
+ inputRefs[i+1].focus()
67
+ }
59
68
  }
60
69
 
61
70
  const checkResult = (result: any) => {
@@ -141,14 +150,15 @@ export const VerifyPhone = (props: any) => {
141
150
  </CountDownContainer>
142
151
  </WrappCountdown>
143
152
  <InputsSection>
144
- {[...Array(4),].map((_: any, i: number) => (
153
+ {inputRefs.map((k: any, idx: number) => (
145
154
  <TextInput
146
- key={i}
155
+ key={idx}
147
156
  keyboardType='number-pad'
148
- placeholder={'0'}
149
- style={styles.inputStyle}
150
- onChangeText={(val: any) => handleChangeCode(val, i)}
157
+ ref={r => inputRefs[idx] = r}
151
158
  maxLength={1}
159
+ style={styles.inputStyle}
160
+ placeholder={'0'}
161
+ onChangeText={(val: any) => goNextAfterEdit(val, idx)}
152
162
  editable={timer !== '00:00'}
153
163
  />
154
164
  ))}
@@ -173,11 +183,11 @@ export const VerifyPhone = (props: any) => {
173
183
  </ErrorSection>
174
184
  )}
175
185
  <ResendSection>
176
- <OText size={17} style={{ marginRight: 5 }}>
186
+ <OText size={16} style={{ marginRight: 5 }}>
177
187
  {t('ARE_YOU_NOT_SEEING_THE_CODE', 'Are you not seeing the code?')}
178
188
  </OText>
179
189
  <Pressable onPress={() => handleSendCodeAgain()}>
180
- <OText size={17} color={theme.colors.primary}>
190
+ <OText size={16} color={theme.colors.primary}>
181
191
  {t('SEND_AGAIN', 'Send Again')}
182
192
  </OText>
183
193
  </Pressable>
@@ -3,8 +3,8 @@ import styled from 'styled-components/native';
3
3
  export const Container = styled.View`
4
4
  width: 100%;
5
5
  padding-top: 5px;
6
- padding-left: 20px;
7
- padding-right: 20px;
6
+ padding-left: 40px;
7
+ padding-right: 40px;
8
8
  `
9
9
 
10
10
  export const CountDownContainer = styled.View`
@@ -168,4 +168,13 @@ export const transformCountryCode = (countryCode : number) => {
168
168
  export const getTypesText = (value: number) => {
169
169
  const ret = ORDER_TYPES.find((type: any) => type.value == value);
170
170
  return ret?.content;
171
+ }
172
+
173
+ /**
174
+ * Function to transform degree to radian
175
+ * @param {number} value for transform
176
+ *
177
+ */
178
+ export const convertToRadian = (value: number) => {
179
+ return value * Math.PI / 180
171
180
  }
@@ -41,10 +41,11 @@ const DriverTipsUI = (props: any) => {
41
41
  borderRadius: 30
42
42
  },
43
43
  inputStyle: {
44
+ borderColor: theme.colors.border,
45
+ borderRadius: 8,
46
+ marginRight: 20,
47
+ height: 44,
44
48
  flex: 1,
45
- borderWidth: 1,
46
- borderColor: theme.colors.disabled,
47
- marginRight: 10
48
49
  }
49
50
  })
50
51
 
@@ -117,21 +118,23 @@ const DriverTipsUI = (props: any) => {
117
118
  <OInput
118
119
  placeholder={placeholderCurrency}
119
120
  style={style.inputStyle}
121
+ inputStyle={{ fontSize: 12 }}
120
122
  onChange={handleChangeDriverTip}
121
123
  autoCapitalize='none'
122
124
  autoCorrect={false}
123
125
  />
124
126
  <OButton
125
- text={t('APPLY_TIP', 'Apply Tip')}
127
+ text={t('APPLY', 'Apply')}
126
128
  bgColor={theme.colors.primary}
127
129
  borderColor={theme.colors.primary}
128
- textStyle={{ color: 'white', fontSize: 20 }}
130
+ textStyle={{ color: 'white', fontSize: 12 }}
129
131
  imgRightSrc={null}
130
132
  isDisabled={!(value > 0 && value !== driverTip) || !value}
131
133
  onClick={() => {
132
134
  handlerChangeOption(value)
133
135
  setvalue(0)
134
136
  }}
137
+ style={{ borderRadius: 8, height: 44, shadowOpacity: 0 }}
135
138
  />
136
139
  </DTWrapperInput>
137
140
  {parseFloat(driverTip || 0) > 0 && (
@@ -60,5 +60,4 @@ export const DTWrapperInput = styled.View`
60
60
  flex-direction: row;
61
61
  align-items: center;
62
62
  justify-content: center;
63
- margin-top: 20px;
64
63
  `
@@ -192,19 +192,19 @@ const OrderSummaryUI = (props: any) => {
192
192
  {cart?.status !== 2 && (
193
193
  <OSTable>
194
194
  <View style={{ width: '100%', marginTop: 20 }}>
195
- <OText size={12}>{t('COMMENTS', 'Comments')}</OText>
195
+ <OText size={12} style={{ marginBottom: 10 }}>{t('COMMENTS', 'Comments')}</OText>
196
196
  <View style={{ flex: 1, width: '100%' }}>
197
197
  <OInput
198
198
  value={cart?.comment}
199
199
  placeholder={t('SPECIAL_COMMENTS', 'Special Comments')}
200
200
  onChange={(value: string) => handleChangeComment(value)}
201
201
  style={{
202
+ borderColor: theme.colors.border,
203
+ borderRadius: 10,
204
+ marginBottom: 20,
205
+ height: 104,
206
+ maxHeight: 104,
202
207
  alignItems: 'flex-start',
203
- width: '100%',
204
- height: 100,
205
- borderColor: theme.colors.textSecondary,
206
- paddingRight: 50,
207
- marginTop: 10
208
208
  }}
209
209
  multiline
210
210
  inputStyle={{ color: theme.colors.textPrimary, fontSize: 12 }}