Commit 7d243b62 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

change display selected category in home page

parent 7c06b404
...@@ -8,6 +8,7 @@ import { CartContext, UserContext, WishlistContext } from "./_app"; ...@@ -8,6 +8,7 @@ import { CartContext, UserContext, WishlistContext } from "./_app";
import PopupAlert from "@/components/PopupAlert"; import PopupAlert from "@/components/PopupAlert";
import { import {
Box, Box,
Button,
FormControl, FormControl,
FormLabel, FormLabel,
MenuItem, MenuItem,
...@@ -132,8 +133,8 @@ export default function Home() { ...@@ -132,8 +133,8 @@ export default function Home() {
/> />
<div> <div>
<Box className="flex justify-start mb-3 px-10 max-w-[1520px] mx-auto"> <Box className="flex justify-start mb-3 px-10 max-w-[1520px] mx-auto">
<Box className="flex items-center mx-3">หมวดหมู่</Box> {/* <Box className="flex items-center mx-3">หมวดหมู่</Box> */}
<FormControl> {/* <FormControl>
<Select <Select
variant="standard" variant="standard"
value={category} value={category}
...@@ -151,7 +152,36 @@ export default function Home() { ...@@ -151,7 +152,36 @@ export default function Home() {
</MenuItem> </MenuItem>
))} ))}
</Select> </Select>
</FormControl> </FormControl> */}
<Box sx={{ display: "flex", overflowX: "scroll", maxWidth: "100vw" }}>
<Button variant={category === -1 ? "contained": "text"} className={`${category === -1 ? "" : "bg-white"} mx-1`}>
ทั้งหมด
</Button>
{categoryList.map((cat, idx) => (
<Button
className={`${cat.id === category ? "" : "bg-white"} mx-1`}
variant={cat.id === category ? "contained" : "text"}
key={idx}
onClick={() => {
if (cat.id === category) {
let que = router.query;
delete que.cat;
router.push({
pathname: location.pathname,
query: { ...que },
});
} else {
router.push({
pathname: location.pathname,
query: { ...router.query, cat: cat.id },
});
}
}}
>
{cat.name}
</Button>
))}
</Box>
</Box> </Box>
{productsFilter.length ? ( {productsFilter.length ? (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment