Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
final-exam
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nawasan Wisitsingkhon
final-exam
Commits
3f7c1838
Commit
3f7c1838
authored
Oct 03, 2023
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
navbar: add home menu;
cookie: define expire;
parent
95d9b776
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
4 deletions
+20
-4
Navbar.js
src/components/Navbar.js
+17
-1
userCookie.js
src/components/lib/userCookie.js
+1
-1
cart.js
src/pages/cart.js
+1
-1
wishlist.js
src/pages/wishlist.js
+1
-1
No files found.
src/components/Navbar.js
View file @
3f7c1838
...
@@ -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"
,
...
...
src/components/lib/userCookie.js
View file @
3f7c1838
...
@@ -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"
);
...
...
src/pages/cart.js
View file @
3f7c1838
...
@@ -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
>
...
...
src/pages/wishlist.js
View file @
3f7c1838
...
@@ -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
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment