ordering-ui-react-native 0.12.8 → 0.12.12

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 (30) hide show
  1. package/package.json +2 -1
  2. package/src/assets/images/business_list_banner.jpg +0 -0
  3. package/src/components/Account/index.tsx +2 -2
  4. package/src/config.json +2 -2
  5. package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -3
  6. package/themes/business/src/components/OrdersOption/index.tsx +30 -23
  7. package/themes/original/index.tsx +2 -0
  8. package/themes/original/src/components/BusinessesListing/index.tsx +7 -0
  9. package/themes/original/src/components/BusinessesListing/styles.tsx +6 -1
  10. package/themes/original/src/components/OrderProgress/index.tsx +208 -0
  11. package/themes/original/src/components/OrderProgress/styles.tsx +30 -0
  12. package/themes/original/src/components/ProductForm/index.tsx +159 -56
  13. package/themes/original/src/components/ProductForm/styles.tsx +1 -1
  14. package/themes/single-business/src/components/ActiveOrders/index.tsx +20 -19
  15. package/themes/single-business/src/components/BusinessProductsListing/index.tsx +4 -4
  16. package/themes/single-business/src/components/Cart/index.tsx +39 -47
  17. package/themes/single-business/src/components/Cart/styles.tsx +1 -0
  18. package/themes/single-business/src/components/LoginForm/index.tsx +147 -89
  19. package/themes/single-business/src/components/LoginForm/styles.tsx +33 -28
  20. package/themes/single-business/src/components/OrderDetails/index.tsx +32 -12
  21. package/themes/single-business/src/components/OrdersOption/index.tsx +50 -50
  22. package/themes/single-business/src/components/OrdersOption/styles.tsx +1 -1
  23. package/themes/single-business/src/components/PreviousOrders/index.tsx +97 -83
  24. package/themes/single-business/src/components/PromotionCard/index.tsx +10 -2
  25. package/themes/single-business/src/components/Promotions/index.tsx +1 -1
  26. package/themes/single-business/src/components/ReviewOrder/index.tsx +299 -274
  27. package/themes/single-business/src/components/ReviewOrder/styles.tsx +23 -26
  28. package/themes/single-business/src/components/UpsellingProducts/index.tsx +230 -189
  29. package/themes/single-business/src/components/UpsellingProducts/styles.tsx +24 -18
  30. package/themes/single-business/src/types/index.tsx +10 -2
@@ -1,16 +1,19 @@
1
- import React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import {
3
3
  ProductForm as ProductOptions,
4
4
  useSession,
5
5
  useLanguage,
6
6
  useOrder,
7
- useUtils,
7
+ useUtils
8
8
  } from 'ordering-components/native';
9
9
  import { useTheme } from 'styled-components/native';
10
10
  import { ProductIngredient } from '../ProductIngredient';
11
11
  import { ProductOption } from '../ProductOption';
12
+ import Swiper from 'react-native-swiper'
13
+ import FastImage from 'react-native-fast-image';
14
+ import IconAntDesign from 'react-native-vector-icons/AntDesign';
12
15
 
13
- import { View, TouchableOpacity, StyleSheet, Dimensions, Platform } from 'react-native';
16
+ import { View, TouchableOpacity, StyleSheet, Dimensions, Platform, AppRegistry } from 'react-native';
14
17
 
15
18
  import {
16
19
  ProductHeader,
@@ -25,7 +28,7 @@ import {
25
28
  WrapperSubOption,
26
29
  ProductComment,
27
30
  ProductActions,
28
- ExtraOptionWrap,
31
+ ExtraOptionWrap
29
32
  } from './styles';
30
33
  import { OButton, OIcon, OInput, OText } from '../shared';
31
34
  import { ScrollView } from 'react-native-gesture-handler';
@@ -110,13 +113,30 @@ export const ProductOptionsUI = (props: any) => {
110
113
  borderBottomColor: theme.colors.border,
111
114
  justifyContent: 'center',
112
115
  },
116
+ slide1: {
117
+ flex: 1,
118
+ },
119
+ mainSwiper : {
120
+ height: 258,
121
+ },
122
+ swiperButton: {
123
+ marginHorizontal: 30,
124
+ alignItems: 'center',
125
+ justifyContent: 'center',
126
+ width: 32,
127
+ height: 32,
128
+ borderRadius: 16,
129
+ backgroundColor: 'rgba(255,255,255,0.3)'
130
+ }
113
131
  });
114
132
 
115
- const [{ parsePrice }] = useUtils();
133
+ const [{ parsePrice, optimizeImage }] = useUtils();
116
134
  const [, t] = useLanguage();
117
135
  const [orderState] = useOrder();
118
136
  const [{ auth }] = useSession();
119
137
  const { product, loading, error } = productObject;
138
+ const [gallery, setGallery] = useState([])
139
+ const [thumbsSwiper, setThumbsSwiper] = useState(0)
120
140
 
121
141
  const { top, bottom } = useSafeAreaInsets();
122
142
  const { height } = useWindowDimensions();
@@ -154,63 +174,76 @@ export const ProductOptionsUI = (props: any) => {
154
174
  return sel[0]?.id !== undefined;
155
175
  };
156
176
 
177
+ const handleChangeMainIndex = (index: number) => {
178
+ setThumbsSwiper(index)
179
+ }
180
+
157
181
  const handleRedirectLogin = () => {
158
182
  onClose();
159
183
  navigation.navigate('Login');
160
184
  };
161
185
 
186
+ useEffect(() => {
187
+ const productImgList: any = []
188
+ product?.images && productImgList.push(product.images)
189
+ for (const img of product?.gallery) {
190
+ productImgList.push(img.file)
191
+ }
192
+ setGallery(productImgList)
193
+ }, [product])
194
+
162
195
  const saveErrors =
163
196
  orderState.loading ||
164
197
  maxProductQuantity === 0 ||
165
198
  Object.keys(errors).length > 0;
166
199
 
167
200
  const ExtraOptions = ({ eID, options }: any) => (
168
- <>
169
- {product?.ingredients.length > 0 && (
170
- <TouchableOpacity
171
- key={`eopt_all_00`}
172
- onPress={() => setSelectedOpt(-1)}
173
- style={[
174
- styles.extraItem,
175
- {
176
- borderBottomColor:
177
- selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
178
- },
179
- ]}>
180
- <OText
181
- color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
182
- size={selOpt == -1 ? 14 : 12}
183
- weight={selOpt == -1 ? '600' : 'normal'}>
184
- {t('INGREDIENTS', 'Ingredients')}
185
- </OText>
186
- </TouchableOpacity>
187
- )}
188
- {options.map(({ id, name, respect_to }: any) => (
189
- <React.Fragment key={`cont_key_${id}`}>
190
- {respect_to == null && (
191
- <TouchableOpacity
192
- key={`eopt_key_${id}`}
193
- onPress={() => setSelectedOpt(id)}
194
- style={[
195
- styles.extraItem,
196
- {
197
- borderBottomColor:
198
- selOpt == id ? theme.colors.textNormal : theme.colors.border,
199
- },
200
- ]}>
201
- <OText
202
- color={
203
- selOpt == id ? theme.colors.textNormal : theme.colors.textSecondary
204
- }
205
- size={selOpt == id ? 14 : 12}
206
- weight={selOpt == id ? '600' : 'normal'}>
207
- {name}
208
- </OText>
209
- </TouchableOpacity>
210
- )}
211
- </React.Fragment>
212
- ))}
213
- </>
201
+ <>
202
+ {product?.ingredients.length > 0 && (
203
+ <TouchableOpacity
204
+ key={`eopt_all_00`}
205
+ onPress={() => setSelectedOpt(-1)}
206
+ style={[
207
+ styles.extraItem,
208
+ {
209
+ borderBottomColor:
210
+ selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
211
+ },
212
+ ]}>
213
+ <OText
214
+ color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
215
+ size={selOpt == -1 ? 14 : 12}
216
+ weight={selOpt == -1 ? '600' : 'normal'}>
217
+ {t('INGREDIENTS', 'Ingredients')}
218
+ </OText>
219
+ </TouchableOpacity>
220
+ )}
221
+ {options.map(({ id, name, respect_to }: any) => (
222
+ <React.Fragment key={`cont_key_${id}`}>
223
+ {respect_to == null && (
224
+ <TouchableOpacity
225
+ key={`eopt_key_${id}`}
226
+ onPress={() => setSelectedOpt(id)}
227
+ style={[
228
+ styles.extraItem,
229
+ {
230
+ borderBottomColor:
231
+ selOpt == id ? theme.colors.textNormal : theme.colors.border,
232
+ },
233
+ ]}>
234
+ <OText
235
+ color={
236
+ selOpt == id ? theme.colors.textNormal : theme.colors.textSecondary
237
+ }
238
+ size={selOpt == id ? 14 : 12}
239
+ weight={selOpt == id ? '600' : 'normal'}>
240
+ {name}
241
+ </OText>
242
+ </TouchableOpacity>
243
+ )}
244
+ </React.Fragment>
245
+ ))}
246
+ </>
214
247
  );
215
248
 
216
249
  return (
@@ -238,11 +271,81 @@ export const ProductOptionsUI = (props: any) => {
238
271
  </View>
239
272
  ) : (
240
273
  <>
241
- <ProductHeader
242
- source={{ uri: product?.images || productCart?.images }}
243
- style={{height: windowWidth}}
244
- resizeMode={'contain'}
245
- />
274
+ <Swiper
275
+ loop={false}
276
+ showsButtons={true}
277
+ style={styles.mainSwiper}
278
+ // index={thumbsSwiper}
279
+ onIndexChanged={(index) => handleChangeMainIndex(index)}
280
+ prevButton={
281
+ <View style={styles.swiperButton}>
282
+ <IconAntDesign
283
+ name="caretleft"
284
+ color={theme.colors.white}
285
+ size={13}
286
+ // style={styles.starIcon}
287
+ />
288
+ </View>
289
+ }
290
+ nextButton={
291
+ <View style={styles.swiperButton}>
292
+ <IconAntDesign
293
+ name="caretright"
294
+ color={theme.colors.white}
295
+ size={13}
296
+ // style={styles.starIcon}
297
+ />
298
+ </View>
299
+ }
300
+ >
301
+ {gallery.length > 0 && gallery.map((img, i) => (
302
+ <View
303
+ style={styles.slide1}
304
+ key={i}
305
+ >
306
+ <FastImage
307
+ style={{ height: '100%' }}
308
+ source={{
309
+ uri: optimizeImage(img, 'h_258,c_limit'),
310
+ priority: FastImage.priority.normal,
311
+ }}
312
+ />
313
+ </View>
314
+ ))}
315
+ </Swiper>
316
+ <ScrollView
317
+ horizontal
318
+ contentContainerStyle={{
319
+ paddingHorizontal: 30,
320
+ paddingVertical: 15
321
+ }}
322
+ >
323
+ {gallery.length > 0 && gallery.map((img, index) => (
324
+ <View
325
+ key={index}
326
+ style={{
327
+ height: 56,
328
+ borderRadius: 8,
329
+ margin: 8,
330
+ opacity: index === thumbsSwiper ? 1 : 0.8
331
+ }}
332
+ >
333
+ <OIcon
334
+ url={img}
335
+ style={{
336
+ borderColor: theme.colors.lightGray,
337
+ borderRadius: 8,
338
+ minHeight: '100%'
339
+ }}
340
+ width={56}
341
+ height={56}
342
+ cover
343
+ />
344
+ {/* {thumbsSwiper === 2 && <OText color='red'>{index.toString()}</OText>}
345
+ {thumbsSwiper === 3 && <OText color='red'>{index.toString()}</OText>} */}
346
+ </View>
347
+ ))}
348
+ </ScrollView>
246
349
  </>
247
350
  )}
248
351
  </WrapHeader>
@@ -77,4 +77,4 @@ export const ProductActions = styled.View`
77
77
  `
78
78
  export const ExtraOptionWrap = styled.ScrollView`
79
79
  margin-horizontal: -40px;
80
- `;
80
+ `;
@@ -10,12 +10,11 @@ import {
10
10
  BusinessInformation,
11
11
  Price,
12
12
  } from './styles';
13
- import { View, StyleSheet } from 'react-native';
13
+ import { View, StyleSheet, TouchableOpacity } from 'react-native';
14
14
 
15
15
  import { ActiveOrdersParams } from '../../types';
16
16
  import moment from 'moment';
17
17
  import { useTheme } from 'styled-components/native';
18
- import { TouchableOpacity } from 'react-native-gesture-handler';
19
18
 
20
19
  export const ActiveOrders = (props: ActiveOrdersParams) => {
21
20
  const {
@@ -85,11 +84,11 @@ export const ActiveOrders = (props: ActiveOrdersParams) => {
85
84
  <OText size={12} lineHeight={18}>
86
85
  {parsePrice(order?.summary?.total || order?.total)}
87
86
  </OText>
88
- {!isPreorders &&
87
+ {/* {!isPreorders &&
89
88
  <TouchableOpacity onPress={handleLike}>
90
89
  <OIcon src={theme.images.general.heart} color={theme.colors.red} width={16} />
91
90
  </TouchableOpacity>
92
- }
91
+ } */}
93
92
  </Price>
94
93
  </OrderInformation>
95
94
  </Information>
@@ -98,21 +97,23 @@ export const ActiveOrders = (props: ActiveOrdersParams) => {
98
97
  );
99
98
 
100
99
  return (
101
- <>
102
- <ActiveOrdersContainer isMiniCards={configs?.google_maps_api_key?.value}>
103
- {orders.length > 0 &&
104
- orders.map((order: any, index: any) => (
105
- <Order key={order?.id || order?.uuid} order={order} index={index} />
106
- ))}
107
- </ActiveOrdersContainer>
108
- <View
109
- style={{
110
- height: 8,
111
- backgroundColor: theme.colors.backgroundGray100,
112
- marginHorizontal: -40,
113
- }}
114
- />
115
- </>
100
+ orders.length === 0 ? null : (
101
+ <>
102
+ <ActiveOrdersContainer isMiniCards={configs?.google_maps_api_key?.value}>
103
+ {orders.length > 0 &&
104
+ orders.map((order: any, index: any) => (
105
+ <Order key={order?.id || order?.uuid} order={order} index={index} />
106
+ ))}
107
+ </ActiveOrdersContainer>
108
+ <View
109
+ style={{
110
+ height: 8,
111
+ backgroundColor: theme.colors.backgroundGray100,
112
+ marginHorizontal: -40,
113
+ }}
114
+ />
115
+ </>
116
+ )
116
117
  );
117
118
  };
118
119
 
@@ -23,7 +23,7 @@ import {
23
23
  } from './styles'
24
24
  import { FloatingButton } from '../FloatingButton'
25
25
  import { ProductForm } from '../ProductForm'
26
- import { UpsellingProducts } from '../UpsellingProducts'
26
+ // import { UpsellingProducts } from '../UpsellingProducts'
27
27
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
28
28
  import { _setStoreData } from '../../providers/StoreUtil';
29
29
 
@@ -237,7 +237,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
237
237
  btnLeftValue={currentCart?.products?.length}
238
238
  btnRightValue={parsePrice(currentCart?.total)}
239
239
  disabled={openUpselling || currentCart?.subtotal < currentCart?.minimum}
240
- handleClick={() => setOpenUpselling(true)}
240
+ handleClick={() => onRedirect('Cart')}
241
241
  hasBottom
242
242
  />
243
243
  )}
@@ -256,7 +256,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
256
256
  onSave={handlerProductAction}
257
257
  />
258
258
  </OModal>
259
- {openUpselling && (
259
+ {/* {openUpselling && (
260
260
  <UpsellingProducts
261
261
  businessId={currentCart?.business_id}
262
262
  business={currentCart?.business}
@@ -268,7 +268,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
268
268
  canOpenUpselling={canOpenUpselling}
269
269
  setCanOpenUpselling={setCanOpenUpselling}
270
270
  />
271
- )}
271
+ )} */}
272
272
  </>
273
273
  )
274
274
  }
@@ -54,6 +54,7 @@ const CartUI = (props: any) => {
54
54
  const [curProduct, setCurProduct] = useState<any>(null)
55
55
  const [openUpselling, setOpenUpselling] = useState(false)
56
56
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
57
+ const [isUpsellingProducts, setIsUpsellingProducts] = useState(false)
57
58
 
58
59
  const isCartPending = cart?.status === 2
59
60
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
@@ -100,6 +101,7 @@ const CartUI = (props: any) => {
100
101
  <ScrollView
101
102
  showsVerticalScrollIndicator={false}
102
103
  showsHorizontalScrollIndicator={false}
104
+ style={{ height, backgroundColor: theme.colors.backgroundPage }}
103
105
  >
104
106
  <Container>
105
107
  <Title>
@@ -126,7 +128,7 @@ const CartUI = (props: any) => {
126
128
  onEditProduct={handleEditProduct}
127
129
  />
128
130
  ))}
129
-
131
+
130
132
  {cart?.valid_products && (
131
133
  <OSBill>
132
134
  <OSTable>
@@ -218,27 +220,16 @@ const CartUI = (props: any) => {
218
220
  {cart?.products?.length > 0 && (
219
221
  <>
220
222
  <LineDivider />
221
-
223
+
222
224
  <Container>
223
- <ScrollView
224
- showsVerticalScrollIndicator={false}
225
- showsHorizontalScrollIndicator={false}
226
- >
227
- <View
228
- style={{
229
- paddingTop: 20,
230
- overflow: 'visible'
231
- }}
225
+ <View style={{ padding: 0, }}>
226
+ <ScrollView
227
+ showsVerticalScrollIndicator={false}
228
+ showsHorizontalScrollIndicator={false}
232
229
  >
233
- <OText
234
- size={16}
235
- lineHeight={24}
236
- weight={'500'}
237
- >
238
- {t('WANT_SOMETHING_ELSE', 'Do you want something else?')}
239
- </OText>
240
230
  <UpsellingProducts
241
231
  isCustomMode
232
+ isShowTitle
242
233
  openUpselling={openUpselling}
243
234
  businessId={cart?.business_id}
244
235
  business={cart?.business}
@@ -247,36 +238,37 @@ const CartUI = (props: any) => {
247
238
  setCanOpenUpselling={setCanOpenUpselling}
248
239
  handleUpsellingPage={handleUpsellingPage}
249
240
  handleCloseUpsellingPage={() => { }}
241
+ handleUpsellingProducts={setIsUpsellingProducts}
250
242
  />
251
- </View>
252
- </ScrollView>
253
-
254
- {cart?.valid_products && (
255
- <CheckoutAction>
256
- <OButton
257
- text={(cart?.subtotal >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
258
- !openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
259
- ) : !cart?.valid_address ? (
260
- `${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
261
- ) : (
262
- `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
263
- )}
264
- bgColor={(cart?.subtotal < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
265
- isDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
266
- borderColor={theme.colors.primary}
267
- imgRightSrc={null}
268
- textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
269
- onClick={() => props.onNavigationRedirect('CheckoutNavigator', {
270
- screen: 'CheckoutPage',
271
- cartUuid: cart?.uuid,
272
- businessLogo: cart?.business?.logo,
273
- businessName: cart?.business?.name,
274
- cartTotal: cart?.total
275
- })}
276
- style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
277
- />
278
- </CheckoutAction>
279
- )}
243
+ </ScrollView>
244
+
245
+ {cart?.valid_products && (
246
+ <CheckoutAction>
247
+ <OButton
248
+ text={(cart?.subtotal >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
249
+ !openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
250
+ ) : !cart?.valid_address ? (
251
+ `${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
252
+ ) : (
253
+ `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
254
+ )}
255
+ bgColor={(cart?.subtotal < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
256
+ isDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
257
+ borderColor={theme.colors.primary}
258
+ imgRightSrc={null}
259
+ textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
260
+ onClick={() => props.onNavigationRedirect('CheckoutNavigator', {
261
+ screen: 'CheckoutPage',
262
+ cartUuid: cart?.uuid,
263
+ businessLogo: cart?.business?.logo,
264
+ businessName: cart?.business?.name,
265
+ cartTotal: cart?.total
266
+ })}
267
+ style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
268
+ />
269
+ </CheckoutAction>
270
+ )}
271
+ </View>
280
272
  </Container>
281
273
  </>
282
274
  )}
@@ -11,6 +11,7 @@ export const Title = styled.View`
11
11
  export const LineDivider = styled.View`
12
12
  height: 8px;
13
13
  background-color: ${(props: any) => props.theme.colors.backgroundGray100};
14
+ margin-bottom: 20px;
14
15
  `
15
16
 
16
17
  export const OrderBill = styled.View`