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
5f1c16ca
Commit
5f1c16ca
authored
Oct 05, 2023
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter at order admin
parent
7b33dfbd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
111 additions
and
92 deletions
+111
-92
order.js
src/pages/admin/order.js
+111
-92
No files found.
src/pages/admin/order.js
View file @
5f1c16ca
...
...
@@ -16,13 +16,17 @@ import {
FormControl
,
Select
,
MenuItem
,
Button
,
}
from
"@mui/material"
;
import
{
useRouter
}
from
"next/router"
;
export
default
function
Order
()
{
const
user
=
useContext
(
UserContext
);
const
router
=
useRouter
();
const
adminOrder
=
useContext
(
AdminOrderContext
);
const
[
message
,
setMessage
]
=
useState
({
message
:
""
,
error
:
false
});
const
[
userAll
,
setUserAll
]
=
useState
([]);
const
[
payStatusFilter
,
setPayStatusFilter
]
=
useState
(
0
);
useEffect
(()
=>
{
axios
...
...
@@ -70,99 +74,114 @@ export default function Order() {
isError
=
{
message
.
error
}
message
=
{
message
.
message
}
/
>
<
Paper
sx
=
{{
p
:
1
,
overflowX
:
"scroll"
}}
>
{
adminOrder
.
value
?.
length
>
0
?
(
<
Box
>
<
Table
>
<
TableHead
>
<
TableRow
>
{[
"id"
,
"วันที่"
,
"ผู้ซื้อ"
,
"ราคาทั้งหมด"
,
"ค่าส่ง"
,
"ชำระเงิน"
,
"ที่อยู่"
,
"การจัดส่ง"
,
].
map
((
label
,
idx
)
=>
(
<
TableCell
key
=
{
idx
}
>
{
label
}
<
/TableCell
>
))}
<
/TableRow
>
<
/TableHead
>
<
TableBody
>
{
adminOrder
.
value
.
map
(
(
order
,
idx
)
=>
order
&&
(
<
TableRow
key
=
{
idx
}
>
<
TableCell
>
{
order
.
id
}
<
/TableCell
>
<
TableCell
>
<
Link
title
=
"คลิกเพื่อดูรายละเอียด"
href
=
{
"/admin/order/"
+
order
.
id
}
>
{
new
Date
(
order
.
date
).
toLocaleString
()}
<
/Link
>
<
/TableCell
>
<
TableCell
>
{
userAll
.
length
?
userAll
?.
filter
(
(
usr
)
=>
usr
.
id
===
order
.
user_id
)[
0
].
name
??
"undifined"
:
"undifined"
}
<
/TableCell
>
<
TableCell
>
<
Box
color
=
"orangered"
>
$
{
Number
(
order
.
total_price
).
toLocaleString
()}
<
/Box
>
<
/TableCell
>
<
TableCell
>
<
Box
color
=
"black"
>
$
{
order
.
shipping_price
}
<
/Box
>
<
/TableCell
>
<
TableCell
>
<
Box
color
=
{
order
.
pay_status
?
"green"
:
"red"
}
>
{
order
.
pay_status
?
"ชำระเงินแล้ว"
:
"ยังไม่ชำระเงิน"
}
<
/Box
>
<
/TableCell
>
<
TableCell
>
{
order
.
address
}
<
/TableCell
>
<
TableCell
>
<
FormControl
variant
=
"standard"
>
<
Select
value
=
{
Number
(
order
.
send_status
)}
onChange
=
{(
e
)
=>
{
onSendingChange
(
Number
(
order
.
id
),
Number
(
e
.
target
.
value
)
);
}}
<
Box
sx
=
{{
maxWidth
:
1200
,
mx
:
"auto"
}}
>
<
Box
sx
=
{{
textAlign
:
"right"
,
mb
:
2
}}
>
<
Button
onClick
=
{()
=>
setPayStatusFilter
(
!
payStatusFilter
)}
variant
=
{
payStatusFilter
?
"contained"
:
"text"
}
>
ยังไม่ชำระเงิน
<
/Button
>
<
/Box
>
<
Paper
sx
=
{{
p
:
1
,
overflowX
:
"scroll"
}}
>
{
adminOrder
.
value
?.
length
>
0
?
(
<
Box
>
<
Table
>
<
TableHead
>
<
TableRow
>
{[
"id"
,
"วันที่"
,
"ผู้ซื้อ"
,
"ราคาทั้งหมด"
,
"ค่าส่ง"
,
"ชำระเงิน"
,
"ที่อยู่"
,
"การจัดส่ง"
,
].
map
((
label
,
idx
)
=>
(
<
TableCell
key
=
{
idx
}
>
{
label
}
<
/TableCell
>
))}
<
/TableRow
>
<
/TableHead
>
<
TableBody
>
{
adminOrder
.
value
.
map
(
(
order
,
idx
)
=>
(
!
payStatusFilter
||
order
.
pay_status
===
0
)
&&
(
!
router
.
query
?.
q
||
order
.
id
===
Number
(
router
.
query
.
q
))
&&
order
&&
(
<
TableRow
key
=
{
idx
}
>
<
TableCell
>
{
order
.
id
}
<
/TableCell
>
<
TableCell
>
<
Link
title
=
"คลิกเพื่อดูรายละเอียด"
href
=
{
"/admin/order/"
+
order
.
id
}
>
<
MenuItem
value
=
{
0
}
>
<
Box
color
=
"gray"
>
ยังไม่จัดส่ง
<
/Box
>
<
/MenuItem
>
<
MenuItem
value
=
{
1
}
>
<
Box
color
=
"orangered"
>
กำลังจัดส่ง
<
/Box
>
<
/MenuItem
>
<
MenuItem
value
=
{
2
}
>
<
Box
color
=
"green"
>
จัดส่งแล้ว
<
/Box
>
<
/MenuItem
>
<
/Select
>
<
/FormControl
>
<
/TableCell
>
<
/TableRow
>
)
)}
<
/TableBody
>
<
/Table
>
<
/Box
>
)
:
(
<
div
className
=
"text-center"
>
{
user
.
value
?.
token
?
"รายการว่างเปล่า"
:
"คุณยังไม่ได้เข้าสู่ระบบ"
}
<
/div
>
)}
<
/Paper
>
{
new
Date
(
order
.
date
).
toLocaleString
()}
<
/Link
>
<
/TableCell
>
<
TableCell
>
{
userAll
.
length
?
userAll
?.
filter
(
(
usr
)
=>
usr
.
id
===
order
.
user_id
)[
0
].
name
??
"undifined"
:
"undifined"
}
<
/TableCell
>
<
TableCell
>
<
Box
color
=
"orangered"
>
$
{
Number
(
order
.
total_price
).
toLocaleString
()}
<
/Box
>
<
/TableCell
>
<
TableCell
>
<
Box
color
=
"black"
>
$
{
order
.
shipping_price
}
<
/Box
>
<
/TableCell
>
<
TableCell
>
<
Box
color
=
{
order
.
pay_status
?
"green"
:
"red"
}
>
{
order
.
pay_status
?
"ชำระเงินแล้ว"
:
"ยังไม่ชำระเงิน"
}
<
/Box
>
<
/TableCell
>
<
TableCell
>
{
order
.
address
}
<
/TableCell
>
<
TableCell
>
<
FormControl
variant
=
"standard"
>
<
Select
value
=
{
Number
(
order
.
send_status
)}
onChange
=
{(
e
)
=>
{
onSendingChange
(
Number
(
order
.
id
),
Number
(
e
.
target
.
value
)
);
}}
>
<
MenuItem
value
=
{
0
}
>
<
Box
color
=
"gray"
>
ยังไม่จัดส่ง
<
/Box
>
<
/MenuItem
>
<
MenuItem
value
=
{
1
}
>
<
Box
color
=
"orangered"
>
กำลังจัดส่ง
<
/Box
>
<
/MenuItem
>
<
MenuItem
value
=
{
2
}
>
<
Box
color
=
"green"
>
จัดส่งแล้ว
<
/Box
>
<
/MenuItem
>
<
/Select
>
<
/FormControl
>
<
/TableCell
>
<
/TableRow
>
)
)}
<
/TableBody
>
<
/Table
>
<
/Box
>
)
:
(
<
div
className
=
"text-center"
>
{
user
.
value
?.
token
?
"รายการว่างเปล่า"
:
"คุณยังไม่ได้เข้าสู่ระบบ"
}
<
/div
>
)}
<
/Paper
>
<
/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