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