ordering-ui-react-native 0.22.25 → 0.22.27

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.22.25",
3
+ "version": "0.22.27",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -47,6 +47,7 @@ export const OrderItem = React.memo((props: any) => {
47
47
  timer: configState?.configs?.order_deadlines_enabled?.value === '1',
48
48
  slaBar: configState?.configs?.order_deadlines_enabled?.value === '1',
49
49
  })
50
+ const showExternalId = configState?.configs?.change_order_id?.value === '1'
50
51
 
51
52
  const IS_PORTRAIT = orientationState.orientation === PORTRAIT
52
53
  const platformIOS = Platform as PlatformIOSStatic
@@ -76,7 +77,7 @@ export const OrderItem = React.memo((props: any) => {
76
77
  marginLeft: 3,
77
78
  },
78
79
  title: {
79
- marginBottom: 6,
80
+ marginBottom: showExternalId ? 0 : 6,
80
81
  fontFamily: 'Poppins',
81
82
  fontStyle: 'normal',
82
83
  fontWeight: '600',
@@ -84,7 +85,7 @@ export const OrderItem = React.memo((props: any) => {
84
85
  color: theme.colors.textGray,
85
86
  },
86
87
  date: {
87
- marginBottom: 6,
88
+ marginBottom: showExternalId ? 0 : 6,
88
89
  fontFamily: 'Poppins',
89
90
  fontStyle: 'normal',
90
91
  fontWeight: 'normal',
@@ -179,17 +180,27 @@ export const OrderItem = React.memo((props: any) => {
179
180
  />
180
181
  </NotificationIcon>
181
182
  )}
182
- <View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
183
+ <View style={{ flexDirection: `${showExternalId ? 'column' : 'row'}`, flexWrap: 'wrap' }}>
184
+ {!order?.order_group_id && showExternalId && !order?.order_group && (
185
+ <OText
186
+ style={styles.date}
187
+ color={theme.colors.unselectText}
188
+ numberOfLines={1}
189
+ adjustsFontSizeToFit
190
+ >
191
+ {order?.external_id ?? t('NO_EXTERNAL_ID', 'No external Id ') + t('NO', 'Order No.') + order?.id}
192
+ </OText>
193
+ )}
183
194
  <OText
184
195
  style={styles.date}
185
196
  color={theme.colors.unselectText}
186
197
  numberOfLines={1}
187
198
  adjustsFontSizeToFit
188
199
  >
189
- {(!!order?.order_group_id && order?.order_group && isLogisticOrder
200
+ {(!showExternalId && ((!!order?.order_group_id && order?.order_group && isLogisticOrder
190
201
  ? `${order?.order_group?.orders?.length} ${t('ORDERS', 'Orders')}`
191
- : (t('NO', 'Order No.') + order.id)
192
- ) + ' · '}
202
+ : (t('NO', 'Order No.') + order?.id)
203
+ ) + ' · '))}
193
204
  {order?.delivery_datetime_utc
194
205
  ? parseDate(order?.delivery_datetime_utc)
195
206
  : parseDate(order?.delivery_datetime, { utc: false })}
@@ -1,5 +1,5 @@
1
- import React, { useState } from 'react'
2
- import { View, Animated, StyleSheet, Platform, TouchableOpacity } from 'react-native'
1
+ import React, { useEffect, useState } from 'react'
2
+ import { View, Animated, StyleSheet, TouchableOpacity } from 'react-native'
3
3
  import { useUtils, useLanguage, useOrder } from 'ordering-components/native'
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
@@ -47,25 +47,34 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
47
47
 
48
48
  const pickerStyle = StyleSheet.create({
49
49
  inputAndroid: {
50
- width: 34,
50
+ width: 45,
51
51
  textAlign: 'center',
52
52
  overflow: 'visible',
53
53
  fontSize: 12,
54
- height: 20,
55
- padding: 0,
56
- color: theme.colors.textNormal
54
+ height: 30,
55
+ color: theme.colors.textNormal,
56
+ backgroundColor: theme.colors.backgroundGray100,
57
+ paddingVertical: 8,
58
+ paddingRight: 10,
59
+ paddingLeft: 0,
60
+ borderRadius: 7.6,
57
61
  },
58
62
  inputIOS: {
59
- width: 34,
63
+ width: 45,
60
64
  textAlign: 'center',
61
65
  overflow: 'visible',
62
66
  fontSize: 12,
67
+ backgroundColor: theme.colors.backgroundGray100,
68
+ paddingVertical: 8,
69
+ paddingRight: 15,
70
+ paddingLeft: 0,
71
+ borderRadius: 7.6,
63
72
  },
64
73
  icon: {
65
74
  position: 'absolute',
66
75
  zIndex: 1,
67
- top: -4,
68
- end: -4,
76
+ top: 0,
77
+ end: 8,
69
78
  },
70
79
  placeholder: {
71
80
  color: theme.colors.secundaryContrast
@@ -79,9 +88,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
79
88
 
80
89
  const [isActive, setActiveState] = useState(false)
81
90
  const [isServiceOpen, setIsServiceOpen] = useState(false)
82
- const [productQuantityState, setProductQuantityState] = useState(product.quantity.toString())
83
- // const [setHeight, setHeightState] = useState({ height: new Animated.Value(0) })
84
- // const [setRotate, setRotateState] = useState({ angle: new Animated.Value(0) })
91
+ const [productQuantityState, setProductQuantityState] = useState<any>(product.quantity.toString())
85
92
 
86
93
  const productInfo = () => {
87
94
  if (isCartProduct) {
@@ -109,20 +116,6 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
109
116
  setIsServiceOpen(true)
110
117
  }
111
118
 
112
- /* const toggleAccordion = () => {
113
- if ((!product?.valid_menu && isCartProduct)) return
114
- if (isActive) {
115
- Animated.timing(setHeight.height, {
116
- toValue: 100,
117
- duration: 500,
118
- easing: Easing.linear,
119
- useNativeDriver: false,
120
- }).start()
121
- } else {
122
- setHeightState({height: new Animated.Value(0)})
123
- }
124
- }*/
125
-
126
119
  const handleChangeQuantity = (value: string) => {
127
120
  if (!orderState.loading) {
128
121
  setProductQuantityState(value)
@@ -139,10 +132,6 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
139
132
  return `${quantity} x ${name} ${pos} +${price}`
140
133
  }
141
134
 
142
- /*useEffect(() => {
143
- toggleAccordion()
144
- }, [isActive])*/
145
-
146
135
  const productOptions = getProductMax && [...Array(getProductMax(product) + 1),].map((_: any, opt: number) => {
147
136
  return {
148
137
  label: opt === 0 ? t('REMOVE', 'Remove') : opt.toString(),
@@ -150,15 +139,23 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
150
139
  }
151
140
  })
152
141
 
142
+ useEffect(() => {
143
+ if (product.quantity.toString() === productQuantityState || productQuantityState) {
144
+ setProductQuantityState(null)
145
+ }
146
+ }, [product.quantity])
147
+
153
148
  return (
154
149
  <>
155
150
  <AccordionSection>
156
151
  <Accordion
157
- isValid={product?.valid ?? true}
158
- onPress={() => (!product?.valid_menu && isCartProduct)
159
- ? {}
160
- : setActiveState(!isActive)}
161
152
  activeOpacity={1}
153
+ isValid={product?.valid ?? true}
154
+ onPress={
155
+ (!product?.valid_menu && isCartProduct) ||
156
+ !(productInfo().ingredients.length > 0 || productInfo().options.length > 0 || !!product.comment)
157
+ ? null : () => setActiveState(!isActive)
158
+ }
162
159
  >
163
160
  <View style={{ flexDirection: 'row', alignItems: 'flex-start' }}>
164
161
  <ContentInfo>
@@ -215,16 +212,20 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
215
212
  <RNPickerSelect
216
213
  items={productOptions}
217
214
  onValueChange={handleChangeQuantity}
218
- value={productQuantityState}
215
+ value={productQuantityState ?? product.quantity.toString()}
219
216
  style={pickerStyle}
220
217
  useNativeAndroidPickerStyle={false}
221
218
  placeholder={{}}
222
- touchableWrapperProps={{
223
- style: {
224
- width: 40,
225
- }
226
- }}
227
- Icon={() => <View style={pickerStyle.icon}><OIcon src={theme.images.general.arrow_down} color={theme.colors.textNormal} width={8} /></View>}
219
+ touchableWrapperProps={{ style: { width: 45 } }}
220
+ Icon={() => (
221
+ <View style={pickerStyle.icon}>
222
+ <OIcon
223
+ src={theme.images.general.arrow_down}
224
+ color={theme.colors.textNormal}
225
+ width={8}
226
+ />
227
+ </View>
228
+ )}
228
229
  disabled={orderState.loading}
229
230
  />
230
231
  </ProductInfo>
@@ -17,9 +17,6 @@ export const Accordion = styled.TouchableOpacity`
17
17
 
18
18
  export const ProductInfo = styled.View`
19
19
  margin-horizontal: 7px;
20
- background-color: ${(props: any) => props.theme.colors.backgroundGray100};
21
- padding: 4px 12px 4px 0px;
22
- border-radius: 7.6px;
23
20
  `
24
21
 
25
22
  export const ProductQuantity = styled.View`