ordering-ui-react-native 0.11.22 → 0.11.26

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 (25) hide show
  1. package/package.json +1 -1
  2. package/src/components/BusinessTypeFilter/index.tsx +155 -105
  3. package/themes/business/src/components/OrdersOption/index.tsx +2 -0
  4. package/themes/business/src/components/PreviousOrders/index.tsx +13 -4
  5. package/themes/business/src/components/PreviousOrders/styles.tsx +6 -0
  6. package/themes/business/src/types/index.tsx +1 -0
  7. package/themes/doordash/src/components/BusinessTypeFilter/index.tsx +152 -84
  8. package/themes/doordash/src/components/BusinessTypeFilter/styles.tsx +1 -2
  9. package/themes/kiosk/src/components/BusinessMenu/index.tsx +1 -1
  10. package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +6 -14
  11. package/themes/kiosk/src/components/Cart/index.tsx +75 -60
  12. package/themes/kiosk/src/components/Cart/styles.tsx +19 -1
  13. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +6 -15
  14. package/themes/kiosk/src/components/LoginForm/index.tsx +1 -8
  15. package/themes/kiosk/src/components/PaymentOptions/index.tsx +2 -1
  16. package/themes/kiosk/src/components/shared/OCard.tsx +1 -1
  17. package/themes/kiosk/src/components/shared/OInput.tsx +4 -0
  18. package/themes/original/src/components/BusinessTypeFilter/index.tsx +118 -44
  19. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +4 -4
  20. package/themes/original/src/components/BusinessesListing/index.tsx +3 -0
  21. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +122 -0
  22. package/themes/original/src/components/HighestRatedBusinesses/styles.tsx +7 -0
  23. package/themes/original/src/types/index.tsx +4 -0
  24. package/themes/uber-eats/src/components/BusinessTypeFilter/index.tsx +151 -76
  25. package/themes/uber-eats/src/components/BusinessTypeFilter/styles.tsx +0 -9
@@ -0,0 +1,122 @@
1
+ import React from 'react';
2
+ import {
3
+ BusinessList as BusinessesListingController,
4
+ useLanguage,
5
+ useOrder
6
+ } from 'ordering-components/native';
7
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
8
+ import { View, ScrollView, Platform, Dimensions } from 'react-native';
9
+ import { OText } from '../shared';
10
+ import { HighestRatedBusinessesParams } from '../../types';
11
+ import { BusinessController } from '../BusinessController'
12
+ import {
13
+ ListWrapper
14
+ } from './styles'
15
+
16
+ const HighestRatedBusinessesUI = (props: HighestRatedBusinessesParams) => {
17
+ const {
18
+ businessesList,
19
+ onBusinessClick
20
+ } = props;
21
+
22
+ const [, t] = useLanguage()
23
+ const [orderState] = useOrder();
24
+
25
+ const windowWidth = Dimensions.get('window').width;
26
+
27
+ return (
28
+ <>
29
+ <ListWrapper>
30
+ <OText size={16} mBottom={5} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('HIGHEST_RATED', 'Highest rated')}</OText>
31
+ <OText size={12}>{t('TOP_RATINGS_AND_GREAT_SERVICE', 'Top ratings and great service')}</OText>
32
+ <ScrollView
33
+ showsHorizontalScrollIndicator={false}
34
+ nestedScrollEnabled
35
+ horizontal
36
+ style={{ height: 300 }}
37
+ >
38
+ {businessesList.businesses?.map(
39
+ (business: any) => (
40
+ <View
41
+ key={business.id}
42
+ style={{
43
+ width: windowWidth - 100,
44
+ paddingHorizontal: 5,
45
+ height: '100%'
46
+ }}
47
+ >
48
+ <BusinessController
49
+ business={business}
50
+ handleCustomClick={onBusinessClick}
51
+ orderType={orderState?.options?.type}
52
+ />
53
+ </View>
54
+ )
55
+ )}
56
+ {businessesList.loading && (
57
+ <>
58
+ {[
59
+ ...Array(10).keys()
60
+ ].map((item, i) => (
61
+ <Placeholder
62
+ Animation={Fade}
63
+ key={i}
64
+ style={{
65
+ marginBottom: 20,
66
+ width: windowWidth - 100,
67
+ paddingHorizontal: 5,
68
+ height: '100%'
69
+ }}>
70
+ <View style={{ width: '100%' }}>
71
+ <PlaceholderLine
72
+ height={150}
73
+ style={{ marginBottom: 20, borderRadius: 8 }}
74
+ />
75
+ <View style={{ paddingHorizontal: 10 }}>
76
+ <View
77
+ style={{
78
+ flexDirection: 'row',
79
+ justifyContent: 'space-between',
80
+ }}>
81
+ <PlaceholderLine
82
+ height={15}
83
+ width={40}
84
+ style={{ marginBottom: 15 }}
85
+ />
86
+ <PlaceholderLine
87
+ height={15}
88
+ width={20}
89
+ style={{ marginBottom: 15 }}
90
+ />
91
+ </View>
92
+ <PlaceholderLine
93
+ height={15}
94
+ width={30}
95
+ style={{ marginBottom: 10 }}
96
+ />
97
+ <PlaceholderLine
98
+ height={15}
99
+ width={80}
100
+ style={{ marginBottom: 10 }}
101
+ />
102
+ </View>
103
+ </View>
104
+ </Placeholder>
105
+ ))}
106
+ </>
107
+ )}
108
+ </ScrollView>
109
+ </ListWrapper>
110
+ </>
111
+ )
112
+ }
113
+
114
+ export const HighestRatedBusinesses = (props: any) => {
115
+ const highestRatedBusinessesProps = {
116
+ ...props,
117
+ UIComponent: HighestRatedBusinessesUI,
118
+ initialOrderByValue: 'rating'
119
+ };
120
+
121
+ return <BusinessesListingController {...highestRatedBusinessesProps} />;
122
+ };
@@ -0,0 +1,7 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const ListWrapper = styled.View`
4
+ background-color: ${(props: any) => props.theme.colors.backgroundLight};
5
+ padding-horizontal: 40px;
6
+ padding-top: 30px;
7
+ `;
@@ -129,6 +129,10 @@ export interface BusinessesListingParams {
129
129
  businessTypes?: any;
130
130
  defaultBusinessType?: any;
131
131
  }
132
+ export interface HighestRatedBusinessesParams {
133
+ businessesList: { businesses: Array<any>, loading: boolean, error: null | string };
134
+ onBusinessClick?: void;
135
+ }
132
136
  export interface BusinessTypeFilterParams {
133
137
  businessTypes?: Array<any>;
134
138
  handleChangeBusinessType: any;
@@ -1,13 +1,15 @@
1
- import React from 'react'
2
- import { StyleSheet, FlatList, View, ScrollView, TouchableOpacity } from 'react-native'
1
+ import React, { useState } from 'react'
2
+ import { StyleSheet, View, ScrollView, TouchableOpacity, Dimensions } from 'react-native'
3
3
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
4
4
  import { BusinessTypeFilter as BusinessTypeFilterController, useLanguage } from 'ordering-components/native'
5
+ import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';
5
6
 
6
- import { BusinessCategories, Category, BCContainer } from './styles'
7
- import { OIcon, OText } from '../shared'
7
+ import { BusinessCategories, BCContainer } from './styles'
8
+ import { OIcon, OText, OModal } from '../shared'
8
9
  import { BusinessTypeFilterParams } from '../../types'
9
10
  import { useTheme } from 'styled-components/native'
10
11
 
12
+ const windowWidth = Dimensions.get('window').width;
11
13
 
12
14
  export const BusinessTypeFilterUI = (props: BusinessTypeFilterParams) => {
13
15
  const {
@@ -18,92 +20,165 @@ export const BusinessTypeFilterUI = (props: BusinessTypeFilterParams) => {
18
20
 
19
21
  const theme = useTheme()
20
22
  const [, t] = useLanguage();
23
+ const [isOpenAllCategories, setIsOpenAllCategories] = useState(false)
21
24
 
22
- const renderTypes = ({ item }: any) => {
25
+
26
+ const styles = StyleSheet.create({
27
+ icons: {
28
+ padding: 10
29
+ },
30
+ logo: {
31
+ width: isOpenAllCategories ? windowWidth / 3 - 27 : windowWidth / 4 - 20,
32
+ height: isOpenAllCategories ? windowWidth / 3 - 27 : windowWidth / 4 - 20,
33
+ marginBottom: 15,
34
+ borderRadius: 8,
35
+ justifyContent: 'center',
36
+ alignItems: 'center',
37
+ },
38
+ categoryStyle: {
39
+ width: isOpenAllCategories ? windowWidth / 3 - 27 : windowWidth / 4 - 20,
40
+ height: 150,
41
+ flexDirection: 'column',
42
+ justifyContent: 'center',
43
+ alignItems: 'center',
44
+ marginHorizontal: isOpenAllCategories ? 10 : 0,
45
+ marginBottom: isOpenAllCategories ? 40 : 0
46
+ },
47
+ allCategoriesContainer : {
48
+ paddingHorizontal: 10,
49
+ paddingVertical: 30
50
+ },
51
+ allCategoriesWrapper: {
52
+ flexDirection: 'row',
53
+ flexWrap: 'wrap',
54
+ }
55
+ })
56
+
57
+ const RenderTypes = ({ item }: any ) => {
23
58
  return (
24
59
  <TouchableOpacity
25
- key={item.id}
26
- onPress={() => handleChangeBusinessType(item.id)}
60
+ style={styles.categoryStyle}
61
+ onPress={() => {
62
+ handleChangeBusinessType(item.id)
63
+ isOpenAllCategories && setIsOpenAllCategories(false)
64
+ }}
27
65
  >
28
- <Category>
29
- {item.image ? (
30
- <OIcon
31
- url={item.image}
32
- style={styles.logo}
33
- />
34
- ) : (
35
- <OIcon
36
- src={theme.images.categories.all}
37
- style={styles.logo}
38
- />
39
- )}
40
- <OText
41
- style={{ textAlign: 'center' }}
42
- size={14}
43
- color={currentTypeSelected === item.id ? theme.colors.primary : theme.colors.textSecondary}
44
- >
45
- {t(`BUSINESS_TYPE_${item.name.replace(/\s/g, '_').toUpperCase()}`, item.name)}
46
- </OText>
47
- </Category>
66
+ {item.image ? (
67
+ <OIcon
68
+ url={item.image}
69
+ style={styles.logo}
70
+ />
71
+ ) : (
72
+ <OIcon
73
+ src={theme.images.categories.all}
74
+ style={styles.logo}
75
+ />
76
+ )}
77
+ <OText
78
+ style={{ textAlign: 'center' }}
79
+ size={14}
80
+ color={currentTypeSelected === item.id ? theme.colors.primary : theme.colors.textSecondary}
81
+ numberOfLines={1}
82
+ ellipsizeMode='tail'
83
+ >
84
+ {t(`BUSINESS_TYPE_${item.name.replace(/\s/g, '_').toUpperCase()}`, item.name)}
85
+ </OText>
48
86
  </TouchableOpacity>
49
87
  )
50
88
  }
51
89
 
52
90
  return (
53
- <BCContainer>
54
- {typesState?.loading && (
55
- <View>
56
- <Placeholder
57
- style={{ marginVertical: 10 }}
58
- Animation={Fade}
59
- >
60
- <ScrollView
61
- horizontal
62
- showsVerticalScrollIndicator={false}
63
- showsHorizontalScrollIndicator={false}
91
+ <>
92
+ <BCContainer>
93
+ {typesState?.loading && (
94
+ <View>
95
+ <Placeholder
96
+ style={{ marginVertical: 10 }}
97
+ Animation={Fade}
64
98
  >
65
- {[...Array(4)].map((_, i) => (
66
- <View key={i} style={{ width: 80, borderRadius: 10, marginRight: 15 }}>
67
- <PlaceholderLine
68
- height={80}
69
- noMargin
70
- />
71
- </View>
99
+ <ScrollView
100
+ horizontal
101
+ showsVerticalScrollIndicator={false}
102
+ showsHorizontalScrollIndicator={false}
103
+ >
104
+ {[...Array(4)].map((_, i) => (
105
+ <View key={i} style={{ width: 80, borderRadius: 8, marginRight: 15 }}>
106
+ <PlaceholderLine
107
+ height={80}
108
+ noMargin
109
+ />
110
+ </View>
111
+ ))}
112
+ </ScrollView>
113
+ </Placeholder>
114
+ </View>
115
+ )}
116
+ {!typesState?.loading && !typesState?.error && typesState?.types && typesState?.types.length > 0 && (
117
+ <>
118
+ <BusinessCategories>
119
+ {typesState?.types.slice(0, 3).map((type: any) => (
120
+ <RenderTypes
121
+ key={type.id}
122
+ item={type}
123
+ />
72
124
  ))}
73
- </ScrollView>
74
- </Placeholder>
75
- </View>
76
- )}
77
- {!typesState?.loading && !typesState?.error && typesState?.types && typesState?.types.length > 0 && (
78
- <>
79
- <BusinessCategories>
80
- <FlatList
81
- horizontal
82
- showsHorizontalScrollIndicator={false}
83
- data={typesState?.types}
84
- renderItem={renderTypes}
85
- keyExtractor={type => type.name}
86
- />
87
- </BusinessCategories>
88
- </>
89
- )}
90
- </BCContainer>
125
+ {typesState?.types.length > 3 && (
126
+ <TouchableOpacity
127
+ style={styles.categoryStyle}
128
+ onPress={() => setIsOpenAllCategories(true)}
129
+ >
130
+ <View
131
+ style={{ ...styles.logo, backgroundColor: theme.colors.lightGray }}
132
+ >
133
+ <MaterialIcon
134
+ name='dots-horizontal'
135
+ size={32}
136
+ color={theme.colors.black}
137
+ />
138
+ </View>
139
+ <OText
140
+ style={{ textAlign: 'center' }}
141
+ size={14}
142
+ color={theme.colors.textSecondary}
143
+ numberOfLines={1}
144
+ ellipsizeMode='tail'
145
+ >
146
+ {t('SEE_ALL', 'See all')}
147
+ </OText>
148
+ </TouchableOpacity>
149
+ )}
150
+ </BusinessCategories>
151
+ </>
152
+ )}
153
+ </BCContainer>
154
+ <OModal
155
+ open={isOpenAllCategories}
156
+ onClose={() => setIsOpenAllCategories(false)}
157
+ entireModal
158
+ >
159
+ <ScrollView style={styles.allCategoriesContainer}>
160
+ <OText
161
+ size={20}
162
+ mBottom={30}
163
+ color={theme.colors.textSecondary}
164
+ style={{ paddingHorizontal: 10 }}
165
+ >
166
+ {t('ALL_CATEGORIES', 'All categories')}
167
+ </OText>
168
+ <View style={styles.allCategoriesWrapper}>
169
+ {typesState?.types.map((type: any) => (
170
+ <RenderTypes
171
+ key={type.id}
172
+ item={type}
173
+ />
174
+ ))}
175
+ </View>
176
+ </ScrollView>
177
+ </OModal>
178
+ </>
91
179
  )
92
180
  }
93
181
 
94
- const styles = StyleSheet.create({
95
- icons: {
96
- padding: 10
97
- },
98
- logo: {
99
- width: 50,
100
- height: 50,
101
- marginBottom: 15,
102
- justifyContent: 'center',
103
- alignItems: 'center',
104
- },
105
- })
106
-
107
182
  export const BusinessTypeFilter = (props: BusinessTypeFilterParams) => {
108
183
  const businessTypeFilterProps = {
109
184
  ...props,
@@ -16,15 +16,6 @@ export const BusinessCategories = styled.View`
16
16
  margin: 10px 0px;
17
17
  width: 100%;
18
18
  `
19
- export const Category = styled.View`
20
- height: 100px;
21
- min-width: 70px;
22
- margin-right: 15px;
23
- display: flex;
24
- flex-direction: column;
25
- justify-content: center;
26
- align-items: center;
27
- `
28
19
 
29
20
  export const IconContainer = styled.View`
30
21
  border-width: 1px;