ordering-ui-react-native 0.23.59 → 0.23.60

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.23.59",
3
+ "version": "0.23.60",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
  import { View, Animated, StyleSheet, TouchableOpacity } from 'react-native'
3
- import { useUtils, useLanguage, useOrder } from 'ordering-components/native'
3
+ import { useUtils, useLanguage, useOrder, ProductItemAccordion as ProductItemAccordionController } from 'ordering-components/native'
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
6
6
  import RNPickerSelect from 'react-native-picker-select'
@@ -24,7 +24,7 @@ import { OIcon, OText, OAlert, OModal } from '../shared'
24
24
 
25
25
  import { ProductItemAccordionParams } from '../../types'
26
26
 
27
- export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
27
+ export const ProductItemAccordionUI = (props: ProductItemAccordionParams) => {
28
28
 
29
29
  const {
30
30
  isDisabledEdit,
@@ -36,6 +36,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
36
36
  onDeleteProduct,
37
37
  onEditProduct,
38
38
  isFromCheckout,
39
+ productInfo
39
40
  } = props
40
41
 
41
42
  const theme = useTheme();
@@ -46,6 +47,14 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
46
47
  const hideProductDummyLogo = theme?.business_view?.components?.products?.components?.product?.components?.dummy?.hidden
47
48
  const hideProductCommentHide = isFromCheckout && theme?.checkout?.components?.cart?.components?.product?.components?.comments?.hidden
48
49
 
50
+ const styles = StyleSheet.create({
51
+ productImage: {
52
+ borderRadius: 7.6,
53
+ width: 48,
54
+ height: 48
55
+ }
56
+ })
57
+
49
58
  const pickerStyle = StyleSheet.create({
50
59
  inputAndroid: {
51
60
  width: 45,
@@ -91,24 +100,6 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
91
100
  const [isServiceOpen, setIsServiceOpen] = useState(false)
92
101
  const [productQuantityState, setProductQuantityState] = useState<any>(product.quantity.toString())
93
102
 
94
- const productInfo = () => {
95
- if (isCartProduct) {
96
- const ingredients = JSON.parse(JSON.stringify(Object.values(product.ingredients ?? {})))
97
- let options = JSON.parse(JSON.stringify(Object.values(product.options ?? {})))
98
-
99
- options = options.map((option: any) => {
100
- option.suboptions = Object.values(option.suboptions ?? {})
101
- return option
102
- })
103
- return {
104
- ...productInfo,
105
- ingredients,
106
- options
107
- }
108
- }
109
- return product
110
- }
111
-
112
103
  const handleEditProduct = (curProduct: any) => {
113
104
  if (!curProduct?.calendar_event) {
114
105
  onEditProduct && onEditProduct(curProduct)
@@ -154,8 +145,8 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
154
145
  isValid={product?.valid ?? true}
155
146
  onPress={
156
147
  (!product?.valid_menu && isCartProduct) ||
157
- !(productInfo().ingredients.length > 0 || productInfo().options.length > 0 || !!product.comment)
158
- ? null : () => setActiveState(!isActive)
148
+ !(productInfo.ingredients.length > 0 || productInfo.options.length > 0 || !!product.comment)
149
+ ? null : () => setActiveState(!isActive)
159
150
  }
160
151
  >
161
152
  <View style={{ flexDirection: 'row', alignItems: 'flex-start' }}>
@@ -246,7 +237,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
246
237
  <View style={{ display: 'flex', flexDirection: 'column', flex: 1, alignItems: 'flex-end', maxWidth: 100 }}>
247
238
  <View style={{ flexDirection: 'row' }}>
248
239
  <OText size={12} lineHeight={18} weight={'400'}>{parsePrice(product.total || product.price)}</OText>
249
- {(productInfo().ingredients.length > 0 || productInfo().options.length > 0 || !!product.comment) && (
240
+ {(productInfo.ingredients.length > 0 || productInfo.options.length > 0 || !!product.comment) && (
250
241
  <MaterialCommunityIcon name='chevron-down' size={18} />
251
242
  )}
252
243
  </View>
@@ -290,17 +281,17 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
290
281
  <View style={{ display: isActive ? 'flex' : 'none', paddingStart: isFromCheckout ? 100 : 40, marginTop: isFromCheckout ? -80 : -30 }}>
291
282
  <Animated.View>
292
283
  <AccordionContent>
293
- {productInfo().ingredients.length > 0 && productInfo().ingredients.some((ingredient: any) => !ingredient.selected) && (
284
+ {productInfo.ingredients.length > 0 && productInfo.ingredients.some((ingredient: any) => !ingredient.selected) && (
294
285
  <ProductOptionsList>
295
286
  <OText size={10} color={theme.colors.textSecondary}>{t('INGREDIENTS', 'Ingredients')}</OText>
296
- {productInfo().ingredients.map((ingredient: any, i) => !ingredient.selected && (
287
+ {productInfo.ingredients.map((ingredient: any, i) => !ingredient.selected && (
297
288
  <OText size={10} color={theme.colors.textThird} key={ingredient.id + i} style={{ marginLeft: 10 }}>{t('NO', 'No')} {ingredient.name}</OText>
298
289
  ))}
299
290
  </ProductOptionsList>
300
291
  )}
301
- {productInfo().options.length > 0 && (
292
+ {productInfo.options.length > 0 && (
302
293
  <ProductOptionsList>
303
- {productInfo().options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => (
294
+ {productInfo.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => (
304
295
  <ProductOption key={option.id}>
305
296
  <OText size={10} color={theme.colors.textSecondary}>{option.name}</OText>
306
297
  {option.suboptions.map((suboption: any) => (
@@ -350,13 +341,13 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
350
341
  )
351
342
  }
352
343
 
353
- const styles = StyleSheet.create({
354
- productImage: {
355
- borderRadius: 7.6,
356
- width: 48,
357
- height: 48
358
- },
359
- test: {
360
- overflow: 'hidden',
344
+ export const ProductItemAccordion = (props: any) => {
345
+ const productItemAccordionProps = {
346
+ ...props,
347
+ UIComponent: ProductItemAccordionUI
361
348
  }
362
- })
349
+
350
+ return (
351
+ <ProductItemAccordionController {...productItemAccordionProps} />
352
+ )
353
+ }
@@ -455,7 +455,8 @@ export interface ProductItemAccordionParams {
455
455
  onEditProduct?: (product: any) => void,
456
456
  offsetDisabled?: any,
457
457
  isFromCheckout?: any,
458
- isDisabledEdit?: any
458
+ isDisabledEdit?: any,
459
+ productInfo?: any
459
460
  }
460
461
  export interface ReviewOrderParams {
461
462
  order?: { id: number, business_id: number, logo: string, driver: any, products: Array<any>, review: any, user_review: any };