ordering-ui-react-native 0.14.36 → 0.14.38-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 (58) 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 +32 -168
  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/PaymentOptions/index.tsx +3 -1
  12. package/src/components/PaymentOptionsWebView/index.tsx +150 -0
  13. package/src/components/ProductForm/index.tsx +6 -8
  14. package/src/components/SingleProductCard/index.tsx +1 -1
  15. package/src/components/StripeElementsForm/index.tsx +28 -13
  16. package/src/components/TaxInformation/index.tsx +58 -26
  17. package/src/components/UpsellingProducts/index.tsx +13 -31
  18. package/src/components/VerifyPhone/styles.tsx +1 -2
  19. package/src/components/shared/OIcon.tsx +4 -1
  20. package/src/index.tsx +2 -0
  21. package/src/navigators/HomeNavigator.tsx +6 -0
  22. package/src/pages/ProductDetails.tsx +55 -0
  23. package/src/types/index.tsx +2 -0
  24. package/src/types/react-native-color-matrix-image-filters/index.d.ts +1 -0
  25. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  26. package/themes/kiosk/src/components/Cart/index.tsx +14 -21
  27. package/themes/kiosk/src/components/CartItem/index.tsx +9 -7
  28. package/themes/kiosk/src/components/CustomerName/index.tsx +2 -1
  29. package/themes/kiosk/src/components/Intro/index.tsx +4 -4
  30. package/themes/kiosk/src/components/OptionCard/index.tsx +11 -6
  31. package/themes/kiosk/src/components/PaymentOptions/index.tsx +46 -44
  32. package/themes/original/index.tsx +4 -0
  33. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
  34. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -2
  35. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +35 -0
  36. package/themes/original/src/components/BusinessProductsListing/index.tsx +22 -49
  37. package/themes/original/src/components/BusinessesListing/index.tsx +100 -75
  38. package/themes/original/src/components/Cart/index.tsx +129 -52
  39. package/themes/original/src/components/Cart/styles.tsx +8 -1
  40. package/themes/original/src/components/Checkout/index.tsx +38 -2
  41. package/themes/original/src/components/Help/index.tsx +1 -1
  42. package/themes/original/src/components/Home/index.tsx +5 -3
  43. package/themes/original/src/components/MessageListing/index.tsx +4 -2
  44. package/themes/original/src/components/OrderDetails/index.tsx +117 -43
  45. package/themes/original/src/components/OrderDetails/styles.tsx +8 -1
  46. package/themes/original/src/components/OrderSummary/index.tsx +141 -51
  47. package/themes/original/src/components/OrderSummary/styles.tsx +7 -0
  48. package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
  49. package/themes/original/src/components/PaymentOptions/index.tsx +8 -2
  50. package/themes/original/src/components/ProductForm/index.tsx +67 -77
  51. package/themes/original/src/components/ProductForm/styles.tsx +9 -2
  52. package/themes/original/src/components/ProductOptionSubOption/index.tsx +3 -2
  53. package/themes/original/src/components/SingleProductCard/index.tsx +21 -11
  54. package/themes/original/src/components/SingleProductCard/styles.tsx +4 -0
  55. package/themes/original/src/components/StripeElementsForm/index.tsx +28 -13
  56. package/themes/original/src/components/TaxInformation/index.tsx +59 -27
  57. package/themes/original/src/components/UpsellingProducts/index.tsx +90 -84
  58. 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,26 @@ 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()
73
+ const [isCheckout, setIsCheckout] = useState(false)
74
+
75
+ const cart = carts?.[`businessId:${props.businessId}`] ?? {}
76
+ const cartProducts = cart?.products?.length
77
+ ? cart?.products.map((product: any) => product.id)
78
+ : []
79
+
80
+ const productsList = !upsellingProducts.loading && !upsellingProducts.error
81
+ ? upsellingProducts?.products?.length
82
+ ? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
83
+ : (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
84
+ : []
74
85
 
75
86
  useEffect(() => {
76
- if (!isCustomMode) {
87
+ if (!isCustomMode && !props.products) {
77
88
  if (!upsellingProducts.loading) {
78
89
  if (upsellingProducts?.products?.length && !isFromCart) {
79
90
  setCanOpenUpselling && setCanOpenUpselling(true)
@@ -81,25 +92,19 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
81
92
  handleUpsellingPage && handleUpsellingPage()
82
93
  }
83
94
  }
84
- // if ((!upsellingProducts?.products?.length && !upsellingProducts.loading && !canOpenUpselling && openUpselling) ||
85
- // (!upsellingProducts?.products?.length && !upsellingProducts.loading && openUpselling)) {
86
- // handleUpsellingPage && handleUpsellingPage()
87
- // }
88
95
  }
89
96
  }, [upsellingProducts.loading, upsellingProducts?.products.length])
90
97
 
91
98
  useEffect(() => {
92
- if (!cart?.validate && cart?.products?.length == 0) handleCloseUpsellingPage()
93
- }, [cart])
99
+ isCheckout && Object.keys(cart).length === 0 && onNavigationRedirect && onNavigationRedirect('MyOrders')
100
+ }, [cart, isCheckout])
94
101
 
95
102
  const handleFormProduct = (product: any) => {
96
- setActualProduct(product)
97
- setModalIsOpen(true)
98
- }
99
-
100
- const handleSaveProduct = () => {
101
- setActualProduct(null)
102
- setModalIsOpen(false)
103
+ onNavigationRedirect && onNavigationRedirect('ProductDetails', {
104
+ product: product,
105
+ businessId: product?.api?.businessId,
106
+ businessSlug: business.slug,
107
+ })
103
108
  }
104
109
 
105
110
  const UpsellingLayout = () => {
@@ -114,7 +119,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
114
119
  !upsellingProducts.loading && (
115
120
  <>
116
121
  {
117
- !upsellingProducts.error ? upsellingProducts.products.map((product: any) => (
122
+ !upsellingProducts.error ? productsList.map((product: any) => (
118
123
  <Item key={product.id}>
119
124
  <View style={{ flexBasis: '57%' }}>
120
125
  <Details>
@@ -125,7 +130,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
125
130
  <OText size={10} color={theme.colors.primary}>{t('ADD', 'Add')}</OText>
126
131
  </AddButton>
127
132
  </View>
128
- <View style={{}}>
133
+ <View>
129
134
  <OIcon url={product.images} style={styles.imageStyle} />
130
135
  </View>
131
136
  </Item>
@@ -143,75 +148,76 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
143
148
  )
144
149
  }
145
150
 
151
+ const UpsellingContent = () => {
152
+ return (
153
+ <>
154
+ <TopBar style={{ paddingTop: Platform.OS == 'ios' ? 10 : 30 }}>
155
+ <TopActions onPress={() => onGoBack()}>
156
+ <OIcon src={theme.images.general.arrow_left} width={15} />
157
+ </TopActions>
158
+ <TopActions style={styles.cancelBtn} onPress={() => handleUpsellingPage()}>
159
+ <OText size={12} color={theme.colors.textSecondary}>{t('CANCEL', 'Cancel')}</OText>
160
+ </TopActions>
161
+ </TopBar>
162
+ <ScrollView style={{ marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
163
+ <View style={{ paddingHorizontal: 40 }}>
164
+ <OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
165
+ <OrderSummary
166
+ cart={cart}
167
+ isCartPending={cart?.status === 2}
168
+ onNavigationRedirect={onNavigationRedirect}
169
+ />
170
+ </View>
171
+ {productsList.length > 0 &&
172
+ <View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
173
+ <OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
174
+ <UpsellingLayout />
175
+ </View>
176
+ }
177
+ </ScrollView>
178
+ <View
179
+ style={{
180
+ alignItems: 'center',
181
+ bottom: props.isPage ? 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
182
+ }}
183
+ >
184
+ <OButton
185
+ imgRightSrc=''
186
+ text={t('CHECKOUT', 'Checkout')}
187
+ style={{...styles.closeUpsellingButton}}
188
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
189
+ onClick={() => {
190
+ handleUpsellingPage()
191
+ setIsCheckout(true)
192
+ }}
193
+ />
194
+ </View>
195
+ </>
196
+ )
197
+ }
198
+
146
199
  return (
147
200
  <>
148
201
  {isCustomMode ? (
149
202
  <UpsellingLayout />
150
203
  ) : (
151
204
  <>
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
- )}
205
+ {props.isPage ? (
206
+ <UpsellingContent />
207
+ ) : (
208
+ canOpenUpselling && !modalIsOpen && (
209
+ <OBottomPopup
210
+ title={''}
211
+ open={openUpselling}
212
+ onClose={() => handleUpsellingPage()}
213
+ isStatusBar
214
+ >
215
+ <UpsellingContent />
216
+ </OBottomPopup>
217
+ )
218
+ )}
197
219
  </>
198
220
  )}
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
221
  </>
216
222
  )
217
223
  }
@@ -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
  }