ordering-ui-react-native 0.14.31 → 0.14.32-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 +10 -6
  7. package/src/components/LogoutButton/index.tsx +14 -0
  8. package/src/components/OrderDetails/index.tsx +102 -34
  9. package/src/components/OrderDetails/styles.tsx +7 -0
  10. package/src/components/OrderSummary/index.tsx +142 -58
  11. package/src/components/OrderSummary/styles.tsx +10 -2
  12. package/src/components/ProductForm/index.tsx +47 -10
  13. package/src/components/ProductForm/styles.tsx +1 -1
  14. package/src/components/SingleProductCard/index.tsx +1 -1
  15. package/src/components/TaxInformation/index.tsx +58 -26
  16. package/src/components/UpsellingProducts/index.tsx +13 -31
  17. package/src/components/VerifyPhone/styles.tsx +1 -2
  18. package/src/navigators/HomeNavigator.tsx +6 -0
  19. package/src/pages/ProductDetails.tsx +55 -0
  20. package/src/types/index.tsx +2 -0
  21. package/src/types/react-native-color-matrix-image-filters/index.d.ts +1 -0
  22. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  23. package/themes/doordash/src/components/ProductForm/index.tsx +41 -2
  24. package/themes/doordash/src/components/ProductForm/styles.tsx +1 -1
  25. package/themes/instacart/src/components/ProductForm/index.tsx +40 -1
  26. package/themes/instacart/src/components/ProductForm/styles.tsx +1 -1
  27. package/themes/kiosk/src/components/Cart/index.tsx +14 -21
  28. package/themes/kiosk/src/components/CartItem/index.tsx +9 -7
  29. package/themes/kiosk/src/components/CustomerName/index.tsx +2 -1
  30. package/themes/kiosk/src/components/Intro/index.tsx +4 -4
  31. package/themes/kiosk/src/components/OptionCard/index.tsx +11 -6
  32. package/themes/kiosk/src/components/PaymentOptions/index.tsx +46 -44
  33. package/themes/original/index.tsx +4 -0
  34. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
  35. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -2
  36. package/themes/original/src/components/BusinessPreorder/index.tsx +37 -35
  37. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +35 -0
  38. package/themes/original/src/components/BusinessProductsListing/index.tsx +16 -47
  39. package/themes/original/src/components/BusinessesListing/index.tsx +100 -75
  40. package/themes/original/src/components/Cart/index.tsx +10 -31
  41. package/themes/original/src/components/Checkout/index.tsx +2 -0
  42. package/themes/original/src/components/Checkout/styles.tsx +1 -0
  43. package/themes/original/src/components/FacebookLogin/index.tsx +20 -5
  44. package/themes/original/src/components/Help/index.tsx +1 -1
  45. package/themes/original/src/components/Home/index.tsx +5 -3
  46. package/themes/original/src/components/LoginForm/index.tsx +50 -49
  47. package/themes/original/src/components/MessageListing/index.tsx +4 -2
  48. package/themes/original/src/components/OrderDetails/index.tsx +3 -1
  49. package/themes/original/src/components/OrderSummary/index.tsx +11 -30
  50. package/themes/original/src/components/PaymentOptionWallet/index.tsx +10 -6
  51. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -0
  52. package/themes/original/src/components/ProductForm/index.tsx +113 -88
  53. package/themes/original/src/components/ProductForm/styles.tsx +10 -3
  54. package/themes/original/src/components/SingleProductCard/index.tsx +21 -11
  55. package/themes/original/src/components/SingleProductCard/styles.tsx +4 -0
  56. package/themes/original/src/components/UpsellingProducts/index.tsx +85 -83
  57. package/themes/original/src/types/index.tsx +6 -0
  58. package/themes/uber-eats/src/components/ProductForm/index.tsx +43 -2
@@ -5,13 +5,20 @@ export const WrapHeader = styled.View`
5
5
  z-index: 1;
6
6
  `
7
7
 
8
+ export const TopActions = styled.TouchableOpacity`
9
+ height: 44px;
10
+ justify-content: center;
11
+ padding-horizontal: 30px;
12
+ `;
13
+
8
14
  export const TopHeader = styled.View`
9
15
  width: 100%;
10
16
  flex-direction: row;
11
17
  align-items: center;
12
18
  justify-content: space-between;
13
19
  z-index: 1;
14
- padding-horizontal: 40px;
20
+ height: 60px;
21
+ min-height: 60px;
15
22
  `
16
23
 
17
24
  export const ProductHeader = styled.ImageBackground`
@@ -37,7 +44,7 @@ export const ProductTitle = styled.View`
37
44
  `
38
45
 
39
46
  export const ProductDescription = styled.View`
40
- margin-bottom: 30px;
47
+ margin-bottom: 20px;
41
48
  `
42
49
 
43
50
  export const ProductEditions = styled.View`
@@ -89,4 +96,4 @@ export const WeightUnitItem = styled.View`
89
96
  ${({ active }: any) => active && css`
90
97
  background-color: ${(props: any) => props.theme.colors.primary}20;
91
98
  `}
92
- `
99
+ `
@@ -7,7 +7,7 @@ import {
7
7
  } from 'ordering-components/native';
8
8
  import { useTheme } from 'styled-components/native';
9
9
  import { SingleProductCardParams } from '../../types';
10
- import { CardContainer, CardInfo, SoldOut, QuantityContainer } from './styles';
10
+ import { CardContainer, CardInfo, SoldOut, QuantityContainer, PricesContainer } from './styles';
11
11
  import { StyleSheet } from 'react-native';
12
12
  import { OText, OIcon } from '../shared';
13
13
  import FastImage from 'react-native-fast-image'
@@ -51,6 +51,13 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
51
51
  textAlign: 'center',
52
52
  borderRadius: 25,
53
53
  alignItems: 'center'
54
+ },
55
+ regularPriceStyle: {
56
+ fontSize: 12,
57
+ color: '#808080',
58
+ textDecorationLine: 'line-through',
59
+ marginLeft: 7,
60
+ marginRight: 7
54
61
  }
55
62
  });
56
63
 
@@ -97,13 +104,13 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
97
104
  (isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
98
105
  ]}
99
106
  onPress={() => onProductClick?.(product)}>
100
- {productAddedToCartLength > 0 && (
101
- <QuantityContainer style={[styles.quantityContainer, {
102
- transform: [{ translateX: 10 }, { translateY: -10 }],
103
- }]}>
104
- <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
105
- </QuantityContainer>
106
- )}
107
+ {productAddedToCartLength > 0 && (
108
+ <QuantityContainer style={[styles.quantityContainer, {
109
+ transform: [{ translateX: 10 }, { translateY: -10 }],
110
+ }]}>
111
+ <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
112
+ </QuantityContainer>
113
+ )}
107
114
  <CardInfo>
108
115
  <OText
109
116
  size={12}
@@ -113,9 +120,12 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
113
120
  style={styles.line18}>
114
121
  {product?.name}
115
122
  </OText>
116
- <OText size={12} weight={'400'} style={styles.line18} color={theme.colors.textNormal}>
117
- {parsePrice(product?.price)}
118
- </OText>
123
+ <PricesContainer>
124
+ <OText color={theme.colors.primary}>{parsePrice(product?.price)}</OText>
125
+ {product?.offer_price !== null && product?.in_offer && (
126
+ <OText style={styles.regularPriceStyle}>{parsePrice(product?.offer_price)}</OText>
127
+ )}
128
+ </PricesContainer>
119
129
  <OText
120
130
  size={10}
121
131
  numberOfLines={2}
@@ -27,3 +27,7 @@ export const QuantityContainer = styled.View`
27
27
  align-items: center;
28
28
  justify-content: center;
29
29
  `
30
+ export const PricesContainer = styled.View`
31
+ flex-direction: row;
32
+ align-items: center;
33
+ `
@@ -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
+ {productsList.length > 0 &&
163
+ <View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
164
+ <OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
165
+ <UpsellingLayout />
166
+ </View>
167
+ }
168
+ <View style={{ paddingHorizontal: 40 }}>
169
+ <OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
170
+ <OrderSummary
171
+ cart={cart}
172
+ isCartPending={cart?.status === 2}
173
+ onNavigationRedirect={onNavigationRedirect}
174
+ />
175
+ </View>
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
  }
@@ -29,7 +29,7 @@ import {
29
29
  WrapperArrowIcon
30
30
 
31
31
  } from './styles'
32
- import { OButton, OInput, OText } from '../shared'
32
+ import { OButton, OInput, OText, OIcon } from '../shared'
33
33
  import { ProductOptionSubOption } from '../ProductOptionSubOption'
34
34
  import { NotFoundSource } from '../NotFoundSource'
35
35
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder'
@@ -119,10 +119,24 @@ export const ProductOptionsUI = (props: any) => {
119
119
  backgroundColor: theme.colors.lightGray,
120
120
  padding: 2,
121
121
  borderRadius: 20
122
+ },
123
+ productTagWrapper: {
124
+ flexDirection: 'row',
125
+ alignItems: 'center'
126
+ },
127
+ productTagImageStyle: {
128
+ width: 32,
129
+ height: 32,
130
+ borderRadius: 8,
131
+ resizeMode: 'cover'
132
+ },
133
+ productTagNameStyle: {
134
+ paddingHorizontal: 6,
135
+ marginRight: 5
122
136
  }
123
137
  })
124
138
 
125
- const [{ parsePrice }] = useUtils()
139
+ const [{ optimizeImage, parsePrice }] = useUtils()
126
140
  const [, t] = useLanguage()
127
141
  const [orderState] = useOrder()
128
142
  const [{ auth }] = useSession()
@@ -242,6 +256,33 @@ export const ProductOptionsUI = (props: any) => {
242
256
  <OText color={theme.colors.gray} style={{ textAlign: 'left', marginBottom: 10 }}>{product?.description || productCart?.description}</OText>
243
257
  </ProductDescription>
244
258
  )}
259
+ <View style={{ marginHorizontal: 30 }}>
260
+ <ScrollView
261
+ horizontal
262
+ showsHorizontalScrollIndicator={false}
263
+ contentContainerStyle={{ paddingBottom: 20 }}
264
+ >
265
+ {product?.tags?.map((tag: any) => (
266
+ <View
267
+ key={tag.id}
268
+ style={styles.productTagWrapper}
269
+ >
270
+ {tag?.image ? (
271
+ <OIcon
272
+ url={optimizeImage(tag?.image, 'h_40,c_limit')}
273
+ style={styles.productTagImageStyle}
274
+ />
275
+ ) : (
276
+ <OIcon
277
+ src={theme.images?.dummies?.product}
278
+ style={styles.productTagImageStyle}
279
+ />
280
+ )}
281
+ <OText size={14} style={styles.productTagNameStyle}>{tag.name}</OText>
282
+ </View>
283
+ ))}
284
+ </ScrollView>
285
+ </View>
245
286
  {loading && !product ? (
246
287
  <>
247
288
  {[...Array(2)].map((item, i) => (