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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
12 deletions
+32
-12
Navbar.js
src/components/Navbar.js
+13
-6
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) {
const
isMenuOpen
=
Boolean
(
anchorEl
);
const
isMobileMenuOpen
=
Boolean
(
mobileMoreAnchorEl
);
function
onUpdateSearch
(
value
)
{
router
.
push
({
pathname
:
location
.
pathname
,
query
:
{
...
router
.
query
,
q
:
value
},
});
}
React
.
useEffect
(()
=>
{
if
(
search
.
length
)
router
.
push
({
pathname
:
router
.
pathname
,
query
:
{
q
:
search
}
});
else
router
.
push
({
pathname
:
router
.
pathname
});
},
[
search
]);
setSearch
(
router
.
query
?.
q
??
""
);
},
[
router
]);
const
handleMobileMenuClose
=
()
=>
{
setMobileMoreAnchorEl
(
null
);
...
...
@@ -174,7 +179,7 @@ function Navbar(props) {
color
=
"inherit"
>
<
Badge
color
=
"error"
>
<
ShoppingBag
/>
<
ShoppingBag
/>
<
/Badge
>
<
/IconButton
>
),
...
...
@@ -295,7 +300,9 @@ function Navbar(props) {
<
StyledInputBase
placeholder
=
"Search…"
inputProps
=
{{
"aria-label"
:
"search"
}}
onChange
=
{(
e
)
=>
setSearch
(
e
.
target
.
value
)}
onChange
=
{(
e
)
=>
{
return
onUpdateSearch
(
e
.
target
.
value
);
}}
/
>
<
/Search
>
<
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 }) {
value
=
{{
value
:
cart
,
set
:
setCart
,
fetch
:
fetchCart
}}
>
<
WishlistContext
.
Provider
value
=
{{
value
:
wishlist
,
set
:
setWishlist
}}
>
{
pathname
.
split
(
"/"
)[
1
]
===
"admin"
?
(
{
String
(
pathname
)
.
split
(
"/"
)[
1
]
===
"admin"
?
(
<>
{
user
.
rank
?
(
<
AdminLayout
>
...
...
src/pages/order.js
View file @
542188c7
...
...
@@ -9,21 +9,17 @@ import {
TableRow
,
}
from
"@mui/material"
;
import
React
,
{
useContext
,
useEffect
,
useState
}
from
"react"
;
import
{
CartContext
,
UserContext
,
WishlistContext
}
from
"./_app"
;
import
{
CartContext
,
UserContext
}
from
"./_app"
;
import
{
useRouter
}
from
"next/router"
;
import
axios
from
"axios"
;
import
PopupAlert
from
"@/components/PopupAlert"
;
import
Head
from
"next/head"
;
import
{
ShoppingBag
}
from
"@mui/icons-material"
;
import
ConfirmOrder
from
"@/components/order/ConfirmOrder"
;
export
default
function
Order
()
{
const
user
=
useContext
(
UserContext
);
const
cart
=
useContext
(
CartContext
);
const
[
products
,
setProducts
]
=
useState
([]);
const
[
message
,
setMessage
]
=
useState
({
error
:
false
,
message
:
""
});
const
[
orderState
,
setOrderState
]
=
useState
(
false
);
const
router
=
useRouter
();
const
[
orderList
,
setOrderList
]
=
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