ordering-ui-react-native 0.15.19 → 0.15.22

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.15.19",
3
+ "version": "0.15.22",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,5 +1,5 @@
1
- import React, { useState, useEffect } from 'react'
2
- import { View, StyleSheet, BackHandler, TouchableOpacity, I18nManager } from 'react-native'
1
+ import React, { useState, useEffect, useRef } from 'react'
2
+ import { View, StyleSheet, BackHandler, TouchableOpacity, I18nManager, AppState } from 'react-native'
3
3
  import LinearGradient from 'react-native-linear-gradient'
4
4
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
5
5
  import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
@@ -64,7 +64,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
64
64
  isFromRoot,
65
65
  driverLocation,
66
66
  goToBusinessList,
67
- onNavigationRedirect
67
+ onNavigationRedirect,
68
+ getOrder
68
69
  } = props
69
70
 
70
71
  const theme = useTheme()
@@ -108,6 +109,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
108
109
  const [isReviewed, setIsReviewed] = useState(false)
109
110
  const [openOrderCreating, setOpenOrderCreating] = useState(false)
110
111
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, tax: null, type: '' })
112
+ const appState = useRef(AppState.currentState)
113
+
111
114
  const { order, loading, businessData, error } = props.order
112
115
 
113
116
  const getOrderStatus = (s: string) => {
@@ -256,6 +259,24 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
256
259
  })
257
260
  }, [])
258
261
 
262
+ useEffect(() => {
263
+ const onFocusApp = (nextAppState: any) => {
264
+ if (
265
+ appState.current.match(/inactive|background/) &&
266
+ nextAppState === "active"
267
+ ) {
268
+ getOrder && getOrder()
269
+ }
270
+ appState.current = nextAppState;
271
+ }
272
+
273
+ AppState.addEventListener("change", onFocusApp);
274
+ return () => {
275
+ AppState.removeEventListener('change', onFocusApp);
276
+ };
277
+ }, [])
278
+
279
+
259
280
  return (
260
281
  <OrderDetailsContainer keyboardShouldPersistTaps='handled'>
261
282
  {order && order?.id && !error && !loading && (
@@ -287,6 +287,7 @@ export interface OrderDetailsParams {
287
287
  isFromRoot?: any;
288
288
  goToBusinessList?: any;
289
289
  onNavigationRedirect?: any;
290
+ getOrder?: () => {}
290
291
  }
291
292
  export interface ProductItemAccordionParams {
292
293
  key?: any;
@@ -631,6 +631,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
631
631
  getOrderStatus={getOrderStatus}
632
632
  handleClickOrder={handleClickOrder}
633
633
  slaSettingTime={slaSettingTime}
634
+ currentTabSelected={currentTabSelected}
634
635
  />
635
636
  )}
636
637
  {!logisticOrders?.error?.length &&
@@ -17,7 +17,8 @@ export const PreviousOrders = (props: any) => {
17
17
  handleClickOrder,
18
18
  isLogisticOrder,
19
19
  handleClickLogisticOrder,
20
- slaSettingTime
20
+ slaSettingTime,
21
+ currentTabSelected
21
22
  } = props;
22
23
  const [, t] = useLanguage();
23
24
  const [{ parseDate, optimizeImage }] = useUtils();
@@ -159,7 +160,7 @@ export const PreviousOrders = (props: any) => {
159
160
  />
160
161
  </NotificationIcon>
161
162
  )}
162
- <View style={{ flexDirection: 'row' }}>
163
+ <View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
163
164
  <OText
164
165
  style={styles.date}
165
166
  color={theme.colors.unselectText}
@@ -169,9 +170,14 @@ export const PreviousOrders = (props: any) => {
169
170
  {(order?.order_group_id && order?.order_group && isLogisticOrder ? `${order?.order_group?.orders?.length} ${t('ORDERS', 'Orders')}` : (t('NO', 'Order No.') + order.id)) + ' · '}
170
171
  {order?.delivery_datetime_utc
171
172
  ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'MM/DD/YY · HH:mm a' })
172
- : parseDate(order?.delivery_datetime, { utc: false })}{' · '}
173
+ : parseDate(order?.delivery_datetime, { utc: false })}
173
174
  </OText>
174
- <OText style={styles.date} color={order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : ''} >{getDelayTime(order)}</OText>
175
+ {(currentTabSelected === 'pending' || currentTabSelected === 'inProgress') && (
176
+ <>
177
+ <OText> · </OText>
178
+ <OText style={styles.date} color={order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : ''} >{getDelayTime(order)}</OText>
179
+ </>
180
+ )}
175
181
  </View>
176
182
  {!isLogisticOrder && (
177
183
  <MyOrderOptions>
@@ -87,6 +87,7 @@ const CouponControlUI = (props: any) => {
87
87
  ) : (
88
88
  <CCWrapper>
89
89
  <OInput
90
+ value={couponInput}
90
91
  placeholder={t('DISCOUNT_COUPON', 'Discount coupon')}
91
92
  onChange={(e: any) => onChangeInputCoupon(e)}
92
93
  style={styles.inputsStyle}
@@ -5,7 +5,7 @@ import {
5
5
  useLanguage,
6
6
  OrderDetails as OrderDetailsConTableoller,
7
7
  useUtils,
8
- useConfig,
8
+ useConfig
9
9
  } from 'ordering-components/native';
10
10
  import { useTheme } from 'styled-components/native';
11
11
  import {
@@ -28,6 +28,7 @@ import {
28
28
  OrderDriver,
29
29
  Map,
30
30
  Divider,
31
+ OrderAction
31
32
  } from './styles';
32
33
  import { OButton, OIcon, OModal, OText } from '../shared';
33
34
  import { ProductItemAccordion } from '../ProductItemAccordion';
@@ -48,6 +49,9 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
48
49
  readMessages,
49
50
  isFromCheckout,
50
51
  driverLocation,
52
+ onNavigationRedirect,
53
+ reorderState,
54
+ handleReorder
51
55
  } = props;
52
56
 
53
57
  const theme = useTheme();
@@ -83,11 +87,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
83
87
  const [, t] = useLanguage();
84
88
  const [{ parsePrice, parseNumber, parseDate }] = useUtils();
85
89
  const [{ configs }] = useConfig();
86
-
87
90
  const [isReviewed, setIsReviewed] = useState(false)
88
91
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, tax: null, type: '' })
89
92
 
90
- const { order } = props.order;
93
+ const { order, businessData } = props.order;
91
94
 
92
95
  const walletName: any = {
93
96
  cash: {
@@ -310,8 +313,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
310
313
  business: type === 'business',
311
314
  driver: type === 'driver',
312
315
  onClose: () => navigation?.canGoBack()
313
- ? navigation.goBack()
314
- : navigation.navigate('BottomTab', { screen: 'MyOrders' }),
316
+ ? navigation.goBack()
317
+ : navigation.navigate('BottomTab', { screen: 'MyOrders' }),
315
318
  }
316
319
  )
317
320
  }
@@ -356,6 +359,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
356
359
  )
357
360
  }
358
361
 
362
+
363
+ useEffect(() => {
364
+ if (reorderState?.error) {
365
+ navigation.navigate('Business', { store: businessData?.slug })
366
+ }
367
+ if (!reorderState?.error && reorderState?.result?.uuid) {
368
+ onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
369
+ }
370
+ }, [reorderState])
371
+
359
372
  useEffect(() => {
360
373
  BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
361
374
  return () => {
@@ -737,16 +750,37 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
737
750
  'Once business accepts your order, we will send you an email, thank you!',
738
751
  )}
739
752
  </OText>
740
- <OButton
741
- text={t('YOUR_ORDERS', 'Your Orders')}
742
- textStyle={{ fontSize: 14, color: theme.colors.primary }}
743
- imgRightSrc={null}
744
- borderColor={theme.colors.primary}
745
- bgColor={theme.colors.clear}
746
- style={{ borderRadius: 7.6, borderWidth: 1, height: 44, shadowOpacity: 0 }}
747
- parentStyle={{ marginTop: 29, width: '50%' }}
748
- onClick={() => navigation.navigate('BottomTab', { screen: 'MyOrders' })}
749
- />
753
+ <OrderAction>
754
+ <OButton
755
+ text={t('YOUR_ORDERS', 'Your Orders')}
756
+ textStyle={{ fontSize: 14, color: theme.colors.primary }}
757
+ imgRightSrc={null}
758
+ borderColor={theme.colors.primary}
759
+ bgColor={theme.colors.clear}
760
+ style={{ borderRadius: 7.6, borderWidth: 1, height: 44, shadowOpacity: 0 }}
761
+ parentStyle={{ marginTop: 29, marginEnd: 15 }}
762
+ onClick={() => navigation.navigate('BottomTab', { screen: 'MyOrders' })}
763
+ />
764
+ {(
765
+ parseInt(order?.status) === 1 ||
766
+ parseInt(order?.status) === 2 ||
767
+ parseInt(order?.status) === 5 ||
768
+ parseInt(order?.status) === 6 ||
769
+ parseInt(order?.status) === 10 ||
770
+ parseInt(order?.status) === 11 ||
771
+ parseInt(order?.status) === 12
772
+ ) && (
773
+ <OButton
774
+ text={order.id === reorderState?.loading ? t('LOADING', 'Loading..') : t('REORDER', 'Reorder')}
775
+ textStyle={{ fontSize: 14, color: theme.colors.primary }}
776
+ imgRightSrc={null}
777
+ borderColor='transparent'
778
+ bgColor={theme.colors.primary + 10}
779
+ style={{ borderRadius: 7.6, borderWidth: 1, height: 44, shadowOpacity: 0, marginTop: 29 }}
780
+ onClick={() => handleReorder && handleReorder(order.id)}
781
+ />
782
+ )}
783
+ </OrderAction>
750
784
  </HeaderInfo>
751
785
  <OrderProducts>
752
786
  {order?.products?.length &&
@@ -125,3 +125,6 @@ export const Divider = styled.View`
125
125
  margin-top: 5px;
126
126
  margin-bottom: 5px;
127
127
  `
128
+ export const OrderAction = styled.View`
129
+ flex-direction: row;
130
+ `
@@ -1,4 +1,4 @@
1
- import React, { Mixin } from 'react'
1
+ import React from 'react'
2
2
  import { useLanguage } from 'ordering-components/native'
3
3
  import { SingleProductCard } from '../SingleProductCard'
4
4
  import { TaxInformationContainer, ProductContainer } from './styles'
@@ -9,7 +9,7 @@ interface taxInformationParams {
9
9
  name: string,
10
10
  description?: string,
11
11
  rate: string | number,
12
- type: number,
12
+ type: string | number,
13
13
  fixed?: number,
14
14
  percentage?: number,
15
15
  id: number,
@@ -29,6 +29,10 @@ export const TaxInformation = (props: taxInformationParams) => {
29
29
  const [, t] = useLanguage()
30
30
 
31
31
  const includedOnPriceString = data?.type === 1 ? `(${t('INCLUDED_ON_PRICE', 'Included on price')})` : `(${t('NOT_INCLUDED_ON_PRICE', 'Not included on price')})`
32
+ const offersHideArray = ['offer_target_2', 'offer_target_3']
33
+ const hideProductsSectionOffers = offersHideArray.includes(type)
34
+ const dataHideArray : Array<string | number> = ['platform', 'business']
35
+ const hideProductsSectionData = dataHideArray.includes(data.type)
32
36
 
33
37
  const getFilterValidation = (product: any) => {
34
38
  return (
@@ -61,7 +65,7 @@ export const TaxInformation = (props: taxInformationParams) => {
61
65
  {t('WITHOUT_DESCRIPTION', 'Without description')}
62
66
  </OText>
63
67
  )}
64
- {!(type === 'offer_target_2' || type === 'offer_target_3') && (
68
+ {!hideProductsSectionOffers && !hideProductsSectionData && (
65
69
  <>
66
70
  <OText>{t('OTHER_PRODUCTS_WITH_THIS', 'Other products with this')} {getTypeString()}:</OText>
67
71
  <ProductContainer>
@@ -143,9 +143,9 @@ export interface BusinessesListingParams {
143
143
  export interface HighestRatedBusinessesParams {
144
144
  businessesList: { businesses: Array<any>, loading: boolean, error: null | string };
145
145
  onBusinessClick?: void;
146
- navigation? :any;
146
+ navigation?: any;
147
147
  isLoading?: boolean;
148
- getBusinesses: (newFetch : boolean) => void
148
+ getBusinesses: (newFetch: boolean) => void
149
149
  }
150
150
  export interface BusinessTypeFilterParams {
151
151
  businessTypes?: Array<any>;
@@ -182,7 +182,7 @@ export interface BusinessProductsListingParams {
182
182
  header?: any;
183
183
  logo?: any;
184
184
  productModal?: any;
185
- getNextProducts?: () => {};
185
+ getNextProducts?: () => {};
186
186
  handleChangeCategory: (value: any) => {};
187
187
  setProductLogin?: () => {};
188
188
  updateProductModal?: (value: any) => {};
@@ -209,8 +209,8 @@ export interface BusinessProductsCategoriesParams {
209
209
  categoriesLayout?: any;
210
210
  selectedCategoryId?: any;
211
211
  lazyLoadProductsRecommended?: any;
212
- setSelectedCategoryId?: any
213
- setCategoryClicked?: any
212
+ setSelectedCategoryId?: any
213
+ setCategoryClicked?: any
214
214
  }
215
215
  export interface BusinessProductsListParams {
216
216
  errors?: any;
@@ -321,7 +321,10 @@ export interface OrderDetailsParams {
321
321
  isFromCheckout?: boolean,
322
322
  driverLocation?: any,
323
323
  isFromRoot?: any,
324
- goToBusinessList?: boolean
324
+ goToBusinessList?: boolean,
325
+ onNavigationRedirect?: any,
326
+ reorderState?: any,
327
+ handleReorder?: any,
325
328
  }
326
329
  export interface ProductItemAccordionParams {
327
330
  key?: any;
@@ -355,7 +358,7 @@ export interface ReviewProductParams {
355
358
  formState?: any,
356
359
  handleChangeFormState?: any,
357
360
  handleSendProductReview?: any
358
- }
361
+ }
359
362
  export interface SingleProductReviewParams {
360
363
  product: any,
361
364
  formState?: any,
@@ -522,34 +525,34 @@ export interface HelpGuideParams {
522
525
  export interface HelpAccountAndPaymentParams {
523
526
  navigation: any;
524
527
  }
525
-
528
+
526
529
  export interface MessageListingParams {
527
530
  navigation: any;
528
531
  franchiseId?: any;
529
532
  }
530
533
 
531
- export interface BusinessSearchParams {
534
+ export interface BusinessSearchParams {
532
535
  navigation: any,
533
- businessesSearchList: any,
534
- onBusinessClick: any,
535
- handleChangeTermValue: (term: string) => void,
536
- termValue: string,
537
- paginationProps: any,
538
- handleSearchbusinessAndProducts: (newFetch?: boolean) => void,
539
- handleChangeFilters: (prop : string, value : any) => void,
540
- filters: any,
541
- businessTypes: Array<number>,
542
- setFilters: (filters: any) => void,
536
+ businessesSearchList: any,
537
+ onBusinessClick: any,
538
+ handleChangeTermValue: (term: string) => void,
539
+ termValue: string,
540
+ paginationProps: any,
541
+ handleSearchbusinessAndProducts: (newFetch?: boolean) => void,
542
+ handleChangeFilters: (prop: string, value: any) => void,
543
+ filters: any,
544
+ businessTypes: Array<number>,
545
+ setFilters: (filters: any) => void,
543
546
  lazySearch?: boolean
544
547
  }
545
-
548
+
546
549
  export interface NoNetworkParams {
547
550
  image?: any,
548
551
  }
549
552
 
550
553
  export interface PlaceSpotParams {
551
554
  isOpenPlaceSpot?: boolean,
552
- cart?: any ,
555
+ cart?: any,
553
556
  placesState?: any,
554
557
  handleChangePlace?: any,
555
558
  getPlacesList?: any,