ordering-ui-react-native 0.12.88 → 0.12.90

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.88",
3
+ "version": "0.12.90",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,7 +1,9 @@
1
1
  import React, { useState, useEffect, useRef } from 'react';
2
2
  import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons';
3
- import { View, StyleSheet, Platform, I18nManager, ScrollView } from 'react-native';
3
+ import { View, StyleSheet, Platform, I18nManager, ScrollView, TouchableOpacity } from 'react-native';
4
4
  import { initStripe, useConfirmPayment } from '@stripe/stripe-react-native';
5
+ import Picker from 'react-native-country-picker-modal';
6
+ import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
5
7
 
6
8
  import {
7
9
  Checkout as CheckoutController,
@@ -40,7 +42,9 @@ import {
40
42
  ChErrors,
41
43
  ChBusinessDetails,
42
44
  ChUserDetails,
43
- TextDetails
45
+ TextDetails,
46
+ DeliveryOptionsContainer,
47
+ DeliveryOptionItem
44
48
  } from './styles';
45
49
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
46
50
 
@@ -51,6 +55,7 @@ import { ActivityIndicator } from 'react-native-paper';
51
55
  import WebView from 'react-native-webview';
52
56
  import Icon from 'react-native-vector-icons/Feather';
53
57
  import { OrderCreating } from '../OrderCreating';
58
+ import { Item } from '../../../themes/uber-eats/src/components/UpsellingProducts/styles';
54
59
 
55
60
  const mapConfigs = {
56
61
  mapZoom: 16,
@@ -84,7 +89,11 @@ const CheckoutUI = (props: any) => {
84
89
  businessLogo,
85
90
  businessName,
86
91
  cartTotal,
87
- currency
92
+ currency,
93
+ deliveryOptionSelected,
94
+ instructionsOptions,
95
+ handleChangeDeliveryOption,
96
+
88
97
  } = props
89
98
 
90
99
  const theme = useTheme();
@@ -104,6 +113,12 @@ const CheckoutUI = (props: any) => {
104
113
  },
105
114
  paddSectionH: {
106
115
  paddingHorizontal: 20
116
+ },
117
+ icon: {
118
+ top: 15,
119
+ right: Platform.OS === 'ios' ? 5 : (I18nManager.isRTL ? 30 : 0),
120
+ position: 'absolute',
121
+ fontSize: 20
107
122
  }
108
123
  })
109
124
 
@@ -127,7 +142,7 @@ const CheckoutUI = (props: any) => {
127
142
  const [prog, setProg] = useState(true);
128
143
  const [openOrderCreating, setOpenOrderCreating] = useState(false)
129
144
  const [cardData, setCardData] = useState(null)
130
-
145
+ const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
131
146
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
132
147
  ? JSON.parse(configs?.driver_tip_options?.value) || []
133
148
  : configs?.driver_tip_options?.value || []
@@ -136,6 +151,12 @@ const CheckoutUI = (props: any) => {
136
151
  const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
137
152
  const cartsWithProducts = carts && Object.values(carts).filter((cart: any) => cart.products.length) || null
138
153
 
154
+ const deliveryOptions = instructionsOptions?.result && instructionsOptions?.result?.filter((option: any) => option?.enabled)?.map(option => {
155
+ return {
156
+ value: option?.id, key: option?.id, label: option?.name
157
+ }
158
+ })
159
+
139
160
  const handlePlaceOrder = () => {
140
161
  if (!userErrors.length) {
141
162
  setOpenOrderCreating(true)
@@ -221,6 +242,11 @@ const CheckoutUI = (props: any) => {
221
242
  setShowGateway({ open: false, closedByUser: true })
222
243
  }
223
244
 
245
+ const changeDeliveryOption = (option : any) => {
246
+ handleChangeDeliveryOption(option)
247
+ setIsDeliveryOptionModalVisible(false)
248
+ }
249
+
224
250
  useEffect(() => {
225
251
  if (validationFields && validationFields?.fields?.checkout) {
226
252
  checkValidationFields()
@@ -428,6 +454,56 @@ const CheckoutUI = (props: any) => {
428
454
  </ChBusinessDetails>
429
455
  </ChSection>
430
456
 
457
+ {!cartState.loading && deliveryOptionSelected !== undefined && options?.type === 1 && (
458
+ <DeliveryOptionsContainer style={style.paddSection}>
459
+ <OText size={20}>{t('DELIVERY_OPTIONS', 'Delivery options')}</OText>
460
+ <View
461
+ style={{
462
+ backgroundColor: theme.colors.inputDisabled,
463
+ borderRadius: 7.5,
464
+ marginBottom: 20,
465
+ flex: 1
466
+ }}>
467
+ <Picker
468
+ countryCode={undefined}
469
+ visible={isDeliveryOptionModalVisible}
470
+ onClose={() => setIsDeliveryOptionModalVisible(false)}
471
+ withCountryNameButton
472
+ renderFlagButton={() => (
473
+ <TouchableOpacity onPress={() => setIsDeliveryOptionModalVisible(true)}>
474
+ <DeliveryOptionItem backgroundColor={theme?.colors?.inputDisabled}>
475
+ <OText
476
+ size={16}
477
+ >
478
+ {deliveryOptions.find((option: any) => option.value === deliveryOptionSelected).label}
479
+ </OText>
480
+ <MaterialIcons name='keyboard-arrow-down' style={style.icon} />
481
+ </DeliveryOptionItem>
482
+ </TouchableOpacity>
483
+ )}
484
+ flatListProps={{
485
+ keyExtractor: (item: any) => item.value,
486
+ data: deliveryOptions || [],
487
+ renderItem: ({ item }: any) => (
488
+ <TouchableOpacity
489
+ onPress={() => changeDeliveryOption(item.value)}
490
+ disabled={
491
+ deliveryOptionSelected === item.value
492
+ }
493
+ >
494
+ <DeliveryOptionItem backgroundColor={deliveryOptionSelected === item.value ? theme.colors.inputDisabled : 'white'}>
495
+ <OText>
496
+ {item.label}
497
+ </OText>
498
+ </DeliveryOptionItem>
499
+ </TouchableOpacity>
500
+ )
501
+ }}
502
+ />
503
+ </View>
504
+ </DeliveryOptionsContainer>
505
+ )}
506
+
431
507
  {!cartState.loading &&
432
508
  cart &&
433
509
  cart?.valid &&
@@ -97,3 +97,16 @@ export const ChErrors = styled.View`
97
97
  align-items: center;
98
98
  margin-bottom: 20px;
99
99
  `
100
+
101
+ export const DeliveryOptionsContainer = styled.View`
102
+ flex: 1;
103
+ margin-top: 10px;
104
+ `
105
+
106
+ export const DeliveryOptionItem = styled.View`
107
+ padding: 15px;
108
+ justify-content: ${(props : any) => props.center ? 'center' : 'space-between'};
109
+ align-items: center;
110
+ flex-direction: row;
111
+ background-color: ${(props : any) => props?.backgroundColor ?? '#fff'};
112
+ `;
@@ -376,6 +376,18 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
376
376
  <OText style={{ textAlign: 'left' }}>{order?.customer?.address}</OText>
377
377
  </InfoBlock>
378
378
  </Customer>
379
+ {order?.delivery_option !== undefined && order?.delivery_type === 1 && (
380
+ <View>
381
+ <OText size={18} style={{ textAlign: 'left' }}>{t('DELIVERY_PREFERENCE', 'Delivery Preference')}</OText>
382
+ <OText style={{ textAlign: 'left' }}>{order?.delivery_option?.name}</OText>
383
+ </View>
384
+ )}
385
+ {order?.comment && (
386
+ <View>
387
+ <OText size={18} style={{ textAlign: 'left' }} >{t('COMMENT', 'Comment')}</OText>
388
+ <OText style={{ textAlign: 'left' }}>{order?.comment}</OText>
389
+ </View>
390
+ )}
379
391
  {order?.driver && (
380
392
  <>
381
393
  {order?.driver?.location && parseInt(order?.status) === 9 && (
@@ -490,19 +502,19 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
490
502
  ))
491
503
  }
492
504
  {
493
- order?.fees?.length > 0 && order?.fees?.filter((fee : any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
494
- <Table key={fee.id}>
495
- <OSRow>
496
- <OText numberOfLines={1}>
497
- {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
498
- ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
499
- </OText>
500
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })}>
501
- <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
502
- </TouchableOpacity>
503
- </OSRow>
504
- <OText>{parsePrice(fee?.fixed + fee?.summary?.percentage || 0)}</OText>
505
- </Table>
505
+ order?.fees?.length > 0 && order?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
506
+ <Table key={fee.id}>
507
+ <OSRow>
508
+ <OText numberOfLines={1}>
509
+ {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
510
+ ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
511
+ </OText>
512
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })}>
513
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
514
+ </TouchableOpacity>
515
+ </OSRow>
516
+ <OText>{parsePrice(fee?.fixed + fee?.summary?.percentage || 0)}</OText>
517
+ </Table>
506
518
  ))
507
519
  }
508
520
  {order?.summary?.delivery_price > 0 && (
@@ -533,14 +545,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
533
545
  </OText>
534
546
  </Table>
535
547
  </Total>
536
- {order?.comment && (
537
- <Table>
538
- <OText style={{flex: 1}}>{t('COMMENT', 'Comment')}</OText>
539
- <OText style={{maxWidth: '70%'}}>
540
- {order?.comment}
541
- </OText>
542
- </Table>
543
- )}
544
548
  {
545
549
  (
546
550
  parseInt(order?.status) === 1 ||
@@ -271,6 +271,20 @@ export const OrderContentComponent = (props: OrderContent) => {
271
271
  {order?.customer?.zipcode}
272
272
  </OText>
273
273
  )}
274
+ {((order?.delivery_option !== undefined && order?.delivery_type === 1) || !!order?.comment) && (
275
+ <View style={{marginTop: 10}}>
276
+ {order?.delivery_option !== undefined && order?.delivery_type === 1 && (
277
+ <OText>
278
+ {order?.delivery_option?.name}
279
+ </OText>
280
+ )}
281
+ {!!order?.comment && (
282
+ <OText style={{fontStyle: 'italic', opacity: 0.6, marginBottom: 5}}>
283
+ {order?.comment}
284
+ </OText>
285
+ )}
286
+ </View>
287
+ )}
274
288
  {!order?.user_review && pastOrderStatuses.includes(order?.status) && (
275
289
  <OButton
276
290
  style={styles.btnReview}
@@ -440,14 +454,6 @@ export const OrderContentComponent = (props: OrderContent) => {
440
454
  {parsePrice(order?.summary?.total ?? 0)}
441
455
  </OText>
442
456
  </Table>
443
- {!!order?.comment && (
444
- <Table>
445
- <OText style={{ flex: 1 }}>{t('COMMENT', 'Comment')}</OText>
446
- <OText style={{ maxWidth: '70%' }}>
447
- {order?.comment}
448
- </OText>
449
- </Table>
450
- )}
451
457
  </Total>
452
458
  </OrderBill >
453
459
  <OModal
@@ -95,6 +95,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
95
95
 
96
96
  const [openModalForBusiness, setOpenModalForBusiness] = useState(false);
97
97
  const [openModalForDriver, setOpenModalForDriver] = useState(false);
98
+ const [isReviewed, setIsReviewed] = useState(false)
98
99
  const [unreadAlert, setUnreadAlert] = useState({
99
100
  business: false,
100
101
  driver: false,
@@ -339,6 +340,24 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
339
340
  }
340
341
  }
341
342
 
343
+ const handleClickOrderReview = (order: any) => {
344
+ navigation.navigate(
345
+ 'ReviewOrder',
346
+ {
347
+ order: {
348
+ id: order?.id,
349
+ business_id: order?.business_id,
350
+ logo: order.business?.logo,
351
+ driver: order?.driver,
352
+ products: order?.products,
353
+ review: order?.review,
354
+ user_review: order?.user_review
355
+ },
356
+ setIsReviewed
357
+ }
358
+ )
359
+ }
360
+
342
361
  useEffect(() => {
343
362
  BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
344
363
  return () => {
@@ -382,6 +401,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
382
401
  }
383
402
  }, [driverLocation]);
384
403
 
404
+ useEffect(() => {
405
+ console.log('order: ', order)
406
+ }, [order]);
407
+
385
408
  return (
386
409
  <OrderDetailsContainer keyboardShouldPersistTaps="handled">
387
410
  <Spinner visible={!order || Object.keys(order).length === 0} />
@@ -409,19 +432,28 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
409
432
  ? parseDate(order?.delivery_datetime_utc)
410
433
  : parseDate(order?.delivery_datetime, { utc: false })}
411
434
  </OText>
412
- <TouchableOpacity
413
- activeOpacity={0.7}
414
- style={{ marginTop: 6 }}
415
- onPress={() => { }}>
416
- <OText
417
- size={10}
418
- lineHeight={15}
419
- color={theme.colors.textSecondary}
420
- style={{ textDecorationLine: 'underline' }}>
421
- {t('REVIEW_ORDER', 'Review order')}
422
- </OText>
423
- </TouchableOpacity>
435
+ {
436
+ (
437
+ parseInt(order?.status) === 1 ||
438
+ parseInt(order?.status) === 11 ||
439
+ parseInt(order?.status) === 15
440
+ ) && !order.review && !isReviewed && (
441
+ <TouchableOpacity
442
+ activeOpacity={0.7}
443
+ style={{ marginTop: 6 }}
444
+ onPress={() => handleClickOrderReview(order)}
424
445
 
446
+ >
447
+ <OText
448
+ size={10}
449
+ lineHeight={15}
450
+ color={theme.colors.textSecondary}
451
+ style={{ textDecorationLine: 'underline' }}
452
+ >
453
+ {t('REVIEW_YOUR_ORDER', 'Review your order')}
454
+ </OText>
455
+ </TouchableOpacity>
456
+ )}
425
457
  <StaturBar>
426
458
  <LinearGradient
427
459
  start={{ x: 0.0, y: 0.0 }}