ordering-ui-react-native 0.18.58-test → 0.18.59

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.18.58-test",
3
+ "version": "0.18.59",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -4,6 +4,7 @@ import { StyleSheet, View } from 'react-native';
4
4
 
5
5
  // Thirds
6
6
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
7
+ import Clipboard from '@react-native-clipboard/clipboard';
7
8
 
8
9
  //OrderingComponent
9
10
  import {
@@ -12,6 +13,7 @@ import {
12
13
  useToast,
13
14
  useSession,
14
15
  ToastType,
16
+ useUtils
15
17
  } from 'ordering-components/native';
16
18
 
17
19
  //Components
@@ -26,7 +28,7 @@ import { OrderDetailsParams } from '../../types';
26
28
  import { USER_TYPE } from '../../config/constants';
27
29
  import { useTheme } from 'styled-components/native';
28
30
  import { NotFoundSource } from '../NotFoundSource';
29
- import { getOrderStatus } from '../../utils';
31
+ import { verifyDecimals, getProductPrice, getOrderStatus } from '../../utils';
30
32
  import { OrderHeaderComponent } from './OrderHeaderComponent';
31
33
  import { OrderContentComponent } from './OrderContentComponent';
32
34
  //Styles
@@ -56,6 +58,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
56
58
  isGrantedPermissions,
57
59
  } = props;
58
60
  const [, { showToast }] = useToast();
61
+ const [{ parsePrice, parseNumber }] = useUtils();
59
62
  const { order } = props.order
60
63
  const theme = useTheme();
61
64
  const [, t] = useLanguage();
@@ -134,6 +137,163 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
134
137
  }
135
138
  };
136
139
 
140
+ const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
141
+ if (name !== 'No') {
142
+ const pos = position && position !== 'whole' ? `(${t(position.toUpperCase(), position)})` : '';
143
+ return pos
144
+ ? `${quantity} x ${name} ${pos} +${parsePrice(price)}\n`
145
+ : `${quantity} x ${name} +${parsePrice(price)}\n`;
146
+ } else {
147
+ return 'No\n';
148
+ }
149
+ };
150
+
151
+ const handleCopyClipboard = () => {
152
+ const businessName = !!order?.business?.name
153
+ ? `${order?.business?.name} \n`
154
+ : '';
155
+
156
+ const businessEmail = !!order?.business?.email
157
+ ? `${order?.business?.email} \n`
158
+ : '';
159
+
160
+ const businessCellphone = !!order?.business?.cellphone
161
+ ? `${order?.business?.cellphone} \n`
162
+ : '';
163
+
164
+ const businessPhone = !!order?.business?.phone
165
+ ? `${order?.business?.phone} \n`
166
+ : '';
167
+
168
+ const businessAddress = !!order?.business?.address
169
+ ? `${order?.business?.address} \n`
170
+ : '';
171
+
172
+ const businessSpecialAddress = !!order?.business?.address_notes
173
+ ? `${order?.business?.address_notes} \n \n`
174
+ : '';
175
+
176
+ const customerName = !!order?.customer?.name
177
+ ? `${order?.customer?.name} ${order?.customer?.middle_name || ''} ${order?.customer?.lastname || ''
178
+ } ${order?.customer?.second_lastname || ''} \n`
179
+ : '';
180
+
181
+ const customerEmail = !!order?.customer.email
182
+ ? `${order?.customer.email} \n`
183
+ : '';
184
+
185
+ const customerCellPhone = !!order?.customer?.cellphone
186
+ ? `${order?.customer?.cellphone} \n`
187
+ : '';
188
+
189
+ const customerPhone = !!order?.customer?.phone
190
+ ? `${order?.customer?.phone} \n`
191
+ : '';
192
+
193
+ const customerAddress = !!order?.customer?.address
194
+ ? `${order?.customer?.address} \n`
195
+ : '';
196
+
197
+ const customerSpecialAddress = !!order?.customer?.address_notes
198
+ ? `${order?.customer?.address_notes} \n`
199
+ : '';
200
+
201
+ const payment = order?.paymethod?.name
202
+ ? `${order?.paymethod?.name} - ${order.delivery_type === 1
203
+ ? t('DELIVERY', 'Delivery')
204
+ : order.delivery_type === 2
205
+ ? t('PICKUP', 'Pickup')
206
+ : order.delivery_type === 3
207
+ ? t('EAT_IN', 'Eat in')
208
+ : order.delivery_type === 4
209
+ ? t('CURBSIDE', 'Curbside')
210
+ : t('DRIVER_THRU', 'Driver thru')
211
+ }\n`
212
+ : '';
213
+
214
+ const getSuboptions = (suboptions: any) => {
215
+ const array: any = []
216
+ suboptions?.length > 0 &&
217
+ suboptions?.map((suboption: any) => {
218
+ const string = `${getFormattedSubOptionName(suboption)}`
219
+ array.push(string)
220
+ })
221
+
222
+ return array.join('')
223
+ }
224
+
225
+ const getOptions = (options: any, productComment: string = '') => {
226
+ const array: any = [];
227
+
228
+ options?.length &&
229
+ options?.map((option: any) => {
230
+ const string =
231
+ ` ${option.name}\n ${getSuboptions(option.suboptions)}`;
232
+
233
+ array.push(string)
234
+ })
235
+
236
+ if (productComment) {
237
+ array.push(` ${t('COMMENT', 'Comment')}\n ${productComment}\n`)
238
+ }
239
+
240
+ return array.join('')
241
+ }
242
+
243
+ const productsInArray =
244
+ order?.products.length &&
245
+ order?.products.map((product: any, i: number) => {
246
+ const string =
247
+ `${product?.quantity} X ${product?.name} ${parsePrice(product.total ?? getProductPrice(product))}\n${getOptions(product.options, product.comment)}`;
248
+
249
+ return i === 0 ? ` ${string}` : string
250
+ });
251
+
252
+ const productsInString = productsInArray.join(' ');
253
+ const orderDetails = `${t(
254
+ 'ORDER_DETAILS',
255
+ 'Order Details',
256
+ )}:\n${productsInString}\n`;
257
+
258
+ const subtotal = `${t('SUBTOTAL', 'Subtotal')}: ${parsePrice(
259
+ order?.subtotal,
260
+ )}\n`;
261
+
262
+ const drivertip = `${t('DRIVER_TIP', 'Driver tip')} ${parsePrice(
263
+ order?.summary?.driver_tip || order?.totalDriverTip,
264
+ )}\n`;
265
+
266
+ const deliveryFee = `${t('DELIVERY_FEE', 'Delivery fee')} ${verifyDecimals(
267
+ order?.service_fee,
268
+ parseNumber,
269
+ )}% ${parsePrice(order?.summary?.service_fee || order?.serviceFee || 0)}\n`;
270
+
271
+ const total = `${t('TOTAL', 'Total')} ${parsePrice(
272
+ order?.summary?.total || order?.total,
273
+ )}\n`;
274
+
275
+ const orderStatus = `${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id} ${t(
276
+ 'IS',
277
+ 'is',
278
+ )} ${getOrderStatus(order?.status, t)?.value}\n`;
279
+
280
+ Clipboard.setString(
281
+ `${orderStatus} ${payment} ${t(
282
+ 'BUSINESS_DETAILS',
283
+ 'Business Details',
284
+ )}\n ${businessName} ${businessEmail} ${businessCellphone} ${businessPhone} ${businessAddress} ${businessSpecialAddress}${t(
285
+ 'CUSTOMER_DETAILS',
286
+ 'Customer Details',
287
+ )}\n ${customerName} ${customerEmail} ${customerCellPhone} ${customerPhone} ${customerAddress} ${customerSpecialAddress}\n${orderDetails} ${subtotal} ${drivertip} ${deliveryFee} ${total}`,
288
+ );
289
+
290
+ showToast(
291
+ ToastType.Info,
292
+ t('COPY_TO_CLIPBOARD', 'Copy to clipboard.'),
293
+ 1000,
294
+ );
295
+ };
296
+
137
297
  const handleViewActionOrder = (action: string) => {
138
298
  if (!isGrantedPermissions) {
139
299
  navigation.navigate('RequestPermissions')
@@ -362,6 +522,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
362
522
  order={order}
363
523
  handleOpenMapView={handleOpenMapView}
364
524
  handleOpenMessagesForBusiness={handleOpenMessagesForBusiness}
525
+ handleCopyClipboard={handleCopyClipboard}
365
526
  getOrderStatus={getOrderStatus}
366
527
  handleArrowBack={handleArrowBack}
367
528
  logisticOrderStatus={logisticOrderStatus}
@@ -140,14 +140,16 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
140
140
  style={styles.icons}
141
141
  />
142
142
  </TouchableOpacity>
143
- <TouchableOpacity onPress={() => handleViewSummaryOrder?.()}>
144
- <SimpleLineIcons
145
- name='printer'
146
- color={theme.colors.textGray}
147
- size={20}
148
- style={styles.icons}
149
- />
150
- </TouchableOpacity>
143
+ {!!handleViewSummaryOrder && (
144
+ <TouchableOpacity onPress={() => handleViewSummaryOrder?.()}>
145
+ <SimpleLineIcons
146
+ name='printer'
147
+ color={theme.colors.textGray}
148
+ size={20}
149
+ style={styles.icons}
150
+ />
151
+ </TouchableOpacity>
152
+ )}
151
153
  </>
152
154
  )}
153
155
  <OIconButton
@@ -205,14 +207,16 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
205
207
  style={styles.icons}
206
208
  />
207
209
  </TouchableOpacity>
208
- <TouchableOpacity onPress={() => handleViewSummaryOrder?.()}>
209
- <SimpleLineIcons
210
- name='printer'
211
- color={theme.colors.textGray}
212
- size={20}
213
- style={styles.icons}
214
- />
215
- </TouchableOpacity>
210
+ {!!handleViewSummaryOrder && (
211
+ <TouchableOpacity onPress={() => handleViewSummaryOrder?.()}>
212
+ <SimpleLineIcons
213
+ name='printer'
214
+ color={theme.colors.textGray}
215
+ size={20}
216
+ style={styles.icons}
217
+ />
218
+ </TouchableOpacity>
219
+ )}
216
220
  </>
217
221
  )}
218
222
  <OIconButton
@@ -159,7 +159,7 @@ const ReviewCustomerUI = (props: ReviewCustomerParams) => {
159
159
  useEffect(() => {
160
160
  if (scrollref?.current) {
161
161
  Keyboard.addListener('keyboardDidShow', () => {
162
- scrollref.current.scrollToEnd()
162
+ scrollref?.current && scrollref.current.scrollToEnd()
163
163
  })
164
164
  }
165
165
  }, [scrollref?.current])
@@ -123,7 +123,7 @@ const AddressFormUI = (props: AddressFormParams) => {
123
123
  },
124
124
  wrapperNavbar: Platform.OS === 'ios'
125
125
  ? { paddingVertical: 0, paddingLeft: 40, paddingRight: 20 }
126
- : { paddingVertical: 10, paddingLeft: 40, paddingRight: 20 }
126
+ : { paddingVertical: 20, paddingLeft: 40, paddingRight: 20 }
127
127
  });
128
128
 
129
129
  const [, t] = useLanguage();
@@ -176,6 +176,7 @@ const AddressFormUI = (props: AddressFormParams) => {
176
176
 
177
177
  const getAddressFormatted = (address: any) => {
178
178
  const data: any = { address: null, error: null };
179
+ Geocoder.init(googleMapsApiKey);
179
180
  Geocoder.from(address)
180
181
  .then((json) => {
181
182
  if (json.results && json.results?.length > 0) {
@@ -490,10 +491,6 @@ const AddressFormUI = (props: AddressFormParams) => {
490
491
  }
491
492
  }, []);
492
493
 
493
- useEffect(() => {
494
- Geocoder.init(googleMapsApiKey);
495
- }, [googleMapsApiKey]);
496
-
497
494
  useEffect(() => {
498
495
  const keyboardDidShowListener = Keyboard.addListener(
499
496
  'keyboardDidShow',
@@ -538,7 +535,7 @@ const AddressFormUI = (props: AddressFormParams) => {
538
535
  />
539
536
  </View>
540
537
  <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
541
- <AddressFormContainer style={{ overflow: 'scroll' }}>
538
+ <AddressFormContainer style={{ height: HEIGHT_SCREEN * .78, overflow: 'scroll' }}>
542
539
  <View>
543
540
  <FormInput>
544
541
  <AutocompleteInput>
@@ -643,7 +640,6 @@ const AddressFormUI = (props: AddressFormParams) => {
643
640
  }
644
641
  }}
645
642
  IconButton={<OIcon src={theme.images.general.pin} width={16} />}
646
- isIntGeoCoder
647
643
  />
648
644
  </View>
649
645
  )}
@@ -665,7 +661,6 @@ const AddressFormUI = (props: AddressFormParams) => {
665
661
  saveLocation={saveMapLocation}
666
662
  setSaveLocation={setSaveMapLocation}
667
663
  handleToggleMap={handleToggleMap}
668
- isIntGeoCoder
669
664
  />
670
665
  </GoogleMapContainer>
671
666
  </View>
@@ -876,7 +871,6 @@ const AddressFormUI = (props: AddressFormParams) => {
876
871
  saveLocation={saveMapLocation}
877
872
  setSaveLocation={setSaveMapLocation}
878
873
  handleToggleMap={handleToggleMap}
879
- isIntGeoCoder
880
874
  />
881
875
  </GoogleMapContainer>
882
876
  )}
@@ -12,8 +12,7 @@ export const GPSButton = (props: any) => {
12
12
  handleGPS,
13
13
  apiKey,
14
14
  IconButton,
15
- IconLoadingButton,
16
- isIntGeoCoder
15
+ IconLoadingButton
17
16
  } = props
18
17
 
19
18
  const [isLoading, setLoading] = useState(false);
@@ -75,9 +74,8 @@ export const GPSButton = (props: any) => {
75
74
  }
76
75
 
77
76
  useEffect(() => {
78
- if (isIntGeoCoder) return
79
77
  Geocoder.init(apiKey);
80
- }, [isIntGeoCoder])
78
+ }, [])
81
79
 
82
80
  return (
83
81
  <GpsButtonStyle
@@ -18,8 +18,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
18
18
  saveLocation,
19
19
  setSaveLocation,
20
20
  handleToggleMap,
21
- locations,
22
- isIntGeoCoder
21
+ locations
23
22
  } = props
24
23
 
25
24
  const [, t] = useLanguage()
@@ -162,9 +161,8 @@ export const GoogleMap = (props: GoogleMapsParams) => {
162
161
  }
163
162
 
164
163
  useEffect(() => {
165
- if (isIntGeoCoder) return
166
164
  Geocoder.init(googleMapsApiKey)
167
- }, [isIntGeoCoder])
165
+ }, [])
168
166
 
169
167
  useEffect(() => {
170
168
  mapRef.current.animateToRegion({
@@ -256,10 +256,18 @@ const LoginFormUI = (props: LoginParams) => {
256
256
  setOtpType(type)
257
257
  }
258
258
 
259
- const handleLoginOtp = (code: string) => {
259
+ const handleLoginOtp = async (code: string) => {
260
260
  if (!code) return
261
- handleButtonLoginClick({ code })
262
- setWillVerifyOtpState(false)
261
+ const logged = await handleButtonLoginClick({ code })
262
+ if (logged){
263
+ setWillVerifyOtpState(false)
264
+ } else {
265
+ setAlertState({
266
+ open: true,
267
+ title: '',
268
+ content: t('OTP_CODE_INCORRECT', 'Otp code incorrect')
269
+ })
270
+ }
263
271
  }
264
272
 
265
273
  const closeAlert = () => {
@@ -90,6 +90,15 @@ const MultiCheckoutUI = (props: any) => {
90
90
  const isMultiDriverTips = configs?.checkout_multi_business_enabled?.value === '1'
91
91
  const walletCarts = (Object.values(carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && cart?.wallets) || null) || []
92
92
 
93
+ const walletName: any = {
94
+ cash: {
95
+ name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
96
+ },
97
+ credit_point: {
98
+ name: t('PAY_WITH_CREDITS_POINTS_WALLET', 'Pay with Credit Points Wallet'),
99
+ }
100
+ }
101
+
93
102
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
94
103
  ? JSON.parse(configs?.driver_tip_options?.value) || []
95
104
  : configs?.driver_tip_options?.value || []
@@ -413,6 +422,16 @@ const MultiCheckoutUI = (props: any) => {
413
422
  </OText>
414
423
  </View>
415
424
  )}
425
+ {!cartGroup?.loading && cartGroup?.result?.payment_events?.length > 0 && cartGroup?.result?.payment_events?.map((event: any) => (
426
+ <View key={event.id} style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
427
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
428
+ {walletName[cartGroup?.result?.wallets?.find((wallet: any) => wallet.wallet_id === event.wallet_id)?.type]?.name}
429
+ </OText>
430
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
431
+ -{parsePrice(event.amount, { isTruncable: true })}
432
+ </OText>
433
+ </View>
434
+ ))}
416
435
  <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
417
436
  <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
418
437
  {t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
@@ -629,8 +629,7 @@ export interface GoogleMapsParams {
629
629
  isSetInputs?: boolean,
630
630
  locations?: Array<any>,
631
631
  setSaveLocation?: (val: boolean) => void,
632
- handleToggleMap?: () => void,
633
- isIntGeoCoder: boolean
632
+ handleToggleMap?: () => void
634
633
  }
635
634
 
636
635
  export interface HelpParams {