ordering-ui-react-native 0.14.34 → 0.14.36-release

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.
Files changed (54) hide show
  1. package/package.json +2 -2
  2. package/src/components/BusinessItemAccordion/index.tsx +2 -2
  3. package/src/components/BusinessProductsListing/index.tsx +10 -26
  4. package/src/components/Cart/index.tsx +136 -62
  5. package/src/components/Cart/styles.tsx +7 -0
  6. package/src/components/Checkout/index.tsx +10 -6
  7. package/src/components/OrderDetails/index.tsx +102 -34
  8. package/src/components/OrderDetails/styles.tsx +7 -0
  9. package/src/components/OrderSummary/index.tsx +142 -58
  10. package/src/components/OrderSummary/styles.tsx +10 -2
  11. package/src/components/ProductForm/index.tsx +6 -8
  12. package/src/components/SingleProductCard/index.tsx +1 -1
  13. package/src/components/StripeElementsForm/index.tsx +28 -13
  14. package/src/components/TaxInformation/index.tsx +58 -26
  15. package/src/components/UpsellingProducts/index.tsx +13 -31
  16. package/src/components/VerifyPhone/styles.tsx +1 -2
  17. package/src/navigators/HomeNavigator.tsx +6 -0
  18. package/src/pages/ProductDetails.tsx +55 -0
  19. package/src/types/index.tsx +2 -0
  20. package/src/types/react-native-color-matrix-image-filters/index.d.ts +1 -0
  21. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  22. package/themes/kiosk/src/components/Cart/index.tsx +14 -21
  23. package/themes/kiosk/src/components/CartItem/index.tsx +9 -7
  24. package/themes/kiosk/src/components/CustomerName/index.tsx +2 -1
  25. package/themes/kiosk/src/components/Intro/index.tsx +4 -4
  26. package/themes/kiosk/src/components/OptionCard/index.tsx +11 -6
  27. package/themes/kiosk/src/components/PaymentOptions/index.tsx +46 -44
  28. package/themes/original/index.tsx +4 -0
  29. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
  30. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -2
  31. package/themes/original/src/components/BusinessPreorder/index.tsx +37 -35
  32. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +35 -0
  33. package/themes/original/src/components/BusinessProductsListing/index.tsx +22 -49
  34. package/themes/original/src/components/BusinessesListing/index.tsx +100 -75
  35. package/themes/original/src/components/Cart/index.tsx +129 -52
  36. package/themes/original/src/components/Cart/styles.tsx +8 -1
  37. package/themes/original/src/components/Checkout/index.tsx +2 -0
  38. package/themes/original/src/components/FacebookLogin/index.tsx +20 -5
  39. package/themes/original/src/components/Help/index.tsx +1 -1
  40. package/themes/original/src/components/Home/index.tsx +5 -3
  41. package/themes/original/src/components/MessageListing/index.tsx +4 -2
  42. package/themes/original/src/components/OrderDetails/index.tsx +117 -43
  43. package/themes/original/src/components/OrderDetails/styles.tsx +8 -1
  44. package/themes/original/src/components/OrderSummary/index.tsx +141 -51
  45. package/themes/original/src/components/OrderSummary/styles.tsx +7 -0
  46. package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
  47. package/themes/original/src/components/ProductForm/index.tsx +67 -77
  48. package/themes/original/src/components/ProductForm/styles.tsx +9 -2
  49. package/themes/original/src/components/SingleProductCard/index.tsx +21 -11
  50. package/themes/original/src/components/SingleProductCard/styles.tsx +4 -0
  51. package/themes/original/src/components/StripeElementsForm/index.tsx +28 -13
  52. package/themes/original/src/components/TaxInformation/index.tsx +59 -27
  53. package/themes/original/src/components/UpsellingProducts/index.tsx +85 -83
  54. package/themes/original/src/types/index.tsx +6 -0
@@ -4,9 +4,10 @@ import {
4
4
  UpsellingPage as UpsellingPageController,
5
5
  useUtils,
6
6
  useLanguage,
7
+ useOrder
7
8
  } from 'ordering-components/native'
8
9
  import { useTheme } from 'styled-components/native';
9
- import { OText, OIcon, OModal, OBottomPopup, OButton } from '../shared'
10
+ import { OText, OIcon, OBottomPopup, OButton } from '../shared'
10
11
  import { UpsellingProductsParams } from '../../types'
11
12
  import {
12
13
  Container,
@@ -14,11 +15,9 @@ import {
14
15
  Item,
15
16
  Details,
16
17
  AddButton,
17
- CloseUpselling,
18
18
  TopBar,
19
19
  TopActions
20
20
  } from './styles'
21
- import { ProductForm } from '../ProductForm';
22
21
  import { OrderSummary } from '../OrderSummary';
23
22
  import { ScrollView } from 'react-native-gesture-handler';
24
23
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -28,18 +27,18 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
28
27
  isCustomMode,
29
28
  upsellingProducts,
30
29
  business,
31
- cart,
32
30
  handleUpsellingPage,
33
31
  handleCloseUpsellingPage,
34
32
  openUpselling,
35
33
  canOpenUpselling,
36
34
  setCanOpenUpselling,
37
- isFromCart
35
+ isFromCart,
36
+ onNavigationRedirect,
37
+ onGoBack
38
38
  } = props
39
39
 
40
40
  const theme = useTheme();
41
41
 
42
-
43
42
  const styles = StyleSheet.create({
44
43
  imageStyle: {
45
44
  width: 73,
@@ -66,14 +65,25 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
66
65
  }
67
66
  })
68
67
 
69
- const [actualProduct, setActualProduct] = useState<any>(null)
70
68
  const [modalIsOpen, setModalIsOpen] = useState(false)
69
+ const [{ carts }] = useOrder()
71
70
  const [{ parsePrice }] = useUtils()
72
71
  const [, t] = useLanguage()
73
72
  const { bottom } = useSafeAreaInsets()
74
73
 
74
+ const cart = carts?.[`businessId:${props.businessId}`] ?? {}
75
+ const cartProducts = cart?.products?.length
76
+ ? cart?.products.map((product: any) => product.id)
77
+ : []
78
+
79
+ const productsList = !upsellingProducts.loading && !upsellingProducts.error
80
+ ? upsellingProducts?.products?.length
81
+ ? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
82
+ : (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
83
+ : []
84
+
75
85
  useEffect(() => {
76
- if (!isCustomMode) {
86
+ if (!isCustomMode && !props.products) {
77
87
  if (!upsellingProducts.loading) {
78
88
  if (upsellingProducts?.products?.length && !isFromCart) {
79
89
  setCanOpenUpselling && setCanOpenUpselling(true)
@@ -81,25 +91,19 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
81
91
  handleUpsellingPage && handleUpsellingPage()
82
92
  }
83
93
  }
84
- // if ((!upsellingProducts?.products?.length && !upsellingProducts.loading && !canOpenUpselling && openUpselling) ||
85
- // (!upsellingProducts?.products?.length && !upsellingProducts.loading && openUpselling)) {
86
- // handleUpsellingPage && handleUpsellingPage()
87
- // }
88
94
  }
89
95
  }, [upsellingProducts.loading, upsellingProducts?.products.length])
90
96
 
91
97
  useEffect(() => {
92
- if (!cart?.validate && cart?.products?.length == 0) handleCloseUpsellingPage()
98
+ Object.keys(cart).length === 0 && onNavigationRedirect && onNavigationRedirect('MyOrders')
93
99
  }, [cart])
94
100
 
95
101
  const handleFormProduct = (product: any) => {
96
- setActualProduct(product)
97
- setModalIsOpen(true)
98
- }
99
-
100
- const handleSaveProduct = () => {
101
- setActualProduct(null)
102
- setModalIsOpen(false)
102
+ onNavigationRedirect && onNavigationRedirect('ProductDetails', {
103
+ product: product,
104
+ businessId: product?.api?.businessId,
105
+ businessSlug: business.slug,
106
+ })
103
107
  }
104
108
 
105
109
  const UpsellingLayout = () => {
@@ -114,7 +118,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
114
118
  !upsellingProducts.loading && (
115
119
  <>
116
120
  {
117
- !upsellingProducts.error ? upsellingProducts.products.map((product: any) => (
121
+ !upsellingProducts.error ? productsList.map((product: any) => (
118
122
  <Item key={product.id}>
119
123
  <View style={{ flexBasis: '57%' }}>
120
124
  <Details>
@@ -125,7 +129,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
125
129
  <OText size={10} color={theme.colors.primary}>{t('ADD', 'Add')}</OText>
126
130
  </AddButton>
127
131
  </View>
128
- <View style={{}}>
132
+ <View>
129
133
  <OIcon url={product.images} style={styles.imageStyle} />
130
134
  </View>
131
135
  </Item>
@@ -143,75 +147,73 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
143
147
  )
144
148
  }
145
149
 
150
+ const UpsellingContent = () => {
151
+ return (
152
+ <>
153
+ <TopBar style={{ paddingTop: Platform.OS == 'ios' ? 10 : 30 }}>
154
+ <TopActions onPress={() => onGoBack()}>
155
+ <OIcon src={theme.images.general.arrow_left} width={15} />
156
+ </TopActions>
157
+ <TopActions style={styles.cancelBtn} onPress={() => handleUpsellingPage()}>
158
+ <OText size={12} color={theme.colors.textSecondary}>{t('CANCEL', 'Cancel')}</OText>
159
+ </TopActions>
160
+ </TopBar>
161
+ <ScrollView style={{ marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
162
+ <View style={{ paddingHorizontal: 40 }}>
163
+ <OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
164
+ <OrderSummary
165
+ cart={cart}
166
+ isCartPending={cart?.status === 2}
167
+ onNavigationRedirect={onNavigationRedirect}
168
+ />
169
+ </View>
170
+ {productsList.length > 0 &&
171
+ <View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
172
+ <OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
173
+ <UpsellingLayout />
174
+ </View>
175
+ }
176
+ </ScrollView>
177
+ <View
178
+ style={{
179
+ alignItems: 'center',
180
+ bottom: props.isPage ? 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
181
+ }}
182
+ >
183
+ <OButton
184
+ imgRightSrc=''
185
+ text={t('CHECKOUT', 'Checkout')}
186
+ style={{...styles.closeUpsellingButton}}
187
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
188
+ onClick={() => handleUpsellingPage()}
189
+ />
190
+ </View>
191
+ </>
192
+ )
193
+ }
194
+
146
195
  return (
147
196
  <>
148
197
  {isCustomMode ? (
149
198
  <UpsellingLayout />
150
199
  ) : (
151
200
  <>
152
- {!canOpenUpselling ? null : (
153
- <>
154
- {!modalIsOpen && (
155
- <OBottomPopup
156
- title={''}
157
- open={openUpselling}
158
- onClose={() => handleUpsellingPage()}
159
- isStatusBar
160
- >
161
- <TopBar style={{ paddingTop: Platform.OS == 'ios' ? 10 : 30 }}>
162
- <TopActions onPress={() => handleCloseUpsellingPage()}>
163
- <OIcon src={theme.images.general.arrow_left} width={15} />
164
- </TopActions>
165
- <TopActions style={styles.cancelBtn} onPress={() => handleCloseUpsellingPage()}>
166
- <OText size={12} color={theme.colors.textSecondary}>{t('CANCEL', 'Cancel')}</OText>
167
- </TopActions>
168
- </TopBar>
169
- <ScrollView style={{ marginBottom: bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
170
- {upsellingProducts?.products?.length > 0 &&
171
- <View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
172
- <OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
173
- <UpsellingLayout />
174
- </View>
175
- }
176
- <View style={{ paddingHorizontal: 40 }}>
177
- <OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
178
- <OrderSummary
179
- cart={cart}
180
- isCartPending={cart?.status === 2}
181
- />
182
- </View>
183
- </ScrollView>
184
- <View style={{alignItems: 'center', bottom: Platform.OS === 'ios' ? bottom + 59 : bottom + 125}}>
185
- <OButton
186
- imgRightSrc=''
187
- text={t('CHECKOUT', 'Checkout')}
188
- style={{...styles.closeUpsellingButton}}
189
- textStyle={{ color: theme.colors.white, fontSize: 14 }}
190
- onClick={() => handleUpsellingPage()}
191
- />
192
- </View>
193
- </OBottomPopup>
194
- )}
195
- </>
196
- )}
201
+ {props.isPage ? (
202
+ <UpsellingContent />
203
+ ) : (
204
+ canOpenUpselling && !modalIsOpen && (
205
+ <OBottomPopup
206
+ title={''}
207
+ open={openUpselling}
208
+ onClose={() => handleUpsellingPage()}
209
+ isStatusBar
210
+ >
211
+ <UpsellingContent />
212
+ </OBottomPopup>
213
+ )
214
+ )}
197
215
  </>
198
216
  )}
199
- <OModal
200
- open={modalIsOpen}
201
- onClose={() => setModalIsOpen(false)}
202
- entireModal
203
- customClose
204
- >
205
- {actualProduct && (
206
- <ProductForm
207
- product={actualProduct}
208
- businessId={actualProduct?.api?.businessId}
209
- businessSlug={business.slug}
210
- onSave={() => handleSaveProduct()}
211
- onClose={() => setModalIsOpen(false)}
212
- />
213
- )}
214
- </OModal>
215
217
  </>
216
218
  )
217
219
  }
@@ -253,6 +253,7 @@ export interface NotFoundSourceParams {
253
253
  }
254
254
  export interface OrdersOptionParams {
255
255
  orderList?: any,
256
+ franchiseId?: any,
256
257
  activeOrders?: boolean,
257
258
  pagination?: any,
258
259
  titleContent?: string,
@@ -438,6 +439,10 @@ export interface UpsellingProductsParams {
438
439
  cart?: any;
439
440
  handleCloseUpsellingPage: () => void;
440
441
  isFromCart?: boolean;
442
+ isPage?: boolean;
443
+ products?: any;
444
+ onNavigationRedirect?: any;
445
+ onGoBack?: any;
441
446
  }
442
447
 
443
448
  export interface GoogleMapsParams {
@@ -478,4 +483,5 @@ export interface HelpAccountAndPaymentParams {
478
483
 
479
484
  export interface MessageListingParams {
480
485
  navigation: any;
486
+ franchiseId?: any;
481
487
  }