ordering-ui-react-native 0.14.24 → 0.14.28

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.14.24",
3
+ "version": "0.14.28",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -70,6 +70,7 @@
70
70
  "react-native-bootsplash": "^3.2.3",
71
71
  "react-native-calendar-picker": "^7.1.2",
72
72
  "react-native-calendar-strip": "^2.2.5",
73
+ "react-native-color-matrix-image-filters": "^5.2.10",
73
74
  "react-native-country-picker-modal": "^2.0.0",
74
75
  "react-native-credit-card-input": "^0.4.1",
75
76
  "react-native-document-picker": "^5.2.0",
@@ -150,10 +150,10 @@ const CheckoutUI = (props: any) => {
150
150
  const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
151
151
  const cartsWithProducts = carts && Object.values(carts).filter((cart: any) => cart.products.length) || null
152
152
 
153
- const deliveryOptions = instructionsOptions?.result && instructionsOptions?.result?.filter((option: any) => option?.enabled)?.map(option => {
153
+ const deliveryOptions = instructionsOptions?.result && instructionsOptions?.result?.filter((option: any) => option?.enabled)?.map((option: any) => {
154
154
  return {
155
- value: option?.id, key: option?.id, label: option?.name
156
- }
155
+ value: option?.id, key: option?.id, label: t(option?.name.toUpperCase().replace(/\s/g, '_'), option?.name)
156
+ }
157
157
  })
158
158
 
159
159
  const handlePlaceOrder = () => {
@@ -45,6 +45,7 @@ const imgOptions = {
45
45
  includeBase64: true,
46
46
  selectionLimit: 0
47
47
  }
48
+ const filterSpecialStatus = ['prepared_in', 'delivered_in']
48
49
 
49
50
  const MessagesUI = (props: MessagesParams) => {
50
51
  const {
@@ -118,7 +119,11 @@ const MessagesUI = (props: MessagesParams) => {
118
119
  const messageConsole = (message: any) => {
119
120
  return message.change?.attribute !== 'driver_id'
120
121
  ?
121
- `${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
122
+ `${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${
123
+ filterSpecialStatus.includes(message.change.attribute) ?
124
+ `${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new} ${t('MINUTES', 'Minutes')}` :
125
+ `${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
126
+ }`
122
127
  : message.change.new
123
128
  ?
124
129
  `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''}`
@@ -15,5 +15,5 @@ export const WrapperNotFound = styled.View`
15
15
  export const ProductsWrapper = styled.View`
16
16
  flex-direction: row;
17
17
  flex-wrap: wrap;
18
- align-items: flex-start;
18
+ margin-bottom: 20px;
19
19
  `
@@ -6,7 +6,7 @@ import {
6
6
  CardInfo,
7
7
  SoldOut
8
8
  } from './styles'
9
- import { StyleSheet, TouchableOpacity, Dimensions } from 'react-native'
9
+ import { StyleSheet, TouchableOpacity, Dimensions, View } from 'react-native'
10
10
  import { OText, OIcon } from '../shared'
11
11
  import { useTheme } from 'styled-components/native'
12
12
 
@@ -23,11 +23,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
23
23
 
24
24
  const styles = StyleSheet.create({
25
25
  container: {
26
- width: (windowWidth - 80) / 2,
27
- height: (windowWidth - 80) / 2 + 40
28
- },
29
- textStyle: {
30
- flex: 1,
26
+ width: (windowWidth - 80) / 2
31
27
  },
32
28
  soldOutTextStyle : {
33
29
  textTransform: 'capitalize',
@@ -35,9 +31,14 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
35
31
  fontSize: 12,
36
32
  lineHeight: 18
37
33
  },
38
- productStyle: {
34
+ imageWrapper: {
39
35
  width: (windowWidth - 160) / 2,
40
36
  height: (windowWidth - 160) / 2,
37
+ position: 'relative'
38
+ },
39
+ productStyle: {
40
+ width: '100%',
41
+ height: '100%',
41
42
  borderRadius: 3,
42
43
  marginTop: 5
43
44
  },
@@ -74,26 +75,30 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
74
75
  onPress={() => onProductClick?.(product)}
75
76
  activeOpacity={0.8}
76
77
  >
77
- <OIcon
78
- url={optimizeImage(product?.images, 'h_200,c_limit')}
79
- src={!product?.images && theme.images.dummies.product}
80
- style={{...styles.productStyle, opacity: (isSoldOut || maxProductQuantity <= 0) ? 0.4 : 1}}
81
- />
78
+ <View
79
+ style={styles.imageWrapper}
80
+ >
81
+ <OIcon
82
+ url={optimizeImage(product?.images, 'h_200,c_limit')}
83
+ src={!product?.images && theme.images.dummies.product}
84
+ style={{...styles.productStyle, opacity: (isSoldOut || maxProductQuantity <= 0) ? 0.4 : 1}}
85
+ />
86
+ {(isSoldOut || maxProductQuantity <= 0) && (
87
+ <SoldOut>
88
+ <OText size={10} style={styles.soldOutTextStyle}>{t('SOLD_OUT', 'SOLD OUT')}</OText>
89
+ </SoldOut>
90
+ )}
91
+ </View>
82
92
  <CardInfo>
83
93
  <OText color={theme.colors.textPrimary} style={{...theme.labels.normal, marginTop: 9}}>{parsePrice(product?.price)}</OText>
84
- <OText numberOfLines={1} ellipsizeMode='tail' style={{...styles.textStyle, ...theme.labels.small}}>{product?.name}</OText>
85
- <OText color={theme.colors.textSecondary} size={9} numberOfLines={2} ellipsizeMode='tail' style={{...styles.textStyle, ...theme.labels.small}}>{product?.description}</OText>
94
+ <OText numberOfLines={1} ellipsizeMode='tail' style={{...theme.labels.small}}>{product?.name}</OText>
95
+ <OText color={theme.colors.textSecondary} size={9} numberOfLines={2} ellipsizeMode='tail' style={{...theme.labels.small}}>{product?.description}</OText>
86
96
  </CardInfo>
87
97
 
88
98
  <TouchableOpacity style={styles.addBtn} onPress={() => onProductClick?.(product)} activeOpacity={0.7}>
89
99
  <OIcon src={theme.images.general.plus_circle} />
90
100
  </TouchableOpacity>
91
101
 
92
- {(isSoldOut || maxProductQuantity <= 0) && (
93
- <SoldOut>
94
- <OText size={10} style={styles.soldOutTextStyle}>{t('SOLD_OUT', 'SOLD OUT')}</OText>
95
- </SoldOut>
96
- )}
97
102
  </CardContainer>
98
103
  )
99
104
  }
@@ -1,12 +1,9 @@
1
1
  import styled from 'styled-components/native'
2
2
 
3
3
  export const CardContainer = styled.TouchableOpacity`
4
- /* flex-grow: 1; */
5
- align-items: flex-start;
4
+ flex-direction: column;
6
5
  padding: 10px;
7
6
  position: relative;
8
- /* margin-end: 10px; */
9
- border-radius: 3px;
10
7
  `
11
8
  export const CardInfo = styled.View`
12
9
  flex: 1;
@@ -16,6 +13,7 @@ export const SoldOut = styled.View`
16
13
  position: absolute;
17
14
  background: ${(props: any) => props.theme.colors.black} 0% 0% no-repeat padding-box;
18
15
  padding: 3px 9px;
19
- top: 91px;
20
- left: 10px;
16
+ left: 0px;
17
+ bottom: -5px;
18
+ border-radius: 3px;
21
19
  `
@@ -9,16 +9,19 @@ import {
9
9
  BIInfo,
10
10
  BIContentInfo,
11
11
  BITotal,
12
- BIActions
12
+ BIActions,
13
+ PriceContainer
13
14
  } from './styles';
14
- import { OAlert, OIcon, OText } from '../shared';
15
+ import { OAlert, OButton, OIcon, OText } from '../shared';
15
16
 
16
17
  export const BusinessItemAccordion = (props: any) => {
17
18
  const {
18
19
  cart,
19
20
  moment,
20
- singleBusiness,
21
- handleClearProducts
21
+ singleBusiness,
22
+ handleClearProducts,
23
+ handleClickCheckout,
24
+ checkoutButtonDisabled
22
25
  } = props
23
26
 
24
27
  const [orderState] = useOrder();
@@ -41,7 +44,7 @@ export const BusinessItemAccordion = (props: any) => {
41
44
  }, [orderState?.carts])
42
45
 
43
46
  return (
44
- <BIContainer isClosed={isClosed}>
47
+ <BIContainer isClosed={isClosed} checkoutVisible={!isActive && !isClosed && !!isProducts && !checkoutButtonDisabled}>
45
48
  <BIHeader
46
49
  isClosed={isClosed}
47
50
  onPress={() => !isClosed ? setActiveState(!isActive) : isClosed}
@@ -71,37 +74,39 @@ export const BusinessItemAccordion = (props: any) => {
71
74
  {props.onNavigationRedirect && !isClosed && (
72
75
  <>
73
76
  <TouchableOpacity onPress={() => props.onNavigationRedirect('Business', { store: cart?.business?.slug })}>
74
- <OText color={theme.colors.textSecondary} size={12} lineHeight={18} style={{ textDecorationLine: 'underline' }}>{t('GO_TO_STORE', 'Go to store')}</OText>
77
+ <OText color={theme.colors.primary} size={12} lineHeight={18} style={{ textDecorationLine: 'underline' }}>{t('GO_TO_STORE', 'Go to store')}</OText>
75
78
  </TouchableOpacity>
76
- <OText color={theme.colors.textSecondary}>{' \u2022 '}</OText>
77
79
  </>
78
80
  )}
79
81
  {!isCartPending && !isClosed && (
80
- <OAlert
81
- title={t('DELETE_CART', 'Delete Cart')}
82
- message={t('QUESTION_DELETE_CART', 'Are you sure to you wants delete the selected cart')}
83
- onAccept={() => handleClearProducts()}
84
- >
85
- <OText size={12} lineHeight={18} color={theme.colors.textSecondary} style={{ textDecorationLine: 'underline' }}>{t('CLEAR_CART', 'Clear cart')}</OText>
86
- </OAlert>
82
+ <>
83
+ <OText color={theme.colors.textSecondary}>{' \u2022 '}</OText>
84
+ <OAlert
85
+ title={t('DELETE_CART', 'Delete Cart')}
86
+ message={t('QUESTION_DELETE_CART', 'Are you sure to you wants delete the selected cart')}
87
+ onAccept={() => handleClearProducts()}
88
+ >
89
+ <OText size={12} lineHeight={18} color={theme.colors.primary} style={{ textDecorationLine: 'underline' }}>{t('CLEAR_CART', 'Clear cart')}</OText>
90
+ </OAlert>
91
+ </>
92
+ )}
93
+ {props.handleChangeStore && (
94
+ <>
95
+ <OText color={theme.colors.textSecondary}>{' \u2022 '}</OText>
96
+ <TouchableOpacity
97
+ onPress={props.handleChangeStore}
98
+ >
99
+ <OText
100
+ size={12}
101
+ lineHeight={18}
102
+ color={theme.colors.textSecondary}
103
+ style={{ textDecorationLine: 'underline' }}
104
+ >
105
+ {t('CHANGE_STORE', 'Change store')}
106
+ </OText>
107
+ </TouchableOpacity>
108
+ </>
87
109
  )}
88
- {props.handleChangeStore && (
89
- <>
90
- <OText color={theme.colors.textSecondary}>{' \u2022 '}</OText>
91
- <TouchableOpacity
92
- onPress={props.handleChangeStore}
93
- >
94
- <OText
95
- size={12}
96
- lineHeight={18}
97
- color={theme.colors.textSecondary}
98
- style={{ textDecorationLine: 'underline' }}
99
- >
100
- {t('CHANGE_STORE', 'Change store')}
101
- </OText>
102
- </TouchableOpacity>
103
- </>
104
- )}
105
110
  </View>
106
111
  </BIContentInfo>
107
112
  </BIInfo>
@@ -134,6 +139,19 @@ export const BusinessItemAccordion = (props: any) => {
134
139
  )}
135
140
  </BIActions>
136
141
  </BIHeader>
142
+ {!isActive && !isClosed && !!isProducts && !checkoutButtonDisabled && (
143
+ <PriceContainer>
144
+ <OText>{parsePrice(cart?.total)}</OText>
145
+ <OButton
146
+ onClick={handleClickCheckout}
147
+ textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
148
+ style={{ width: 160, flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
149
+ text={t('CHECKOUT', 'Checkout')}
150
+ bgColor={(cart?.subtotal < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
151
+ borderColor={theme.colors.primary}
152
+ />
153
+ </PriceContainer>
154
+ )}
137
155
 
138
156
  <BIContent style={{ display: isActive ? 'flex' : 'none' }}>
139
157
  {props.children}
@@ -52,3 +52,10 @@ export const BIActions = styled.View`
52
52
  align-items: center;
53
53
  justify-content: flex-end;
54
54
  `
55
+
56
+ export const PriceContainer = styled.View`
57
+ flex-direction: row;
58
+ justify-content: space-between;
59
+ align-items: center;
60
+ flex: 1
61
+ `
@@ -42,7 +42,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
42
42
  return (
43
43
  <ProductsContainer>
44
44
  {category.id &&
45
- categoryState.products?.map((product: any) => (
45
+ categoryState.products?.sort((a: any, b: any) => a.rank - b.rank).map((product: any) => (
46
46
  <SingleProductCard
47
47
  key={'prod_' + product.id}
48
48
  isSoldOut={product.inventoried && !product.quantity}
@@ -63,7 +63,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
63
63
  {t('FEATURED', 'Featured')}
64
64
  </OText>
65
65
  <>
66
- {categoryState.products?.map(
66
+ {categoryState.products?.sort((a: any, b: any) => a.rank - b.rank).map(
67
67
  (product: any, i: any) =>
68
68
  product.featured && (
69
69
  <SingleProductCard
@@ -110,7 +110,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
110
110
  </OText>
111
111
  </View>
112
112
  <>
113
- {products.map((product: any, i: any) => (
113
+ {products.sort((a: any, b: any) => a.rank - b.rank).map((product: any, i: any) => (
114
114
  <SingleProductCard
115
115
  key={i}
116
116
  isSoldOut={product.inventoried && !product.quantity}
@@ -145,6 +145,8 @@ const CartUI = (props: any) => {
145
145
  handleCartOpen={handleCartOpen}
146
146
  onNavigationRedirect={props.onNavigationRedirect}
147
147
  handleChangeStore={props.isFranchiseApp ? () => setOpenChangeStore(true) : null}
148
+ handleClickCheckout={() => setOpenUpselling(true)}
149
+ checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
148
150
  >
149
151
  {cart?.products?.length > 0 && cart?.products.map((product: any) => (
150
152
  <ProductItemAccordion
@@ -137,7 +137,7 @@ const CheckoutUI = (props: any) => {
137
137
 
138
138
  const deliveryOptions = instructionsOptions?.result && instructionsOptions?.result?.filter((option: any) => option?.enabled)?.map((option: any) => {
139
139
  return {
140
- value: option?.id, key: option?.id, label: option?.name
140
+ value: option?.id, key: option?.id, label: t(option?.name.toUpperCase().replace(/\s/g, '_'), option?.name)
141
141
  }
142
142
  })
143
143
 
@@ -12,6 +12,34 @@ import { MessagesParams } from '../../types'
12
12
  import { useWindowDimensions } from 'react-native'
13
13
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
14
14
 
15
+ const ORDER_STATUS: any = {
16
+ 0: 'ORDER_STATUS_PENDING',
17
+ 1: 'ORDERS_COMPLETED',
18
+ 2: 'ORDER_REJECTED',
19
+ 3: 'ORDER_STATUS_IN_BUSINESS',
20
+ 4: 'ORDER_READY',
21
+ 5: 'ORDER_REJECTED_RESTAURANT',
22
+ 6: 'ORDER_STATUS_CANCELLEDBYDRIVER',
23
+ 7: 'ORDER_STATUS_ACCEPTEDBYRESTAURANT',
24
+ 8: 'ORDER_CONFIRMED_ACCEPTED_BY_DRIVER',
25
+ 9: 'ORDER_PICKUP_COMPLETED_BY_DRIVER',
26
+ 10: 'ORDER_PICKUP_FAILED_BY_DRIVER',
27
+ 11: 'ORDER_DELIVERY_COMPLETED_BY_DRIVER',
28
+ 12: 'ORDER_DELIVERY_FAILED_BY_DRIVER',
29
+ 13: 'PREORDER',
30
+ 14: 'ORDER_NOT_READY',
31
+ 15: 'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
32
+ 16: 'ORDER_STATUS_CANCELLED_BY_CUSTOMER',
33
+ 17: 'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
34
+ 18: 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS',
35
+ 19: 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
36
+ 20: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
37
+ 21: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
38
+ }
39
+
40
+ const filterSpecialStatus = ['prepared_in', 'delivered_in']
41
+
42
+
15
43
  const MessagesUI = (props: MessagesParams) => {
16
44
  const {
17
45
  type,
@@ -94,58 +122,6 @@ const MessagesUI = (props: MessagesParams) => {
94
122
  });
95
123
  };
96
124
 
97
- const getStatus = (status: number) => {
98
-
99
- switch (status) {
100
- case 0:
101
- return 'ORDER_STATUS_PENDING'
102
- case 1:
103
- return 'ORDERS_COMPLETED'
104
- case 2:
105
- return 'ORDER_REJECTED'
106
- case 3:
107
- return 'ORDER_STATUS_IN_BUSINESS'
108
- case 4:
109
- return 'ORDER_READY'
110
- case 5:
111
- return 'ORDER_REJECTED_RESTAURANT'
112
- case 6:
113
- return 'ORDER_STATUS_CANCELLEDBYDRIVER'
114
- case 7:
115
- return 'ORDER_STATUS_ACCEPTEDBYRESTAURANT'
116
- case 8:
117
- return 'ORDER_CONFIRMED_ACCEPTED_BY_DRIVER'
118
- case 9:
119
- return 'ORDER_PICKUP_COMPLETED_BY_DRIVER'
120
- case 10:
121
- return 'ORDER_PICKUP_FAILED_BY_DRIVER'
122
- case 11:
123
- return 'ORDER_DELIVERY_COMPLETED_BY_DRIVER'
124
- case 12:
125
- return 'ORDER_DELIVERY_FAILED_BY_DRIVER'
126
- case 13:
127
- return 'PREORDER'
128
- case 14:
129
- return 'ORDER_NOT_READY'
130
- case 15:
131
- return 'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER'
132
- case 16:
133
- return 'ORDER_STATUS_CANCELLED_BY_CUSTOMER'
134
- case 17:
135
- return 'ORDER_NOT_PICKEDUP_BY_CUSTOMER'
136
- case 18:
137
- return 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS'
138
- case 19:
139
- return 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER'
140
- case 20:
141
- return 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS'
142
- case 21:
143
- return 'ORDER_CUSTOMER_ARRIVED_BUSINESS'
144
- default:
145
- return status
146
- }
147
- }
148
-
149
125
  const onSubmit = (values: any) => {
150
126
  handleSend && handleSend()
151
127
  setImage && setImage(null)
@@ -154,14 +130,18 @@ const MessagesUI = (props: MessagesParams) => {
154
130
 
155
131
  const messageConsole = (message: any) => {
156
132
  return message.change?.attribute !== 'driver_id'
133
+ ?
134
+ `${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${
135
+ filterSpecialStatus.includes(message.change.attribute) ?
136
+ `${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new} ${t('MINUTES', 'Minutes')}` :
137
+ `${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
138
+ }`
139
+ : message.change.new
157
140
  ?
158
- `${t('ORDER', 'Order')} ${message.change.attribute} ${t('CHANGED_FROM', 'Changed from')} ${message.change.old !== null && t(getStatus(parseInt(message.change.old, 10)))} ${t('TO', 'to')} ${t(getStatus(parseInt(message.change.new, 10)))}`
159
- : message.change.new
160
- ?
161
- `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''}`
162
- :
163
- `${t('DRIVER_UNASSIGNED', 'Driver unassigned')}`
164
- }
141
+ `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''}`
142
+ :
143
+ `${t('DRIVER_UNASSIGNED', 'Driver unassigned')}`
144
+ }
165
145
 
166
146
  useEffect(() => {
167
147
  let newMessages: Array<any> = []
@@ -894,6 +894,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
894
894
  orderId={order?.id}
895
895
  messages={messages}
896
896
  order={order}
897
+ business={openModalForBusiness}
898
+ driver={openModalForDriver}
897
899
  setMessages={setMessages}
898
900
  onClose={handleCloseModal}
899
901
  />
@@ -12,6 +12,9 @@ import { ProductOption } from '../ProductOption';
12
12
  import Swiper from 'react-native-swiper'
13
13
  import FastImage from 'react-native-fast-image';
14
14
  import IconAntDesign from 'react-native-vector-icons/AntDesign';
15
+ import {
16
+ Grayscale
17
+ } from 'react-native-color-matrix-image-filters'
15
18
 
16
19
  import { View, TouchableOpacity, StyleSheet, Dimensions, Platform, AppRegistry, I18nManager } from 'react-native';
17
20
 
@@ -149,9 +152,12 @@ export const ProductOptionsUI = (props: any) => {
149
152
  if (errors[`id:${id}`]) {
150
153
  bgColor = 'rgba(255, 0, 0, 0.05)';
151
154
  }
152
- if (isSoldOut || maxProductQuantity <= 0) {
155
+ if (maxProductQuantity <= 0) {
153
156
  bgColor = 'hsl(0, 0%, 72%)';
154
157
  }
158
+ if (isSoldOut) {
159
+ bgColor = theme.colors.white;
160
+ }
155
161
  return bgColor;
156
162
  };
157
163
 
@@ -316,13 +322,15 @@ export const ProductOptionsUI = (props: any) => {
316
322
  style={styles.slide1}
317
323
  key={i}
318
324
  >
319
- <FastImage
320
- style={{ height: '100%' }}
321
- source={{
322
- uri: optimizeImage(img, 'h_258,c_limit'),
323
- priority: FastImage.priority.normal,
324
- }}
325
- />
325
+ <Grayscale amount={isSoldOut ? 1 : 0}>
326
+ <FastImage
327
+ style={{ height: '100%' }}
328
+ source={{
329
+ uri: optimizeImage(img, 'h_258,c_limit'),
330
+ priority: FastImage.priority.normal,
331
+ }}
332
+ />
333
+ </Grayscale>
326
334
  </View>
327
335
  ))}
328
336
  </Swiper>
@@ -346,17 +354,19 @@ export const ProductOptionsUI = (props: any) => {
346
354
  opacity: index === thumbsSwiper ? 1 : 0.8
347
355
  }}
348
356
  >
349
- <OIcon
350
- url={img}
351
- style={{
352
- borderColor: theme.colors.lightGray,
353
- borderRadius: 8,
354
- minHeight: '100%'
355
- }}
356
- width={56}
357
- height={56}
358
- cover
359
- />
357
+ <Grayscale amount={isSoldOut ? 1 : 0}>
358
+ <OIcon
359
+ url={img}
360
+ style={{
361
+ borderColor: theme.colors.lightGray,
362
+ borderRadius: 8,
363
+ minHeight: '100%'
364
+ }}
365
+ width={56}
366
+ height={56}
367
+ cover
368
+ />
369
+ </Grayscale>
360
370
  </View>
361
371
  </TouchableOpacity>
362
372
 
@@ -488,13 +498,7 @@ export const ProductOptionsUI = (props: any) => {
488
498
  {t('INGREDIENTS', 'Ingredients')}
489
499
  </OText>
490
500
  </SectionTitle>
491
- <WrapperIngredients
492
- style={{
493
- backgroundColor:
494
- isSoldOut || maxProductQuantity <= 0
495
- ? 'hsl(0, 0%, 72%)'
496
- : theme.colors.white,
497
- }}>
501
+ <WrapperIngredients>
498
502
  {product?.ingredients.map((ingredient: any) => (
499
503
  <ProductIngredient
500
504
  key={ingredient.id}
@@ -503,6 +507,7 @@ export const ProductOptionsUI = (props: any) => {
503
507
  productCart.ingredients[`id:${ingredient.id}`]
504
508
  }
505
509
  onChange={handleChangeIngredientState}
510
+ isSoldOut={isSoldOut}
506
511
  />
507
512
  ))}
508
513
  </WrapperIngredients>
@@ -540,6 +545,7 @@ export const ProductOptionsUI = (props: any) => {
540
545
  return (
541
546
  <ProductOptionSubOption
542
547
  key={suboption.id}
548
+ isSoldOut={isSoldOut}
543
549
  onChange={
544
550
  handleChangeSuboptionState
545
551
  }
@@ -573,13 +579,7 @@ export const ProductOptionsUI = (props: any) => {
573
579
  {t('INGREDIENTS', 'Ingredients')}
574
580
  </OText>
575
581
  </SectionTitle>
576
- <WrapperIngredients
577
- style={{
578
- backgroundColor:
579
- isSoldOut || maxProductQuantity <= 0
580
- ? 'hsl(0, 0%, 72%)'
581
- : theme.colors.white,
582
- }}>
582
+ <WrapperIngredients>
583
583
  {product?.ingredients.map((ingredient: any) => (
584
584
  <ProductIngredient
585
585
  key={ingredient.id}
@@ -588,6 +588,7 @@ export const ProductOptionsUI = (props: any) => {
588
588
  productCart.ingredients[`id:${ingredient.id}`]
589
589
  }
590
590
  onChange={handleChangeIngredientState}
591
+ isSoldOut={isSoldOut}
591
592
  />
592
593
  ))}
593
594
  </WrapperIngredients>
@@ -10,18 +10,19 @@ const ProductIngredientUI = (props: any) => {
10
10
  const {
11
11
  state,
12
12
  ingredient,
13
- toggleSelect
13
+ toggleSelect,
14
+ isSoldOut
14
15
  } = props
15
16
 
16
17
  const theme = useTheme();
17
18
 
18
19
  return (
19
- <Container onPress={() => toggleSelect()}>
20
+ <Container disabled={isSoldOut} onPress={() => toggleSelect()}>
20
21
  <View>
21
- {state?.selected ? (
22
+ {state?.selected && !isSoldOut ? (
22
23
  <MaterialCommunityIcon name='checkbox-marked' color={theme.colors.primary} size={24} />
23
24
  ) : (
24
- <MaterialCommunityIcon name='checkbox-blank-outline' color={theme.colors.backgroundDark} size={24} />
25
+ <MaterialCommunityIcon name='checkbox-blank-outline' color='#cbcbcb' size={24} />
25
26
  )}
26
27
  </View>
27
28
  <OText mLeft={10}>
@@ -53,8 +53,8 @@ export const ProductOptionSubOptionUI = (props: any) => {
53
53
  const price = option?.with_half_option && suboption?.half_price && state.position !== 'whole' ? suboption?.half_price : suboption?.price
54
54
 
55
55
  return (
56
- <Container disabled={disabled}>
57
- <IconControl onPress={() => handleSuboptionClick()}>
56
+ <Container>
57
+ <IconControl disabled={disabled} onPress={() => handleSuboptionClick()}>
58
58
  {((option?.min === 0 && option?.max === 1) || option?.max > 1) ? (
59
59
  state?.selected ? (
60
60
  <OIcon src={theme.images.general.check_act} color={theme.colors.primary} width={16} />
@@ -73,30 +73,30 @@ export const ProductOptionSubOptionUI = (props: any) => {
73
73
  </OText>
74
74
  </IconControl>
75
75
  {showMessage && <OText size={10} mLeft={4} mRight={4} style={{ flex: 1, textAlign: 'center' }} color={theme.colors.primary}>{`${t('OPTIONS_MAX_LIMIT', 'Maximum options to choose')}: ${option?.max}`}</OText>}
76
- {option?.allow_suboption_quantity && (
76
+ {option?.allow_suboption_quantity && state?.selected && (
77
77
  <QuantityControl>
78
- <Checkbox disabled={state.quantity === 0} onPress={decrement}>
78
+ <Checkbox disabled={disabled || state.quantity === 0} onPress={decrement}>
79
79
  <OIcon
80
80
  src={theme.images.general.minus}
81
81
  width={16}
82
- color={state.quantity === 0 ? theme.colors.disabled : theme.colors.primary}
82
+ color={state.quantity === 0 || disabled ? theme.colors.disabled : theme.colors.primary}
83
83
  />
84
84
  </Checkbox>
85
85
  <OText mLeft={5} mRight={5}>
86
86
  {state.quantity}
87
87
  </OText>
88
- <Checkbox disabled={disableIncrement} onPress={increment}>
88
+ <Checkbox disabled={disabled || disableIncrement} onPress={increment}>
89
89
  <OIcon
90
90
  src={theme.images.general.plus}
91
91
  width={16}
92
- color={disableIncrement ? theme.colors.disabled : theme.colors.primary}
92
+ color={disableIncrement || disabled ? theme.colors.disabled : theme.colors.primary}
93
93
  />
94
94
  </Checkbox>
95
95
  </QuantityControl>
96
96
  )}
97
- {option?.with_half_option && (
97
+ {option?.with_half_option && state?.selected && (
98
98
  <PositionControl>
99
- <Circle onPress={() => changePosition('left')}>
99
+ <Circle disabled={disabled} onPress={() => changePosition('left')}>
100
100
  <OIcon
101
101
  src={theme.images.general.half_l}
102
102
  color={state.selected && state.position === 'left' ? theme.colors.primary : '#cbcbcb'}
@@ -104,14 +104,14 @@ export const ProductOptionSubOptionUI = (props: any) => {
104
104
  style={styles.inverse}
105
105
  />
106
106
  </Circle>
107
- <Circle onPress={() => changePosition('whole')}>
107
+ <Circle disabled={disabled} onPress={() => changePosition('whole')}>
108
108
  <OIcon
109
109
  src={theme.images.general.half_f}
110
110
  color={state.selected && state.position === 'whole' ? theme.colors.primary : '#cbcbcb'}
111
111
  width={16}
112
112
  />
113
113
  </Circle>
114
- <Circle onPress={() => changePosition('right')}>
114
+ <Circle disabled={disabled} onPress={() => changePosition('right')}>
115
115
  <OIcon
116
116
  src={theme.images.general.half_r}
117
117
  color={state.selected && state.position === 'right' ? theme.colors.primary : '#cbcbcb'}