|
@@ -71,15 +71,11 @@ const ProductList = ({ size = 99999 }) => {
|
71
|
71
|
useEffect(() => {
|
72
|
72
|
|
73
|
73
|
console.log("Products: ", products)
|
|
74
|
+
|
74
|
75
|
if (products.length > 0) {
|
75
|
|
- let productType = sessionStorage.getItem('amber-select-product-type')
|
76
|
|
- let newFilteredProducts = products.filter(
|
77
|
|
- (product) => product.productType === productType
|
78
|
|
- );
|
79
|
76
|
|
80
|
|
- setTimeout(() => {
|
81
|
|
- setFilteredProducts(newFilteredProducts)
|
82
|
|
- }, 100)
|
|
77
|
+ let newFilteredProducts = filterProducts()
|
|
78
|
+ setFilteredProducts(newFilteredProducts)
|
83
|
79
|
|
84
|
80
|
const tagList = getAllTags(newFilteredProducts);
|
85
|
81
|
setTagFilterOption(tagList);
|
|
@@ -102,6 +98,14 @@ const ProductList = ({ size = 99999 }) => {
|
102
|
98
|
|
103
|
99
|
useEffect(() => {
|
104
|
100
|
|
|
101
|
+ let newFilteredProducts = filterProducts()
|
|
102
|
+ debugger
|
|
103
|
+ setFilteredProducts(newFilteredProducts)
|
|
104
|
+
|
|
105
|
+ }, [tags, collection, sort])
|
|
106
|
+
|
|
107
|
+ const filterProducts = () => {
|
|
108
|
+
|
105
|
109
|
if (products?.length > 0) {
|
106
|
110
|
|
107
|
111
|
let productType = sessionStorage.getItem('amber-select-product-type')
|
|
@@ -135,7 +139,6 @@ const ProductList = ({ size = 99999 }) => {
|
135
|
139
|
}
|
136
|
140
|
);
|
137
|
141
|
|
138
|
|
-
|
139
|
142
|
if (sort === "title") {
|
140
|
143
|
newFilteredProducts = newFilteredProducts.sort((a, b) => a.title.localeCompare(b.title));
|
141
|
144
|
} else if (sort === "new") {
|
|
@@ -144,15 +147,13 @@ const ProductList = ({ size = 99999 }) => {
|
144
|
147
|
newFilteredProducts = newFilteredProducts.sort((a, b) => new Date(a.createdAt) - new Date(b.createdAt));
|
145
|
148
|
}
|
146
|
149
|
|
147
|
|
-
|
148
|
|
- setFilteredProducts([]) //cause I want those fadeIn animation
|
149
|
|
- setTimeout(() => {
|
150
|
|
- setFilteredProducts(newFilteredProducts)
|
151
|
|
- }, 100)
|
|
150
|
+ return newFilteredProducts
|
152
|
151
|
|
153
|
152
|
}
|
154
|
153
|
|
155
|
|
- }, [tags, collection, sort])
|
|
154
|
+ return []
|
|
155
|
+
|
|
156
|
+ }
|
156
|
157
|
|
157
|
158
|
const handleChange = (event) => {
|
158
|
159
|
//setInput({ ...input, [event.target.name]: event.target.value });
|
|
@@ -200,7 +201,7 @@ const ProductList = ({ size = 99999 }) => {
|
200
|
201
|
},
|
201
|
202
|
boxShadow: 0,
|
202
|
203
|
fontSize: 10
|
203
|
|
- }}
|
|
204
|
+ }}
|
204
|
205
|
variant="contained">
|
205
|
206
|
NEW
|
206
|
207
|
</Button>}
|
|
@@ -269,10 +270,10 @@ const ProductList = ({ size = 99999 }) => {
|
269
|
270
|
|
270
|
271
|
{/* Right Side: Option Inputs */}
|
271
|
272
|
<Box sx={{
|
272
|
|
- display: "flex", gap: 2, flexDirection: "row", flexWrap:"wrap", justifyContent:"space-between", py:{
|
273
|
|
- xs:2,
|
274
|
|
- sm:2,
|
275
|
|
- md:0
|
|
273
|
+ display: "flex", gap: 2, flexDirection: "row", flexWrap: "wrap", justifyContent: "space-between", py: {
|
|
274
|
+ xs: 2,
|
|
275
|
+ sm: 2,
|
|
276
|
+ md: 0
|
276
|
277
|
}
|
277
|
278
|
}}>
|
278
|
279
|
|