Commit 3f7c1838 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

navbar: add home menu;

cookie: define expire;
parent 95d9b776
...@@ -19,6 +19,7 @@ import Link from "next/link"; ...@@ -19,6 +19,7 @@ import Link from "next/link";
import { Favorite } from "@mui/icons-material"; import { Favorite } from "@mui/icons-material";
import { Logout, SupervisedUserCircle } from "@mui/icons-material"; import { Logout, SupervisedUserCircle } from "@mui/icons-material";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { Cottage } from "@mui/icons-material";
const Search = styled("div")(({ theme }) => ({ const Search = styled("div")(({ theme }) => ({
position: "relative", position: "relative",
...@@ -64,7 +65,7 @@ function Navbar(props) { ...@@ -64,7 +65,7 @@ function Navbar(props) {
const router = useRouter(); const router = useRouter();
const [search, setSearch] = React.useState(router.query?.q ?? ""); const [search, setSearch] = React.useState(router.query?.q ?? "");
const wishlist = useContext(WishlistContext); const wishlist = useContext(WishlistContext);
const cart = useContext(CartContext) const cart = useContext(CartContext);
const user = useContext(UserContext); const user = useContext(UserContext);
const { window } = props; const { window } = props;
...@@ -116,6 +117,21 @@ function Navbar(props) { ...@@ -116,6 +117,21 @@ function Navbar(props) {
const MenuList = user?.value?.name const MenuList = user?.value?.name
? [ ? [
{
label: "หน้าหลัก",
link: "/",
element: (
<IconButton
size="large"
aria-label="show 4 new mails"
color="inherit"
>
<Badge color="error">
<Cottage />
</Badge>
</IconButton>
),
},
{ {
label: "สินค้าที่ชอบ", label: "สินค้าที่ชอบ",
link: "/wishlist", link: "/wishlist",
......
...@@ -8,7 +8,7 @@ class userCookie { ...@@ -8,7 +8,7 @@ class userCookie {
return !!this.token; return !!this.token;
} }
store(token) { store(token) {
Cookies.set("token", token); Cookies.set("token", token, { expires: 1 });
} }
delete() { delete() {
Cookies.remove("token"); Cookies.remove("token");
......
...@@ -133,7 +133,7 @@ export default function Cart() { ...@@ -133,7 +133,7 @@ export default function Cart() {
</TableBody> </TableBody>
</Table> </Table>
) : ( ) : (
<div className="text-center">รายการว่างเปล่า</div> <div className="text-center">{user.value?.token ? "รายการว่างเปล่า": "คุณยังไม่ได้เข้าสู่ระบบ"}</div>
)} )}
</Paper> </Paper>
</Box> </Box>
......
...@@ -189,7 +189,7 @@ export default function Wishlist() { ...@@ -189,7 +189,7 @@ export default function Wishlist() {
</TableBody> </TableBody>
</Table> </Table>
) : ( ) : (
<div className="text-center">รายการว่างเปล่า</div> <div className="text-center">{user.value?.token ? "รายการว่างเปล่า": "คุณยังไม่ได้เข้าสู่ระบบ"}</div>
)} )}
</Paper> </Paper>
</Box> </Box>
......
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