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
542188c7
Commit
542188c7
authored
Oct 03, 2023
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix search on navbar
parent
74b7f294
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
11 deletions
+31
-11
Navbar.js
src/components/Navbar.js
+12
-5
OrderDetailPage.js
src/components/OrderDetailPage.js
+9
-0
_app.js
src/pages/_app.js
+1
-1
order.js
src/pages/order.js
+1
-5
[id].js
src/pages/order/[id].js
+8
-0
No files found.
src/components/Navbar.js
View file @
542188c7
...
@@ -76,11 +76,16 @@ function Navbar(props) {
...
@@ -76,11 +76,16 @@ function Navbar(props) {
const
isMenuOpen
=
Boolean
(
anchorEl
);
const
isMenuOpen
=
Boolean
(
anchorEl
);
const
isMobileMenuOpen
=
Boolean
(
mobileMoreAnchorEl
);
const
isMobileMenuOpen
=
Boolean
(
mobileMoreAnchorEl
);
function
onUpdateSearch
(
value
)
{
router
.
push
({
pathname
:
location
.
pathname
,
query
:
{
...
router
.
query
,
q
:
value
},
});
}
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
search
.
length
)
setSearch
(
router
.
query
?.
q
??
""
);
router
.
push
({
pathname
:
router
.
pathname
,
query
:
{
q
:
search
}
});
},
[
router
]);
else
router
.
push
({
pathname
:
router
.
pathname
});
},
[
search
]);
const
handleMobileMenuClose
=
()
=>
{
const
handleMobileMenuClose
=
()
=>
{
setMobileMoreAnchorEl
(
null
);
setMobileMoreAnchorEl
(
null
);
...
@@ -295,7 +300,9 @@ function Navbar(props) {
...
@@ -295,7 +300,9 @@ function Navbar(props) {
<
StyledInputBase
<
StyledInputBase
placeholder
=
"Search…"
placeholder
=
"Search…"
inputProps
=
{{
"aria-label"
:
"search"
}}
inputProps
=
{{
"aria-label"
:
"search"
}}
onChange
=
{(
e
)
=>
setSearch
(
e
.
target
.
value
)}
onChange
=
{(
e
)
=>
{
return
onUpdateSearch
(
e
.
target
.
value
);
}}
/
>
/
>
<
/Search
>
<
/Search
>
<
Box
sx
=
{{
flexGrow
:
1
}}
/
>
<
Box
sx
=
{{
flexGrow
:
1
}}
/
>
...
...
src/components/OrderDetailPage.js
0 → 100644
View file @
542188c7
import
React
from
'react'
export
default
function
OrderDetailPage
()
{
return
(
<
div
>
OrderDetailPage
<
/div
>
)
}
\ No newline at end of file
src/pages/_app.js
View file @
542188c7
...
@@ -61,7 +61,7 @@ export default function App({ Component, pageProps }) {
...
@@ -61,7 +61,7 @@ export default function App({ Component, pageProps }) {
value
=
{{
value
:
cart
,
set
:
setCart
,
fetch
:
fetchCart
}}
value
=
{{
value
:
cart
,
set
:
setCart
,
fetch
:
fetchCart
}}
>
>
<
WishlistContext
.
Provider
value
=
{{
value
:
wishlist
,
set
:
setWishlist
}}
>
<
WishlistContext
.
Provider
value
=
{{
value
:
wishlist
,
set
:
setWishlist
}}
>
{
pathname
.
split
(
"/"
)[
1
]
===
"admin"
?
(
{
String
(
pathname
)
.
split
(
"/"
)[
1
]
===
"admin"
?
(
<>
<>
{
user
.
rank
?
(
{
user
.
rank
?
(
<
AdminLayout
>
<
AdminLayout
>
...
...
src/pages/order.js
View file @
542188c7
...
@@ -9,21 +9,17 @@ import {
...
@@ -9,21 +9,17 @@ import {
TableRow
,
TableRow
,
}
from
"@mui/material"
;
}
from
"@mui/material"
;
import
React
,
{
useContext
,
useEffect
,
useState
}
from
"react"
;
import
React
,
{
useContext
,
useEffect
,
useState
}
from
"react"
;
import
{
CartContext
,
UserContext
,
WishlistContext
}
from
"./_app"
;
import
{
CartContext
,
UserContext
}
from
"./_app"
;
import
{
useRouter
}
from
"next/router"
;
import
{
useRouter
}
from
"next/router"
;
import
axios
from
"axios"
;
import
axios
from
"axios"
;
import
PopupAlert
from
"@/components/PopupAlert"
;
import
PopupAlert
from
"@/components/PopupAlert"
;
import
Head
from
"next/head"
;
import
Head
from
"next/head"
;
import
{
ShoppingBag
}
from
"@mui/icons-material"
;
import
ConfirmOrder
from
"@/components/order/ConfirmOrder"
;
export
default
function
Order
()
{
export
default
function
Order
()
{
const
user
=
useContext
(
UserContext
);
const
user
=
useContext
(
UserContext
);
const
cart
=
useContext
(
CartContext
);
const
cart
=
useContext
(
CartContext
);
const
[
products
,
setProducts
]
=
useState
([]);
const
[
products
,
setProducts
]
=
useState
([]);
const
[
message
,
setMessage
]
=
useState
({
error
:
false
,
message
:
""
});
const
[
message
,
setMessage
]
=
useState
({
error
:
false
,
message
:
""
});
const
[
orderState
,
setOrderState
]
=
useState
(
false
);
const
router
=
useRouter
();
const
[
orderList
,
setOrderList
]
=
useState
([]);
const
[
orderList
,
setOrderList
]
=
useState
([]);
const
[
CartProduct
,
setCartProduct
]
=
useState
([]);
const
[
CartProduct
,
setCartProduct
]
=
useState
([]);
...
...
src/pages/order/[id].js
0 → 100644
View file @
542188c7
import
{
useRouter
}
from
"next/router"
;
import
React
from
"react"
;
export
default
function
OrderDetail
()
{
const
router
=
useRouter
();
console
.
log
(
router
.
query
);
return
<
div
>
OrderDetail
<
/div>
;
}
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