|
@@ -1,252 +1,277 @@
|
1
|
|
-import { useEffect, useState } from 'react';
|
2
|
|
-import { Box, Typography, Button, FormControl, Select, MenuItem, InputBase } from '@mui/material';
|
3
|
|
-import Grid from '@mui/material/Grid2';
|
|
1
|
+import { useEffect, useState } from "react";
|
|
2
|
+import {
|
|
3
|
+ Box,
|
|
4
|
+ Typography,
|
|
5
|
+ Button,
|
|
6
|
+ FormControl,
|
|
7
|
+ Select,
|
|
8
|
+ MenuItem,
|
|
9
|
+ InputBase,
|
|
10
|
+} from "@mui/material";
|
|
11
|
+import Grid from "@mui/material/Grid2";
|
4
|
12
|
import { styled } from "@mui/material";
|
5
|
13
|
//REDUX
|
6
|
|
-import { useSelector, useDispatch } from 'react-redux';
|
7
|
|
-import { fetchProducts } from '../../redux/slices/productSlice';
|
|
14
|
+import { useSelector, useDispatch } from "react-redux";
|
|
15
|
+import { fetchProducts } from "../../redux/slices/productSlice";
|
|
16
|
+import { useNavigate } from "react-router-dom";
|
8
|
17
|
|
9
|
18
|
//UTIL FUNCTION
|
10
|
19
|
function getAllTags(data) {
|
11
|
20
|
const products = data || [];
|
12
|
|
- const allTags = products.flatMap(product => product.tags);
|
|
21
|
+ const allTags = products.flatMap((product) => product.tags);
|
13
|
22
|
const uniqueTags = [...new Set(allTags)];
|
14
|
23
|
return uniqueTags;
|
15
|
24
|
}
|
16
|
25
|
|
17
|
26
|
function getAllCollection(data) {
|
18
|
27
|
const products = data || [];
|
19
|
|
- const allCollection = products.flatMap(product => product.collections);
|
|
28
|
+ const allCollection = products.flatMap((product) => product.collections);
|
20
|
29
|
const uniqueCollection = Array.from(
|
21
|
|
- new Map(allCollection.map(item => [item?.title, item])).values()
|
|
30
|
+ new Map(allCollection.map((item) => [item?.title, item])).values()
|
22
|
31
|
);
|
23
|
32
|
return uniqueCollection;
|
24
|
33
|
}
|
25
|
34
|
|
26
|
35
|
const BootstrapInput = styled(InputBase)(({ theme }) => ({
|
27
|
|
- 'label + &': {
|
|
36
|
+ "label + &": {
|
28
|
37
|
marginTop: theme.spacing(3),
|
29
|
38
|
},
|
30
|
|
- '& .MuiInputBase-input': {
|
31
|
|
- position: 'relative',
|
|
39
|
+ "& .MuiInputBase-input": {
|
|
40
|
+ position: "relative",
|
32
|
41
|
backgroundColor: "#2E2E2E",
|
33
|
|
- border: '1px solid #ced4da',
|
|
42
|
+ border: "1px solid #ced4da",
|
34
|
43
|
color: "#FFF",
|
35
|
44
|
fontSize: 13,
|
36
|
|
- padding: '5px 0',
|
37
|
|
- paddingRight: '50px !important',
|
|
45
|
+ padding: "5px 0",
|
|
46
|
+ paddingRight: "50px !important",
|
38
|
47
|
paddingLeft: "10px",
|
39
|
|
- transition: theme.transitions.create(['border-color', 'box-shadow']),
|
40
|
|
- '&:focus': {
|
|
48
|
+ transition: theme.transitions.create(["border-color", "box-shadow"]),
|
|
49
|
+ "&:focus": {
|
41
|
50
|
borderRadius: 4,
|
42
|
|
- borderColor: '#80bdff',
|
43
|
|
- boxShadow: '0 0 0 0.2rem rgba(0,123,255,.25)',
|
|
51
|
+ borderColor: "#80bdff",
|
|
52
|
+ boxShadow: "0 0 0 0.2rem rgba(0,123,255,.25)",
|
44
|
53
|
},
|
45
|
54
|
},
|
46
|
|
- '& .MuiSvgIcon-root': {
|
47
|
|
- color: "#FFF !important"
|
|
55
|
+ "& .MuiSvgIcon-root": {
|
|
56
|
+ color: "#FFF !important",
|
48
|
57
|
},
|
49
|
58
|
}));
|
50
|
59
|
|
51
|
60
|
const ProductList = ({ size = 99999 }) => {
|
52
|
|
-
|
53
|
|
- const products = useSelector((state) => state.products.products.data) // only used as referenced
|
54
|
|
- const [filteredProducts, setFilteredProducts] = useState([]) // this one is the actual data to be rendered
|
55
|
|
- const [tagFilterOption, setTagFilterOption] = useState([])
|
56
|
|
- const [collectionFilterOption, setCollectionFilterOption] = useState([])
|
|
61
|
+ const products = useSelector((state) => state.products.products.data); // only used as referenced
|
|
62
|
+ const [filteredProducts, setFilteredProducts] = useState([]); // this one is the actual data to be rendered
|
|
63
|
+ const [tagFilterOption, setTagFilterOption] = useState([]);
|
|
64
|
+ const [collectionFilterOption, setCollectionFilterOption] = useState([]);
|
57
|
65
|
const dispatch = useDispatch();
|
|
66
|
+ const navigate = useNavigate();
|
58
|
67
|
|
59
|
68
|
//filter
|
60
|
|
- const [tags, setTags] = useState('all');
|
61
|
|
- const [collection, setCollection] = useState('all');
|
62
|
|
- const [sort, setSort] = useState('new')
|
|
69
|
+ const [tags, setTags] = useState("all");
|
|
70
|
+ const [collection, setCollection] = useState("all");
|
|
71
|
+ const [sort, setSort] = useState("new");
|
63
|
72
|
|
64
|
73
|
useEffect(() => {
|
65
|
|
-
|
66
|
|
- dispatch(fetchProducts())
|
67
|
|
-
|
68
|
|
- }, [])
|
69
|
|
-
|
|
74
|
+ dispatch(fetchProducts());
|
|
75
|
+ }, []);
|
70
|
76
|
|
71
|
77
|
useEffect(() => {
|
72
|
|
-
|
73
|
|
- console.log("Products: ", products)
|
|
78
|
+ console.log("Products: ", products);
|
74
|
79
|
|
75
|
80
|
if (products.length > 0) {
|
76
|
|
-
|
77
|
|
- let newFilteredProducts = filterProducts()
|
78
|
|
- setFilteredProducts([])
|
|
81
|
+ let newFilteredProducts = filterProducts();
|
|
82
|
+ setFilteredProducts([]);
|
79
|
83
|
setTimeout(() => {
|
80
|
|
- setFilteredProducts(newFilteredProducts)
|
|
84
|
+ setFilteredProducts(newFilteredProducts);
|
81
|
85
|
}, 100);
|
82
|
86
|
|
83
|
87
|
const tagList = getAllTags(newFilteredProducts);
|
84
|
88
|
setTagFilterOption(tagList);
|
85
|
89
|
|
86
|
|
-
|
87
|
90
|
// Filter will only exist if the user haven't click on collection
|
88
|
|
- if (!sessionStorage.getItem('amber-select-collection')) {
|
|
91
|
+ if (!sessionStorage.getItem("amber-select-collection")) {
|
89
|
92
|
const collectionList = getAllCollection(newFilteredProducts);
|
90
|
93
|
setCollectionFilterOption(collectionList);
|
91
|
94
|
} else {
|
92
|
|
- const selectedColletion = JSON.parse(sessionStorage.getItem('amber-select-collection'))
|
93
|
|
- setCollection(selectedColletion?.title)
|
|
95
|
+ const selectedColletion = JSON.parse(
|
|
96
|
+ sessionStorage.getItem("amber-select-collection")
|
|
97
|
+ );
|
|
98
|
+ setCollection(selectedColletion?.title);
|
94
|
99
|
}
|
95
|
|
-
|
96
|
100
|
}
|
97
|
|
-
|
98
|
|
-
|
99
|
|
- }, [products])
|
100
|
|
-
|
|
101
|
+ }, [products]);
|
101
|
102
|
|
102
|
103
|
useEffect(() => {
|
103
|
|
-
|
104
|
|
- let newFilteredProducts = filterProducts()
|
105
|
|
- setFilteredProducts([])
|
|
104
|
+ let newFilteredProducts = filterProducts();
|
|
105
|
+ setFilteredProducts([]);
|
106
|
106
|
setTimeout(() => {
|
107
|
|
- setFilteredProducts(newFilteredProducts)
|
|
107
|
+ setFilteredProducts(newFilteredProducts);
|
108
|
108
|
}, 100);
|
109
|
|
-
|
110
|
|
-
|
111
|
|
- }, [tags, collection, sort])
|
|
109
|
+ }, [tags, collection, sort]);
|
112
|
110
|
|
113
|
111
|
const filterProducts = () => {
|
114
|
|
-
|
115
|
112
|
if (products?.length > 0) {
|
116
|
|
-
|
117
|
|
- let productType = sessionStorage.getItem('amber-select-product-type')
|
|
113
|
+ let productType = sessionStorage.getItem("amber-select-product-type");
|
118
|
114
|
|
119
|
115
|
let newFilteredProducts = products.filter(
|
120
|
116
|
(product) => product.productType === productType
|
121
|
117
|
);
|
122
|
118
|
|
123
|
119
|
// Tags
|
124
|
|
- newFilteredProducts = newFilteredProducts.filter(
|
125
|
|
- (product) => {
|
126
|
|
- if (tags == 'all') {
|
127
|
|
- return product.productType === productType
|
128
|
|
- } else {
|
129
|
|
- return product.productType === productType && product.tags.includes(tags)
|
130
|
|
- }
|
131
|
|
-
|
|
120
|
+ newFilteredProducts = newFilteredProducts.filter((product) => {
|
|
121
|
+ if (tags == "all") {
|
|
122
|
+ return product.productType === productType;
|
|
123
|
+ } else {
|
|
124
|
+ return (
|
|
125
|
+ product.productType === productType && product.tags.includes(tags)
|
|
126
|
+ );
|
132
|
127
|
}
|
133
|
|
- );
|
|
128
|
+ });
|
134
|
129
|
|
135
|
130
|
// Collection
|
136
|
|
- newFilteredProducts = newFilteredProducts.filter(
|
137
|
|
- (product) => {
|
138
|
|
-
|
139
|
|
- if (collection == 'all') {
|
140
|
|
- return product.productType === productType
|
141
|
|
- } else {
|
142
|
|
- return product.productType === productType && product.collections.some(data => data?.title === collection)
|
143
|
|
- }
|
144
|
|
-
|
|
131
|
+ newFilteredProducts = newFilteredProducts.filter((product) => {
|
|
132
|
+ if (collection == "all") {
|
|
133
|
+ return product.productType === productType;
|
|
134
|
+ } else {
|
|
135
|
+ return (
|
|
136
|
+ product.productType === productType &&
|
|
137
|
+ product.collections.some((data) => data?.title === collection)
|
|
138
|
+ );
|
145
|
139
|
}
|
146
|
|
- );
|
|
140
|
+ });
|
147
|
141
|
|
148
|
142
|
if (sort === "title") {
|
149
|
|
- newFilteredProducts = newFilteredProducts.sort((a, b) => a.title.localeCompare(b.title));
|
|
143
|
+ newFilteredProducts = newFilteredProducts.sort((a, b) =>
|
|
144
|
+ a.title.localeCompare(b.title)
|
|
145
|
+ );
|
150
|
146
|
} else if (sort === "new") {
|
151
|
|
- newFilteredProducts = newFilteredProducts.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt));
|
|
147
|
+ newFilteredProducts = newFilteredProducts.sort(
|
|
148
|
+ (a, b) => new Date(b.createdAt) - new Date(a.createdAt)
|
|
149
|
+ );
|
152
|
150
|
} else if (sort === "old") {
|
153
|
|
- newFilteredProducts = newFilteredProducts.sort((a, b) => new Date(a.createdAt) - new Date(b.createdAt));
|
|
151
|
+ newFilteredProducts = newFilteredProducts.sort(
|
|
152
|
+ (a, b) => new Date(a.createdAt) - new Date(b.createdAt)
|
|
153
|
+ );
|
154
|
154
|
}
|
155
|
155
|
|
156
|
|
- return newFilteredProducts
|
157
|
|
-
|
|
156
|
+ return newFilteredProducts;
|
158
|
157
|
}
|
159
|
158
|
|
160
|
|
- return []
|
161
|
|
-
|
162
|
|
- }
|
|
159
|
+ return [];
|
|
160
|
+ };
|
163
|
161
|
|
164
|
162
|
const handleChange = (event) => {
|
165
|
163
|
//setInput({ ...input, [event.target.name]: event.target.value });
|
166
|
164
|
};
|
167
|
165
|
|
168
|
|
- const renderProduct = (handle, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, extra_desc, selected = false) => {
|
169
|
|
-
|
|
166
|
+ const renderProduct = (
|
|
167
|
+ handle,
|
|
168
|
+ img_url,
|
|
169
|
+ title,
|
|
170
|
+ collection_name,
|
|
171
|
+ minPrice,
|
|
172
|
+ minPriceCurrency,
|
|
173
|
+ maxPrice,
|
|
174
|
+ maxPriceCurrency,
|
|
175
|
+ extra_desc,
|
|
176
|
+ selected = false
|
|
177
|
+ ) => {
|
170
|
178
|
return (
|
171
|
|
- <Grid className="animate__animated animate__fadeIn" item size={{ xs: 6, sm: 6, md: 3 }}>
|
172
|
|
-
|
173
|
|
- <a href={`/products/${handle}`} style={{ textDecoration: "none", color: "#000" }}>
|
174
|
|
- <Box
|
175
|
|
- sx={{
|
176
|
|
- overflow: 'hidden',
|
177
|
|
- position: 'relative',
|
178
|
|
- cursor: 'pointer'
|
|
179
|
+ <Grid
|
|
180
|
+ className="animate__animated animate__fadeIn"
|
|
181
|
+ item
|
|
182
|
+ size={{ xs: 6, sm: 6, md: 3 }}
|
|
183
|
+ >
|
|
184
|
+ <Box
|
|
185
|
+ sx={{
|
|
186
|
+ overflow: "hidden",
|
|
187
|
+ position: "relative",
|
|
188
|
+ cursor: "pointer",
|
|
189
|
+ }}
|
|
190
|
+ onClick={()=>{
|
|
191
|
+ navigate(`/products/${handle}`)
|
|
192
|
+ }}
|
|
193
|
+ >
|
|
194
|
+ <img
|
|
195
|
+ src={img_url}
|
|
196
|
+ alt={title}
|
|
197
|
+ style={{
|
|
198
|
+ width: "100%",
|
|
199
|
+ aspectRatio: "3 / 4",
|
|
200
|
+ objectFit: "cover",
|
|
201
|
+ objectPosition: "top center",
|
179
|
202
|
}}
|
|
203
|
+ />
|
180
|
204
|
|
181
|
|
- >
|
182
|
|
- <img
|
183
|
|
- src={img_url}
|
184
|
|
- alt={title}
|
185
|
|
- style={{
|
186
|
|
- width: '100%',
|
187
|
|
- aspectRatio: '3 / 4',
|
188
|
|
- objectFit: 'cover',
|
189
|
|
- objectPosition: 'top center'
|
190
|
|
- }}
|
191
|
|
- />
|
192
|
|
-
|
193
|
|
- {(selected) && <Button
|
|
205
|
+ {selected && (
|
|
206
|
+ <Button
|
194
|
207
|
sx={{
|
195
|
208
|
position: "absolute",
|
196
|
209
|
top: {
|
197
|
210
|
xs: 0,
|
198
|
211
|
sm: 0,
|
199
|
212
|
md: 10,
|
200
|
|
- lg: 20
|
|
213
|
+ lg: 20,
|
201
|
214
|
},
|
202
|
215
|
left: {
|
203
|
216
|
xs: 0,
|
204
|
217
|
sm: 0,
|
205
|
218
|
md: 10,
|
206
|
|
- lg: 20
|
|
219
|
+ lg: 20,
|
207
|
220
|
},
|
208
|
221
|
boxShadow: 0,
|
209
|
|
- fontSize: 10
|
|
222
|
+ fontSize: 10,
|
210
|
223
|
}}
|
211
|
|
- variant="contained">
|
|
224
|
+ variant="contained"
|
|
225
|
+ >
|
212
|
226
|
NEW
|
213
|
|
- </Button>}
|
|
227
|
+ </Button>
|
|
228
|
+ )}
|
214
|
229
|
|
215
|
|
- <Box sx={{ pb: 3, pt: 1, width: "90%" }}>
|
216
|
|
- <Typography variant="body2" sx={{
|
217
|
|
- fontWeight: "100", fontSize: {
|
|
230
|
+ <Box sx={{ pb: 3, pt: 1, width: "90%" }}>
|
|
231
|
+ <Typography
|
|
232
|
+ variant="body2"
|
|
233
|
+ sx={{
|
|
234
|
+ fontWeight: "100",
|
|
235
|
+ fontSize: {
|
218
|
236
|
xs: "0.875rem",
|
219
|
237
|
sm: "0.875rem",
|
220
|
238
|
md: "1.1rem",
|
221
|
|
- }
|
222
|
|
- }}>
|
223
|
|
- {collection_name}
|
224
|
|
- </Typography>
|
225
|
|
- <Typography variant="body2" sx={{
|
226
|
|
- fontWeight: "400", fontSize: {
|
|
239
|
+ },
|
|
240
|
+ }}
|
|
241
|
+ >
|
|
242
|
+ {collection_name}
|
|
243
|
+ </Typography>
|
|
244
|
+ <Typography
|
|
245
|
+ variant="body2"
|
|
246
|
+ sx={{
|
|
247
|
+ fontWeight: "400",
|
|
248
|
+ fontSize: {
|
227
|
249
|
xs: "0.875rem",
|
228
|
250
|
sm: "0.875rem",
|
229
|
251
|
md: "1.1rem",
|
230
|
|
- }
|
231
|
|
- }}>
|
232
|
|
- {title}
|
233
|
|
- </Typography>
|
234
|
|
- <Typography variant="body2" sx={{
|
235
|
|
- fontWeight: "100", fontSize: {
|
|
252
|
+ },
|
|
253
|
+ }}
|
|
254
|
+ >
|
|
255
|
+ {title}
|
|
256
|
+ </Typography>
|
|
257
|
+ <Typography
|
|
258
|
+ variant="body2"
|
|
259
|
+ sx={{
|
|
260
|
+ fontWeight: "100",
|
|
261
|
+ fontSize: {
|
236
|
262
|
xs: "0.875rem",
|
237
|
263
|
sm: "0.875rem",
|
238
|
264
|
md: "1.1rem",
|
239
|
|
- }
|
240
|
|
- }}>
|
241
|
|
- {`${minPriceCurrency} ${parseFloat(minPrice).toFixed(2)}`}
|
242
|
|
- </Typography>
|
243
|
|
- </Box>
|
|
265
|
+ },
|
|
266
|
+ }}
|
|
267
|
+ >
|
|
268
|
+ {`${minPriceCurrency} ${parseFloat(minPrice).toFixed(2)}`}
|
|
269
|
+ </Typography>
|
244
|
270
|
</Box>
|
245
|
|
- </a>
|
|
271
|
+ </Box>
|
246
|
272
|
</Grid>
|
247
|
|
- )
|
248
|
|
-
|
249
|
|
- }
|
|
273
|
+ );
|
|
274
|
+ };
|
250
|
275
|
|
251
|
276
|
return (
|
252
|
277
|
<>
|
|
@@ -260,90 +285,127 @@ const ProductList = ({ size = 99999 }) => {
|
260
|
285
|
xs: "column",
|
261
|
286
|
sm: "row",
|
262
|
287
|
md: "row",
|
263
|
|
- lg: "row"
|
|
288
|
+ lg: "row",
|
264
|
289
|
},
|
265
|
290
|
alignItems: "center",
|
266
|
291
|
backgroundColor: "background.black",
|
267
|
292
|
color: "white",
|
268
|
293
|
px: 2, // Add padding around the box
|
269
|
|
- my: 4
|
|
294
|
+ my: 4,
|
270
|
295
|
}}
|
271
|
296
|
>
|
272
|
297
|
{/* Left Side: Page Title */}
|
273
|
|
- <Typography variant="body2" sx={{ fontSize: 10, mt: { xs: 1, sm: 1, md: 0 } }}>
|
|
298
|
+ <Typography
|
|
299
|
+ variant="body2"
|
|
300
|
+ sx={{ fontSize: 10, mt: { xs: 1, sm: 1, md: 0 } }}
|
|
301
|
+ >
|
274
|
302
|
{`${filteredProducts.length} Item`}
|
275
|
303
|
</Typography>
|
276
|
304
|
|
277
|
305
|
{/* Right Side: Option Inputs */}
|
278
|
|
- <Box sx={{
|
279
|
|
- display: "flex", gap: 2, flexDirection: "row", flexWrap: "wrap", justifyContent: "space-between", py: {
|
280
|
|
- xs: 2,
|
281
|
|
- sm: 2,
|
282
|
|
- md: 0
|
283
|
|
- }
|
284
|
|
- }}>
|
285
|
|
-
|
286
|
|
- {(tagFilterOption.length > 0) && <FormControl sx={{ m: 1, display: "flex", flexDirection: "row" }} variant="standard">
|
287
|
|
- <Typography variant="body2" sx={{ mr: 1, my: "auto" }}>Tag</Typography>
|
288
|
|
- <Select
|
289
|
|
- value={tags}
|
290
|
|
- onChange={(event) => {
|
291
|
|
- setTags(event.target.value);
|
292
|
|
- }}
|
293
|
|
- sx={{
|
294
|
|
- '& .MuiSelect-select': {
|
295
|
|
- border: "none"
|
296
|
|
- }
|
297
|
|
- }}
|
298
|
|
- input={<BootstrapInput />}
|
299
|
|
- name="type"
|
|
306
|
+ <Box
|
|
307
|
+ sx={{
|
|
308
|
+ display: "flex",
|
|
309
|
+ gap: 2,
|
|
310
|
+ flexDirection: "row",
|
|
311
|
+ flexWrap: "wrap",
|
|
312
|
+ justifyContent: "space-between",
|
|
313
|
+ py: {
|
|
314
|
+ xs: 2,
|
|
315
|
+ sm: 2,
|
|
316
|
+ md: 0,
|
|
317
|
+ },
|
|
318
|
+ }}
|
|
319
|
+ >
|
|
320
|
+ {tagFilterOption.length > 0 && (
|
|
321
|
+ <FormControl
|
|
322
|
+ sx={{ m: 1, display: "flex", flexDirection: "row" }}
|
|
323
|
+ variant="standard"
|
300
|
324
|
>
|
301
|
|
- <MenuItem value={'all'}>All</MenuItem>
|
302
|
|
- {tagFilterOption?.map((data) => (<MenuItem value={data}>{data}</MenuItem>))}
|
303
|
|
- </Select>
|
304
|
|
- </FormControl>}
|
305
|
|
-
|
306
|
|
- {(collectionFilterOption.length > 0) && <FormControl sx={{ m: 1, display: "flex", flexDirection: "row" }} variant="standard">
|
307
|
|
- <Typography variant="body2" sx={{ mr: 1, my: "auto" }}>Collection</Typography>
|
308
|
|
- <Select
|
309
|
|
- value={collection}
|
310
|
|
- onChange={(event) => {
|
311
|
|
- setCollection(event.target.value);
|
312
|
|
- }}
|
313
|
|
- sx={{
|
314
|
|
- '& .MuiSelect-select': {
|
315
|
|
- border: "none"
|
316
|
|
- }
|
317
|
|
- }}
|
318
|
|
- input={<BootstrapInput />}
|
319
|
|
- name="type"
|
|
325
|
+ <Typography variant="body2" sx={{ mr: 1, my: "auto" }}>
|
|
326
|
+ Tag
|
|
327
|
+ </Typography>
|
|
328
|
+ <Select
|
|
329
|
+ value={tags}
|
|
330
|
+ onChange={(event) => {
|
|
331
|
+ setTags(event.target.value);
|
|
332
|
+ }}
|
|
333
|
+ sx={{
|
|
334
|
+ "& .MuiSelect-select": {
|
|
335
|
+ border: "none",
|
|
336
|
+ },
|
|
337
|
+ }}
|
|
338
|
+ input={<BootstrapInput />}
|
|
339
|
+ name="type"
|
|
340
|
+ >
|
|
341
|
+ <MenuItem value={"all"}>All</MenuItem>
|
|
342
|
+ {tagFilterOption?.map((data) => (
|
|
343
|
+ <MenuItem value={data}>{data}</MenuItem>
|
|
344
|
+ ))}
|
|
345
|
+ </Select>
|
|
346
|
+ </FormControl>
|
|
347
|
+ )}
|
|
348
|
+
|
|
349
|
+ {collectionFilterOption.length > 0 && (
|
|
350
|
+ <FormControl
|
|
351
|
+ sx={{ m: 1, display: "flex", flexDirection: "row" }}
|
|
352
|
+ variant="standard"
|
320
|
353
|
>
|
321
|
|
- <MenuItem value={'all'}>All</MenuItem>
|
322
|
|
- {collectionFilterOption?.map(({ title }) => (<MenuItem value={title}>{title}</MenuItem>))}
|
323
|
|
- </Select>
|
324
|
|
- </FormControl>}
|
325
|
|
-
|
326
|
|
- <FormControl sx={{ m: 1, display: "flex", flexDirection: "row" }} variant="standard">
|
327
|
|
- <Typography variant="body2" sx={{ mr: 1, my: "auto" }}>Sort</Typography>
|
|
354
|
+ <Typography variant="body2" sx={{ mr: 1, my: "auto" }}>
|
|
355
|
+ Collection
|
|
356
|
+ </Typography>
|
|
357
|
+ <Select
|
|
358
|
+ value={collection}
|
|
359
|
+ onChange={(event) => {
|
|
360
|
+ setCollection(event.target.value);
|
|
361
|
+ }}
|
|
362
|
+ sx={{
|
|
363
|
+ "& .MuiSelect-select": {
|
|
364
|
+ border: "none",
|
|
365
|
+ },
|
|
366
|
+ }}
|
|
367
|
+ input={<BootstrapInput />}
|
|
368
|
+ name="type"
|
|
369
|
+ >
|
|
370
|
+ <MenuItem value={"all"}>All</MenuItem>
|
|
371
|
+ {collectionFilterOption?.map(({ title }) => (
|
|
372
|
+ <MenuItem value={title}>{title}</MenuItem>
|
|
373
|
+ ))}
|
|
374
|
+ </Select>
|
|
375
|
+ </FormControl>
|
|
376
|
+ )}
|
|
377
|
+
|
|
378
|
+ <FormControl
|
|
379
|
+ sx={{ m: 1, display: "flex", flexDirection: "row" }}
|
|
380
|
+ variant="standard"
|
|
381
|
+ >
|
|
382
|
+ <Typography variant="body2" sx={{ mr: 1, my: "auto" }}>
|
|
383
|
+ Sort
|
|
384
|
+ </Typography>
|
328
|
385
|
<Select
|
329
|
386
|
value={sort}
|
330
|
387
|
onChange={(event) => {
|
331
|
388
|
setSort(event.target.value);
|
332
|
389
|
}}
|
333
|
390
|
sx={{
|
334
|
|
- '& .MuiSelect-select': {
|
335
|
|
- border: "none"
|
336
|
|
- }
|
|
391
|
+ "& .MuiSelect-select": {
|
|
392
|
+ border: "none",
|
|
393
|
+ },
|
337
|
394
|
}}
|
338
|
395
|
input={<BootstrapInput />}
|
339
|
396
|
name="sort"
|
340
|
397
|
>
|
341
|
|
- <MenuItem defaultValue value={'title'}>Title</MenuItem>
|
342
|
|
- <MenuItem defaultValue value={'new'}>Newest</MenuItem>
|
343
|
|
- <MenuItem defaultValue value={'old'}>Oldest</MenuItem>
|
|
398
|
+ <MenuItem defaultValue value={"title"}>
|
|
399
|
+ Title
|
|
400
|
+ </MenuItem>
|
|
401
|
+ <MenuItem defaultValue value={"new"}>
|
|
402
|
+ Newest
|
|
403
|
+ </MenuItem>
|
|
404
|
+ <MenuItem defaultValue value={"old"}>
|
|
405
|
+ Oldest
|
|
406
|
+ </MenuItem>
|
344
|
407
|
</Select>
|
345
|
408
|
</FormControl>
|
346
|
|
-
|
347
|
409
|
</Box>
|
348
|
410
|
</Box>
|
349
|
411
|
|
|
@@ -351,20 +413,39 @@ const ProductList = ({ size = 99999 }) => {
|
351
|
413
|
<Box sx={{ mb: 5 }}>
|
352
|
414
|
<Grid container spacing={0.5} columns={12}>
|
353
|
415
|
{filteredProducts.map((product, index) => {
|
354
|
|
-
|
355
|
|
- let { handle, title, images, collections, minVariantPrice, maxVariantPrice, productType, variants, selected } = product
|
356
|
|
-
|
357
|
|
- let minPrice = minVariantPrice.amount
|
358
|
|
- let minPriceCurrency = minVariantPrice.currencyCode
|
359
|
|
- let maxPrice = maxVariantPrice.amount
|
360
|
|
- let maxPriceCurrency = maxVariantPrice.currencyCode
|
361
|
|
- let img_url = images[0]?.url
|
362
|
|
- let collection_name = collections[0]?.title
|
|
416
|
+ let {
|
|
417
|
+ handle,
|
|
418
|
+ title,
|
|
419
|
+ images,
|
|
420
|
+ collections,
|
|
421
|
+ minVariantPrice,
|
|
422
|
+ maxVariantPrice,
|
|
423
|
+ productType,
|
|
424
|
+ variants,
|
|
425
|
+ selected,
|
|
426
|
+ } = product;
|
|
427
|
+
|
|
428
|
+ let minPrice = minVariantPrice.amount;
|
|
429
|
+ let minPriceCurrency = minVariantPrice.currencyCode;
|
|
430
|
+ let maxPrice = maxVariantPrice.amount;
|
|
431
|
+ let maxPriceCurrency = maxVariantPrice.currencyCode;
|
|
432
|
+ let img_url = images[0]?.url;
|
|
433
|
+ let collection_name = collections[0]?.title;
|
363
|
434
|
|
364
|
435
|
if (index < size) {
|
365
|
|
- return renderProduct(handle, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, "", selected)
|
|
436
|
+ return renderProduct(
|
|
437
|
+ handle,
|
|
438
|
+ img_url,
|
|
439
|
+ title,
|
|
440
|
+ collection_name,
|
|
441
|
+ minPrice,
|
|
442
|
+ minPriceCurrency,
|
|
443
|
+ maxPrice,
|
|
444
|
+ maxPriceCurrency,
|
|
445
|
+ "",
|
|
446
|
+ selected
|
|
447
|
+ );
|
366
|
448
|
}
|
367
|
|
-
|
368
|
449
|
})}
|
369
|
450
|
</Grid>
|
370
|
451
|
</Box>
|