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
7b33dfbd
Commit
7b33dfbd
authored
Oct 05, 2023
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change switch to button
parent
44bf1622
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
16 deletions
+12
-16
order.js
src/pages/order.js
+12
-16
No files found.
src/pages/order.js
View file @
7b33dfbd
...
...
@@ -3,7 +3,6 @@ import {
Button
,
Paper
,
Stack
,
Switch
,
Table
,
TableBody
,
TableCell
,
...
...
@@ -12,7 +11,7 @@ import {
Typography
,
}
from
"@mui/material"
;
import
React
,
{
useContext
,
useEffect
,
useState
}
from
"react"
;
import
{
CartContext
,
OrderContext
,
UserContext
}
from
"./_app"
;
import
{
OrderContext
,
UserContext
}
from
"./_app"
;
import
axios
from
"axios"
;
import
PopupAlert
from
"@/components/PopupAlert"
;
import
Head
from
"next/head"
;
...
...
@@ -22,13 +21,12 @@ import { useRouter } from "next/router";
export
default
function
Order
()
{
const
user
=
useContext
(
UserContext
);
const
cart
=
useContext
(
CartContext
);
const
[
products
,
setProducts
]
=
useState
([]);
const
[
message
,
setMessage
]
=
useState
({
error
:
false
,
message
:
""
});
const
order
=
useContext
(
OrderContext
);
const
[
payment
,
setPayment
]
=
useState
({
open
:
false
,
id
:
-
1
,
price
:
-
1
});
const
[
payFilter
,
setPayFilter
]
=
useState
(
false
);
const
router
=
useRouter
()
const
router
=
useRouter
()
;
const
fetchProduct
=
async
()
=>
{
try
{
...
...
@@ -64,21 +62,18 @@ export default function Order() {
message
=
{
message
.
message
}
/
>
<
Box
sx
=
{{
maxWidth
:
1200
,
mx
:
"auto"
}}
>
<
Box
>
<
Box
sx
=
{{
pb
:
2
}}
>
<
Stack
direction
=
{
"row"
}
alignItems
=
{
"center"
}
justifyContent
=
{
"end"
}
>
<
Typography
>
ทั้งหมด
<
/Typography
>
<
Switch
checked
=
{
payFilter
}
onChange
=
{(
e
)
=>
{
console
.
log
(
e
.
target
.
checked
);
setPayFilter
(
e
.
target
.
checked
);
}}
/
>
<
Typography
>
ยังไม่ชำระเงิน
<
/Typography
>
<
Button
onClick
=
{()
=>
setPayFilter
(
!
payFilter
)}
variant
=
{
payFilter
?
"contained"
:
"text"
}
>
ดูรายกายที่ยังไม่ชำระเงิน
<
/Button
>
<
/Stack
>
<
/Box
>
<
Paper
sx
=
{{
p
:
1
,
overflowX
:
"scroll"
}}
>
...
...
@@ -104,7 +99,8 @@ export default function Order() {
{
order
.
value
.
map
(
(
order
,
idx
)
=>
order
&&
(
!
router
.
query
?.
q
||
Number
(
router
.
query
.
q
)
===
order
.
id
)
&&
(
!
router
.
query
?.
q
||
Number
(
router
.
query
.
q
)
===
order
.
id
)
&&
(
!
payFilter
||
order
.
pay_status
===
0
)
&&
(
<
TableRow
key
=
{
idx
}
>
<
TableCell
>
{
order
.
id
}
<
/TableCell
>
...
...
@@ -119,7 +115,7 @@ export default function Order() {
<
/Link
>
<
/TableCell
>
<
TableCell
>
{
order
.
product_count
}
<
/TableCell
>
<
TableCell
>
{
order
.
shipping_price
}
<
/TableCell
>
<
TableCell
>
$
{
order
.
shipping_price
}
<
/TableCell
>
<
TableCell
>
<
Box
color
=
{
order
.
pay_status
?
"green"
:
"red"
}
>
{
order
.
pay_status
?
(
...
...
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