ordering-ui-react-native 0.12.16 → 0.12.20

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 (27) hide show
  1. package/package.json +1 -1
  2. package/src/config.json +2 -2
  3. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +168 -156
  4. package/themes/business/src/components/NewOrderNotification/index.tsx +14 -1
  5. package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -1
  6. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +1 -1
  7. package/themes/business/src/components/OrdersOption/index.tsx +88 -123
  8. package/themes/business/src/components/PreviousOrders/index.tsx +69 -94
  9. package/themes/business/src/components/PreviousOrders/styles.tsx +0 -7
  10. package/themes/business/src/components/ProductItemAccordion/index.tsx +25 -27
  11. package/themes/business/src/components/shared/OIcon.tsx +0 -2
  12. package/themes/business/src/types/index.tsx +4 -1
  13. package/themes/doordash/src/components/BusinessProductsCategories/index.tsx +60 -5
  14. package/themes/doordash/src/components/BusinessProductsList/index.tsx +144 -79
  15. package/themes/doordash/src/components/BusinessProductsListing/index.tsx +58 -26
  16. package/themes/doordash/src/components/ForgotPasswordForm/index.tsx +37 -35
  17. package/themes/doordash/src/components/ForgotPasswordForm/styles.tsx +7 -0
  18. package/themes/doordash/src/components/Help/index.tsx +1 -1
  19. package/themes/doordash/src/components/LastOrders/index.tsx +9 -3
  20. package/themes/doordash/src/components/LastOrders/styles.tsx +1 -1
  21. package/themes/doordash/src/components/ProductForm/index.tsx +1 -1
  22. package/themes/doordash/src/types/index.tsx +11 -1
  23. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +128 -83
  24. package/themes/kiosk/src/components/DrawerView/index.tsx +57 -0
  25. package/themes/kiosk/src/components/DrawerView/styles.tsx +30 -0
  26. package/themes/kiosk/src/components/ProductForm/index.tsx +22 -20
  27. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
@@ -48,7 +48,7 @@ export const Help = (props: HelpParams) => {
48
48
 
49
49
  <LastOrdersContainer>
50
50
  <OText size={18} weight={600}>{t('LAST_ORDERS', 'Last Orders')}</OText>
51
- <LastOrders />
51
+ <LastOrders navigation={navigation} />
52
52
  </LastOrdersContainer>
53
53
  </>
54
54
  )
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { useCallback } from 'react'
2
2
  import {
3
3
  OrderList as OrderListController,
4
4
  useUtils,
@@ -17,10 +17,12 @@ import {
17
17
  OrderContainer,
18
18
  OrderInfo
19
19
  } from './styles'
20
+ import { StackActions } from '@react-navigation/native'
20
21
 
21
22
  const LastOrdersUI = (props: LastOrdersParams) => {
22
23
  const {
23
- orderList
24
+ orderList,
25
+ navigation
24
26
  } = props
25
27
  const { loading, error, orders } = orderList
26
28
 
@@ -40,6 +42,10 @@ const LastOrdersUI = (props: LastOrdersParams) => {
40
42
  }
41
43
  })
42
44
 
45
+ const goToOrders = useCallback((order) => {
46
+ navigation.navigate('BottomTab', { screen: 'MyOrders' });
47
+ }, [])
48
+
43
49
  return (
44
50
  <>
45
51
  {loading ? (
@@ -53,7 +59,7 @@ const LastOrdersUI = (props: LastOrdersParams) => {
53
59
  ) : (
54
60
  <>
55
61
  {orders.map((order: any) => (
56
- <OrderContainer key={order.id}>
62
+ <OrderContainer key={order.id} onPress={() => goToOrders(order)}>
57
63
  <OIcon
58
64
  url={optimizeImage(order.business?.header, 'h_300,c_limit')}
59
65
  style={styles.headerLogo}
@@ -1,6 +1,6 @@
1
1
  import styled from 'styled-components/native'
2
2
 
3
- export const OrderContainer = styled.View`
3
+ export const OrderContainer = styled.TouchableOpacity`
4
4
  position: relative;
5
5
  margin-vertical: 12px;
6
6
  `
@@ -99,7 +99,7 @@ export const ProductOptionsUI = (props: any) => {
99
99
  minHeight: 200,
100
100
  zIndex: 0
101
101
  },
102
- closeButton: { width: 32, height: 32, borderRadius: 17, backgroundColor: theme.colors.white, alignItems: 'center', justifyContent: 'center' },
102
+ closeButton: { width: 11, height: 32, backgroundColor: theme.colors.white, alignItems: 'center', justifyContent: 'center' },
103
103
  quantityWrap: { width: 40, height: 24, alignItems: 'center', justifyContent: 'center', borderRadius: 7.6, backgroundColor: theme.colors.inputDisabled }
104
104
  })
105
105
  const [{ parsePrice }] = useUtils()
@@ -164,6 +164,7 @@ export interface BusinessProductsListingParams {
164
164
  handleChangeCategory: (value: any) => {};
165
165
  setProductLogin?: () => {};
166
166
  updateProductModal?: (value: any) => {}
167
+ getNextProducts?: () => {};
167
168
  }
168
169
  export interface BusinessBasicInformationParams {
169
170
  businessState?: any;
@@ -175,13 +176,19 @@ export interface BusinessBasicInformationParams {
175
176
  }
176
177
  export interface BusinessProductsCategoriesParams {
177
178
  categories: Array<any>;
178
- // handlerClickCategory: any;
179
179
  onClickCategory: any;
180
180
  openBusinessInformation: any;
181
181
  categorySelected: any;
182
182
  featured: boolean;
183
183
  loading?: any;
184
184
  contentStyle?: ViewStyle;
185
+ scrollViewRef?: any;
186
+ productListLayout?: any;
187
+ categoriesLayout?: any;
188
+ selectedCategoryId?: any;
189
+ lazyLoadProductsRecommended?: any;
190
+ setSelectedCategoryId?: any;
191
+ setCategoryClicked?: any;
185
192
  }
186
193
  export interface BusinessProductsListParams {
187
194
  errors?: any;
@@ -198,6 +205,8 @@ export interface BusinessProductsListParams {
198
205
  errorQuantityProducts?: boolean;
199
206
  handleCancelSearch?: () => void;
200
207
  sortBy?: string;
208
+ categoriesLayout?: any,
209
+ setCategoriesLayout?: any
201
210
  }
202
211
  export interface SingleProductCardParams {
203
212
  businessId: any;
@@ -407,6 +416,7 @@ export interface HelpParams {
407
416
  }
408
417
 
409
418
  export interface LastOrdersParams {
419
+ navigation?: any,
410
420
  orderList?: any,
411
421
  }
412
422
 
@@ -1,5 +1,5 @@
1
- import React, { useState } from 'react';
2
- import { Platform, View } from 'react-native';
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Dimensions, Platform, View } from 'react-native';
3
3
  import { useLanguage, useOrder, useUtils } from 'ordering-components/native';
4
4
  import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons'
5
5
 
@@ -17,13 +17,16 @@ import { CartContent } from '../../components/CartContent';
17
17
  import { TouchableOpacity } from 'react-native-gesture-handler';
18
18
  import { LANDSCAPE, PORTRAIT, useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
19
19
  import { useCartBottomSheet } from '../../providers/CartBottomSheetProvider';
20
- import { useTheme } from 'styled-components/native';
20
+ import styled, { useTheme } from 'styled-components/native';
21
+ import { DrawerView } from '../DrawerView';
22
+ import { ProductForm } from '../ProductForm';
21
23
 
22
24
  const CategoriesMenu = (props: any): React.ReactElement => {
23
25
 
24
26
  const {
25
27
  navigation,
26
28
  route,
29
+ isDrawer
27
30
  } = props;
28
31
 
29
32
  const {
@@ -41,7 +44,16 @@ const CategoriesMenu = (props: any): React.ReactElement => {
41
44
  const [{ parsePrice }] = useUtils();
42
45
  const [orientationState] = useDeviceOrientation();
43
46
  const [bottomSheetVisibility, { showCartBottomSheet, hideCartBottomSheet }] = useCartBottomSheet();
44
-
47
+ const [productSelected, setProductSelected] = useState({})
48
+ const [drawerState, setDrawerState] = useState({ isOpen: false, data: { order: null } });
49
+
50
+ const width_dimension = Dimensions.get('window').width;
51
+ const height_dimension = Dimensions.get('window').height;
52
+
53
+ const KeyboardView = styled.KeyboardAvoidingView`
54
+ flex: 1;
55
+ `;
56
+
45
57
  const onChangeTabs = (idx: number) => {
46
58
  resetInactivityTimeout();
47
59
  setIndexCateg(idx);
@@ -49,6 +61,10 @@ const CategoriesMenu = (props: any): React.ReactElement => {
49
61
 
50
62
  const goToBack = () => navigation.goBack()
51
63
 
64
+ const setDrawerValues = ({ isOpen, data }: any) => {
65
+ setDrawerState({ ...drawerState, isOpen, data });
66
+ }
67
+
52
68
  const [{ carts }] = useOrder();
53
69
  const cartsList = (carts && Object.values(carts).filter((cart: any) => cart.products.length > 0)) || [];
54
70
  const VISIBLE_CART_BOTTOM_SHEET_HEIGHT = orientationState?.dimensions?.height * (orientationState.orientation === PORTRAIT ? 0.5 : 1);
@@ -82,91 +98,120 @@ const CategoriesMenu = (props: any): React.ReactElement => {
82
98
  }
83
99
 
84
100
  return (
85
- <View style={{
86
- flex: 1,
87
- flexDirection: orientationState?.orientation === PORTRAIT ? 'column' : 'row'
88
- }}>
89
- <View
90
- style={{
91
- flex: 1,
92
- paddingBottom: bottomSheetVisibility && !!cart && orientationState?.orientation === PORTRAIT
93
- ? VISIBLE_CART_BOTTOM_SHEET_HEIGHT
94
- : 0,
95
- }}
96
- >
97
- <Container nopadding nestedScrollEnabled>
98
- <View style={{ paddingTop: 20 }}>
99
- <NavBar
100
- title={categories[curIndexCateg].name}
101
- onActionLeft={goToBack}
102
- rightComponent={cart && (
103
- <TouchableOpacity
104
- style={{ paddingHorizontal: 20, flexDirection: 'row', alignItems: 'center' }}
105
- onPress={onToggleCart}
106
- >
107
- <OText
108
- color={theme.colors.mediumGray}
101
+ <>
102
+ <View style={{
103
+ flex: 1,
104
+ flexDirection: orientationState?.orientation === PORTRAIT ? 'column' : 'row'
105
+ }}>
106
+ <View
107
+ style={{
108
+ flex: 1,
109
+ paddingBottom: bottomSheetVisibility && !!cart && orientationState?.orientation === PORTRAIT
110
+ ? VISIBLE_CART_BOTTOM_SHEET_HEIGHT
111
+ : 0,
112
+ }}
113
+ >
114
+ <Container nopadding nestedScrollEnabled>
115
+ <View style={{ paddingTop: 20 }}>
116
+ <NavBar
117
+ title={categories[curIndexCateg].name}
118
+ onActionLeft={goToBack}
119
+ rightComponent={cart && (
120
+ <TouchableOpacity
121
+ style={{ paddingHorizontal: 20, flexDirection: 'row', alignItems: 'center' }}
122
+ onPress={onToggleCart}
109
123
  >
110
- {`${cart?.products?.length || 0} ${t('ITEMS', 'items')}`} {parsePrice(cart?.total || 0)} {' '}
111
- </OText>
112
-
113
- <MaterialIcon
114
- name={bottomSheetVisibility ? "cart-off" : "cart-outline"}
115
- color={theme.colors.primary}
116
- size={30}
117
- />
118
- </TouchableOpacity>
119
- )}
120
- />
121
- <OSegment
122
- items={categories.map((category) => ({
123
- text: category.name
124
- }))}
125
- selectedIdx={curIndexCateg}
126
- onSelectItem={onChangeTabs}
124
+ <OText
125
+ color={theme.colors.mediumGray}
126
+ >
127
+ {`${cart?.products?.length || 0} ${t('ITEMS', 'items')}`} {parsePrice(cart?.total || 0)} {' '}
128
+ </OText>
129
+
130
+ <MaterialIcon
131
+ name={bottomSheetVisibility ? "cart-off" : "cart-outline"}
132
+ color={theme.colors.primary}
133
+ size={30}
134
+ />
135
+ </TouchableOpacity>
136
+ )}
137
+ />
138
+ <OSegment
139
+ items={categories.map((category) => ({
140
+ text: category.name
141
+ }))}
142
+ selectedIdx={curIndexCateg}
143
+ onSelectItem={onChangeTabs}
144
+ />
145
+ </View>
146
+
147
+ <GridContainer style={{ marginTop: 20 }}>
148
+ {categories[curIndexCateg].products.map((product) => (
149
+ <OCard
150
+ key={product.id}
151
+ title={product?.name}
152
+ image={{ uri: product?.images }}
153
+ style={{
154
+ width: orientationState?.orientation === LANDSCAPE
155
+ ? bottomSheetVisibility ? orientationState?.dimensions?.width * 0.145 :orientationState?.dimensions?.width * 0.16
156
+ : orientationState?.dimensions?.width * 0.20
157
+ }}
158
+ titleStyle={{marginTop: Platform.OS === 'ios' ? 10 : 0}}
159
+ onPress={() => {
160
+ resetInactivityTimeout()
161
+ if (isDrawer) {
162
+ setProductSelected(product)
163
+ setDrawerValues({ isOpen: true, data: null })
164
+ } else {
165
+ navigation.navigate('ProductDetails', {
166
+ businessId,
167
+ businessSlug,
168
+ product,
169
+ });
170
+ }
171
+ }}
172
+ {...(!!product?.description && { description: product?.description } )}
173
+ {...(!!product?.price && { price: parsePrice(product?.price) } )}
174
+ {...(product?.in_offer && { prevPrice: `$${product?.offer_price}` } )}
175
+ />
176
+ ))}
177
+ </GridContainer>
178
+ </Container>
179
+ </View>
180
+
181
+ <View
182
+ style={{
183
+ flex: bottomSheetVisibility && orientationState?.orientation === PORTRAIT ? 0 : 0.8,
184
+ display: bottomSheetVisibility ? 'flex' : 'none'
185
+ }}
186
+ >
187
+ <CartContent
188
+ {...cartProps}
127
189
  />
128
190
  </View>
129
-
130
- <GridContainer style={{ marginTop: 20 }}>
131
- {categories[curIndexCateg].products.map((product) => (
132
- <OCard
133
- key={product.id}
134
- title={product?.name}
135
- image={{ uri: product?.images }}
136
- style={{
137
- width: orientationState?.orientation === LANDSCAPE
138
- ? bottomSheetVisibility ? orientationState?.dimensions?.width * 0.145 :orientationState?.dimensions?.width * 0.16
139
- : orientationState?.dimensions?.width * 0.20
140
- }}
141
- titleStyle={{marginTop: Platform.OS === 'ios' ? 10 : 0}}
142
- onPress={() => {
143
- resetInactivityTimeout()
144
- navigation.navigate('ProductDetails', {
145
- businessId,
146
- businessSlug,
147
- product,
148
- });
149
- }}
150
- {...(!!product?.description && { description: product?.description } )}
151
- {...(!!product?.price && { price: parsePrice(product?.price) } )}
152
- {...(product?.in_offer && { prevPrice: `$${product?.offer_price}` } )}
153
- />
154
- ))}
155
- </GridContainer>
156
- </Container>
157
191
  </View>
158
-
159
- <View
160
- style={{
161
- flex: bottomSheetVisibility && orientationState?.orientation === PORTRAIT ? 0 : 0.8,
162
- display: bottomSheetVisibility ? 'flex' : 'none'
163
- }}
192
+ <DrawerView
193
+ isOpen={drawerState.isOpen}
194
+ width={width_dimension - (width_dimension * 0.4)}
195
+ height={height_dimension}
196
+ onClickIcon={() => setDrawerValues({ isOpen: !drawerState.isOpen, data: null })}
197
+ >
198
+ <KeyboardView
199
+ enabled
200
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
164
201
  >
165
- <CartContent
166
- {...cartProps}
202
+ <ProductForm
203
+ isDrawer
204
+ product={productSelected}
205
+ businessId={parseInt(businessId, 10)}
206
+ businessSlug={businessSlug}
207
+ onSave={() => {
208
+ setDrawerValues({ isOpen: !drawerState.isOpen, data: null })
209
+ }}
210
+ navigation={navigation}
167
211
  />
168
- </View>
169
- </View>
212
+ </KeyboardView>
213
+ </DrawerView>
214
+ </>
170
215
  );
171
216
  };
172
217
 
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { StyleSheet } from 'react-native';
3
+ import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons';
4
+
5
+ import {
6
+ Container,
7
+ Wrapper,
8
+ WrapperFloatBtn,
9
+ IconControl
10
+ } from './styles';
11
+
12
+ export const DrawerView = (props: any) => {
13
+ const {
14
+ children,
15
+ isOpen,
16
+ width,
17
+ height,
18
+ onClickIcon,
19
+ iconStyles
20
+ } = props;
21
+
22
+ return (
23
+ isOpen && (
24
+ <>
25
+ <WrapperFloatBtn>
26
+ <IconControl
27
+ activeOpacity={1}
28
+ style={{ ...iconStyles, ...styles.shadow}}
29
+ onPress={() => onClickIcon()}
30
+ >
31
+ <MaterialCommunityIcon
32
+ name='arrow-expand-right'
33
+ size={24}
34
+ />
35
+ </IconControl>
36
+ </WrapperFloatBtn>
37
+ <Container style={styles.shadow}>
38
+ <Wrapper width={width} height={height}>
39
+ {children}
40
+ </Wrapper>
41
+ </Container>
42
+ </>
43
+ )
44
+ )
45
+ }
46
+
47
+ const styles = StyleSheet.create({
48
+ shadow:{
49
+ shadowColor: 'rgba(0.0, 0.0, 0.0, 0.5)',
50
+ shadowOffset: {
51
+ width: 0,
52
+ height: 1.5,
53
+ },
54
+ shadowOpacity: 0.21,
55
+ shadowRadius: 5,
56
+ }
57
+ })
@@ -0,0 +1,30 @@
1
+ import styled, { css } from 'styled-components/native';
2
+
3
+ export const Container = styled.View`
4
+ position: absolute;
5
+ top: 0;
6
+ right: 0;
7
+ z-index: 10001;
8
+ elevation: 5;
9
+ background-color: #FFF;
10
+ `;
11
+
12
+ export const Wrapper = styled.View`
13
+ width: ${(props: any) => props.width}px;
14
+ height: ${(props: any) => props.height}px;
15
+ `;
16
+
17
+ export const WrapperFloatBtn = styled.View`
18
+ position: absolute;
19
+ top: 10%;
20
+ right: ${(props: any) => props.outside ? 11 : 58}%;
21
+ z-index: 20002;
22
+ elevation: 11;
23
+ `;
24
+
25
+ export const IconControl = styled.TouchableOpacity`
26
+ background-color: ${(props: any) => props.theme.colors.white};
27
+ padding: 10px;
28
+ border-radius: 8px;
29
+ elevation: 11;
30
+ `;
@@ -55,7 +55,8 @@ export const ProductOptionsUI = (props: any) => {
55
55
  handleChangeCommentState,
56
56
  productObject,
57
57
  onClose,
58
- isFromCheckout
58
+ isFromCheckout,
59
+ isDrawer
59
60
  } = props;
60
61
 
61
62
  const theme = useTheme();
@@ -240,22 +241,23 @@ export const ProductOptionsUI = (props: any) => {
240
241
  scrollEventThrottle={16}
241
242
  >
242
243
  <Animated.View style={[styles.header, { height: headerHeight }]}>
243
- <Animated.View style={{ opacity: navBar1ContainerOpacity }}>
244
- <NavBar
245
- {...navBarProps}
246
- titleColor={theme.colors.white}
247
- {...((navigation || onClose) && { leftImg: theme.images.general.arrow_left_white })}
248
- btnStyle={{
249
- width: 55,
250
- height: 55,
251
- backgroundColor: 'black',
252
- borderRadius: 100,
253
- opacity: 0.8,
254
- left: 20,
255
- }}
256
- imgLeftStyle={{ width: 27, height: 27 }}
257
- />
258
- </Animated.View>
244
+ {!isDrawer && (<Animated.View style={{ opacity: navBar1ContainerOpacity }}>
245
+ <NavBar
246
+ {...navBarProps}
247
+ titleColor={theme.colors.white}
248
+ {...((navigation || onClose) && { leftImg: theme.images.general.arrow_left_white })}
249
+ btnStyle={{
250
+ width: 55,
251
+ height: 55,
252
+ backgroundColor: 'black',
253
+ borderRadius: 100,
254
+ opacity: 0.8,
255
+ left: 20,
256
+ }}
257
+ imgLeftStyle={{ width: 27, height: 27 }}
258
+ />
259
+ </Animated.View>
260
+ )}
259
261
  <Animated.View style={{ opacity: navBar2ContainerOpacity, position: 'absolute' }}>
260
262
  <NavBar
261
263
  {...navBarProps}
@@ -367,8 +369,8 @@ export const ProductOptionsUI = (props: any) => {
367
369
  <Spinner visible={loading} />
368
370
  )}
369
371
  {!loading && !error && product && (
370
- <View style={{ paddingTop: 20, paddingBottom: 80 }}>
371
- <WrapContent>
372
+ <View style={{ paddingTop: isDrawer ? 10 : 20, paddingBottom: 80 }}>
373
+ <WrapContent isDrawer={isDrawer}>
372
374
  <ProductDescription>
373
375
  {(
374
376
  (product?.sku && product?.sku !== '-1' && product?.sku !== '1') ||
@@ -500,7 +502,7 @@ export const ProductOptionsUI = (props: any) => {
500
502
  </TouchableOpacity>
501
503
  </View>
502
504
  )}
503
- <View style={{ width: isSoldOut || maxProductQuantity <= 0 ? '100%' : '80%' }}>
505
+ <View style={{ width: isSoldOut || maxProductQuantity <= 0 ? '100%' : isDrawer ? '70%':'80%' }}>
504
506
  {productCart && !isSoldOut && maxProductQuantity > 0 && auth && orderState.options?.address_id && (
505
507
  <OButton
506
508
  onClick={() => handleSaveProduct()}
@@ -27,7 +27,7 @@ export const ProductHeader = styled.ImageBackground`
27
27
  `
28
28
 
29
29
  export const WrapContent = styled.View`
30
- padding: 0 20px;
30
+ padding: ${(props: any) => props.isDrawer ? '0 5px' : '0 20px'};
31
31
  position: relative;
32
32
  bottom: 20px;
33
33
  background-color: white;