ordering-ui-react-native 0.23.27 → 0.23.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
package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx
CHANGED
|
@@ -1,87 +1,90 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { useTheme } from 'styled-components/native'
|
|
3
2
|
import { StyleSheet } from 'react-native'
|
|
4
|
-
import { SubCategoriesContainer, ContainerButton } from './styles'
|
|
5
|
-
import { OButton } from '../../shared'
|
|
6
3
|
import { useLanguage } from 'ordering-components/native'
|
|
4
|
+
import FIcon from 'react-native-vector-icons/Feather'
|
|
5
|
+
import { SubCategoriesContainer, ContainerButton } from './styles'
|
|
6
|
+
import { OButton, OText } from '../../shared'
|
|
7
7
|
|
|
8
8
|
function SubcategoriesComponentPropsAreEqual(prev: any, next: any) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
return prev.subcategoriesSelected === next.subcategoriesSelected &&
|
|
10
|
+
prev.category === next.category
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
interface SubcategoriesComponentParams {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
subcategoriesSelected?: any,
|
|
15
|
+
category?: any,
|
|
16
|
+
onClickSubcategory: any
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
const SubcategoriesComponent = (props: SubcategoriesComponentParams) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const {
|
|
21
|
+
subcategoriesSelected,
|
|
22
|
+
category,
|
|
23
|
+
onClickSubcategory
|
|
24
|
+
} = props
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const allsubcategorySelected = !subcategoriesSelected?.some((subcategory: any) => category?.id === subcategory?.parent_category_id)
|
|
26
|
+
const [, t] = useLanguage()
|
|
27
|
+
const allsubcategorySelected = !subcategoriesSelected?.some((subcategory: any) => category?.id === subcategory?.parent_category_id)
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
marginLeft: 5,
|
|
43
|
-
marginRight: 5,
|
|
44
|
-
marginBottom: 10,
|
|
45
|
-
height: 35,
|
|
46
|
-
paddingLeft: 3,
|
|
47
|
-
paddingRight: 3,
|
|
48
|
-
}
|
|
49
|
-
});
|
|
29
|
+
const bpStyles = StyleSheet.create({
|
|
30
|
+
categoryButtonStyle: {
|
|
31
|
+
borderWidth: 0,
|
|
32
|
+
marginRight: 5,
|
|
33
|
+
borderRadius: 8,
|
|
34
|
+
marginBottom: 5,
|
|
35
|
+
height: 35,
|
|
36
|
+
padding: 0,
|
|
37
|
+
paddingLeft: 3,
|
|
38
|
+
paddingRight: 3,
|
|
39
|
+
}
|
|
40
|
+
});
|
|
50
41
|
|
|
51
42
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
43
|
+
return (
|
|
44
|
+
<SubCategoriesContainer>
|
|
45
|
+
<ContainerButton
|
|
46
|
+
isSelected={allsubcategorySelected}
|
|
47
|
+
>
|
|
48
|
+
<OButton
|
|
49
|
+
onClick={() => onClickSubcategory(null, category)}
|
|
50
|
+
text={
|
|
51
|
+
allsubcategorySelected
|
|
52
|
+
? <OText color='#FFF'>
|
|
53
|
+
{t('ALL', 'All')}{' '}
|
|
54
|
+
<FIcon name='x-circle' size={16} />
|
|
55
|
+
</OText>
|
|
56
|
+
: t('ALL', 'All')
|
|
57
|
+
}
|
|
58
|
+
style={bpStyles.categoryButtonStyle}
|
|
59
|
+
textStyle={{ fontSize: 12 }}
|
|
60
|
+
/>
|
|
61
|
+
</ContainerButton>
|
|
62
|
+
{category?.subcategories?.map((subcategory: any) => {
|
|
63
|
+
const isSubcategorySelected = subcategoriesSelected?.find((_subcategory: any) => _subcategory?.id === subcategory?.id)
|
|
64
|
+
return (
|
|
65
|
+
<ContainerButton
|
|
66
|
+
key={subcategory?.id}
|
|
67
|
+
isSelected={isSubcategorySelected}
|
|
68
|
+
>
|
|
69
|
+
<OButton
|
|
70
|
+
onClick={() => onClickSubcategory(subcategory, category)}
|
|
71
|
+
text={
|
|
72
|
+
isSubcategorySelected
|
|
73
|
+
? <OText color='#FFF'>
|
|
74
|
+
{subcategory?.name}{' '}
|
|
75
|
+
<FIcon name='x-circle' size={16} />
|
|
76
|
+
</OText>
|
|
77
|
+
: subcategory?.name
|
|
78
|
+
}
|
|
79
|
+
style={bpStyles.categoryButtonStyle}
|
|
80
|
+
textStyle={{ fontSize: 12 }}
|
|
81
|
+
/>
|
|
82
|
+
</ContainerButton>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
)}
|
|
86
|
+
</SubCategoriesContainer>
|
|
87
|
+
)
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
export const SubcategoriesComponentMemoized = React.memo(SubcategoriesComponent, SubcategoriesComponentPropsAreEqual)
|
|
@@ -65,11 +65,10 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
65
65
|
return
|
|
66
66
|
}
|
|
67
67
|
const categoryFounded = subcategoriesSelected.find((_subcategory: any) => subCategory?.id === _subcategory?.id)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
68
|
+
setSubcategoriesSelected?.(categoryFounded
|
|
69
|
+
? subcategoriesSelected.filter((_subcategory: any) => subCategory?.id !== _subcategory?.id)
|
|
70
|
+
: [...subcategoriesSelected, subCategory]
|
|
71
|
+
)
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
return (
|