ordering-ui-react-native 0.14.94 → 0.14.97

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.94",
3
+ "version": "0.14.97",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -220,7 +220,7 @@ const CartUI = (props: any) => {
220
220
  <OSRow>
221
221
  <OText numberOfLines={1}>
222
222
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
223
- ({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
223
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
224
224
  </OText>
225
225
  <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
226
226
  <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
@@ -535,7 +535,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
535
535
  <OSRow>
536
536
  <OText numberOfLines={1}>
537
537
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
538
- ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
538
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
539
539
  </OText>
540
540
  <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })}>
541
541
  <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
@@ -1,13 +1,14 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { ProductsList, useLanguage, useUtils, useConfig } from 'ordering-components/native';
3
3
  import { SingleProductCard } from '../SingleProductCard';
4
4
  import { NotFoundSource } from '../NotFoundSource';
5
5
  import { BusinessProductsListParams } from '../../types';
6
- import { OIcon, OText } from '../shared';
6
+ import { OButton, OIcon, OModal, OText } from '../shared';
7
7
  import { ProductsContainer, ErrorMessage, WrapperNotFound } from './styles';
8
8
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
9
9
  import { View } from 'react-native';
10
10
  import { StyleSheet } from 'react-native';
11
+ import { useTheme } from 'styled-components/native';
11
12
 
12
13
  const BusinessProductsListUI = (props: BusinessProductsListParams) => {
13
14
  const {
@@ -32,8 +33,9 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
32
33
  const [, t] = useLanguage();
33
34
  const [{ optimizeImage }] = useUtils()
34
35
  const [{ configs }] = useConfig()
36
+ const theme = useTheme()
35
37
  const isUseParentCategory = configs?.use_parent_category?.value === 'true' || configs?.use_parent_category?.value === '1'
36
-
38
+ const [openDescription, setOpenDescription] = useState<any>(null)
37
39
  const handleOnLayout = (event: any, categoryId: any) => {
38
40
  const _categoriesLayout = { ...categoriesLayout }
39
41
  const categoryKey = 'cat_' + categoryId
@@ -84,8 +86,11 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
84
86
 
85
87
  {!category?.id && categories.filter(category => category?.id !== null).map((category, i, _categories) => {
86
88
  const products = !isUseParentCategory
87
- ? categoryState?.products?.filter((product : any) => product?.category_id === category?.id) ?? []
88
- : categoryState?.products?.filter((product : any) => category?.children?.some((cat : any) => cat.category_id === product?.category_id)) ?? []
89
+ ? categoryState?.products?.filter((product: any) => product?.category_id === category?.id) ?? []
90
+ : categoryState?.products?.filter((product: any) => category?.children?.some((cat: any) => cat.category_id === product?.category_id)) ?? []
91
+
92
+ const shortCategoryDescription = category?.description?.length > 80 ? `${category?.description?.substring(0, 80)}...` : category?.description
93
+
89
94
  return (
90
95
  <React.Fragment key={'cat_' + category.id}>
91
96
  {products.length > 0 && (
@@ -106,6 +111,28 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
106
111
  {category.name}
107
112
  </OText>
108
113
  </View>
114
+ {!!category?.description && (
115
+ <View style={{ position: 'relative' }}>
116
+ <OText size={12} weight={'500'} mBottom={5}>
117
+ {shortCategoryDescription}
118
+ {category?.description?.length > 80 && (
119
+ <OButton
120
+ style={{ height: 15, paddingRight: 0, paddingLeft: 0, borderWidth: 0 }}
121
+ text={t('SEE_MORE', 'See more')}
122
+ parentStyle={{ padding: 0 }}
123
+ onClick={() => setOpenDescription(category)}
124
+ bgColor='transparent'
125
+ textStyle={{
126
+ fontSize: 12,
127
+ borderBottomWidth: 1,
128
+ borderBottomColor: theme.colors.primary,
129
+ color: theme.colors.primary
130
+ }}
131
+ />
132
+ )}
133
+ </OText>
134
+ </View>
135
+ )}
109
136
  <>
110
137
  {products.sort((a: any, b: any) => a.rank - b.rank).map((product: any, i: any) => (
111
138
  <SingleProductCard
@@ -188,6 +215,23 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
188
215
  <OText>{e}</OText>
189
216
  </ErrorMessage>
190
217
  ))}
218
+ <OModal
219
+ open={!!openDescription}
220
+ title={openDescription?.name}
221
+ onClose={() => setOpenDescription(null)}
222
+ >
223
+ <View style={{ padding: 20 }}>
224
+ {!!openDescription?.image && (
225
+ <OIcon
226
+ url={optimizeImage(openDescription?.image, 'h_100,c_limit')}
227
+ width={240}
228
+ height={240}
229
+ style={{ borderRadius: 7.6 }}
230
+ />
231
+ )}
232
+ <OText>{openDescription?.description}</OText>
233
+ </View>
234
+ </OModal>
191
235
  </ProductsContainer>
192
236
  );
193
237
  };
@@ -219,7 +219,7 @@ const CartUI = (props: any) => {
219
219
  </OSTable>
220
220
  ))
221
221
  }
222
- <Divider />
222
+ {/* <Divider /> */}
223
223
  {cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
224
224
  <OSTable>
225
225
  <OText size={12} lineHeight={18} numberOfLines={1}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
@@ -252,7 +252,7 @@ const CartUI = (props: any) => {
252
252
  <OSRow>
253
253
  <OText size={12} lineHeight={18} numberOfLines={1}>
254
254
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
255
- ({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
255
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
256
256
  </OText>
257
257
  <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
258
258
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
@@ -895,7 +895,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
895
895
  <OSRow>
896
896
  <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
897
897
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
898
- ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
898
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
899
899
  </OText>
900
900
  <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })}>
901
901
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />