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
baaac0df
Commit
baaac0df
authored
Oct 05, 2023
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update show order in report
parent
b65e1604
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
+27
-10
Orders.js
src/components/dashboard/Orders.js
+22
-9
order.js
src/pages/admin/order.js
+5
-1
No files found.
src/components/dashboard/Orders.js
View file @
baaac0df
...
...
@@ -9,15 +9,12 @@ import TableRow from "@mui/material/TableRow";
import
Title
from
"./Title"
;
import
{
UserContext
}
from
"@/pages/_app"
;
import
{
AdminOrderContext
}
from
"../layout/AdminLayout"
;
function
preventDefault
(
event
)
{
event
.
preventDefault
();
}
import
axios
from
"axios"
;
export
default
function
Orders
()
{
const
user
=
React
.
useContext
(
UserContext
);
const
adminOrder
=
React
.
useContext
(
AdminOrderContext
);
const
[
orderRecent
,
setOrderRecent
]
=
React
.
useState
([]);
const
[
userAll
,
setUserAll
]
=
React
.
useState
([]);
React
.
useEffect
(()
=>
{
let
order_r
=
[];
...
...
@@ -27,6 +24,15 @@ export default function Orders() {
setOrderRecent
(
order_r
);
},
[
adminOrder
]);
React
.
useEffect
(()
=>
{
axios
.
get
(
"/api/user"
)
.
then
((
res
)
=>
{
setUserAll
(
res
.
data
);
})
.
catch
((
err
)
=>
console
.
log
(
err
));
},
[]);
return
(
<
React
.
Fragment
>
<
Title
>
ออเดอร์ล่าสุด
<
/Title
>
...
...
@@ -38,7 +44,7 @@ export default function Orders() {
"id"
,
"ราคาทั้งหมด"
,
"วันที่"
,
"
จำนวนสินค้า
"
,
"
ผู้ซื้อ
"
,
"ค่าส่ง"
,
"ชำระเงิน"
,
].
map
((
label
,
idx
)
=>
(
...
...
@@ -62,8 +68,13 @@ export default function Orders() {
{
new
Date
(
order
.
date
).
toLocaleString
()}
<
/Link
>
<
/TableCell
>
<
TableCell
>
{
order
.
product_count
}
<
/TableCell
>
<
TableCell
>
{
order
.
shipping_price
}
<
/TableCell
>
<
TableCell
>
{
userAll
.
length
?
userAll
?.
filter
((
usr
)
=>
usr
.
id
===
order
.
user_id
)[
0
]
.
name
??
"undifined"
:
"undifined"
}
<
/TableCell
>
<
TableCell
>
$
{
order
.
shipping_price
}
<
/TableCell
>
<
TableCell
>
<
Box
color
=
{
order
.
pay_status
?
"green"
:
"red"
}
>
{
order
.
pay_status
?
"ชำระเงินแล้ว"
:
"ยังไม่ชำระเงิน"
}
...
...
@@ -76,7 +87,9 @@ export default function Orders() {
<
/Table
>
<
/div
>
<
Box
sx
=
{{
pt
:
2
}}
>
<
Link
className
=
"text-blue-600"
href
=
"/admin/order"
>
ดูออเดอร์ทั้งหมด
<
/Link
>
<
Link
className
=
"text-blue-600"
href
=
"/admin/order"
>
ดูออเดอร์ทั้งหมด
<
/Link
>
<
/Box
>
<
/React.Fragment
>
);
...
...
src/pages/admin/order.js
View file @
baaac0df
...
...
@@ -110,7 +110,11 @@ export default function Order() {
<
/Link
>
<
/TableCell
>
<
TableCell
>
{
userAll
.
filter
((
usr
)
=>
usr
.
id
===
order
.
user_id
)[
0
].
name
}
{
userAll
.
length
?
userAll
?.
filter
(
(
usr
)
=>
usr
.
id
===
order
.
user_id
)[
0
].
name
??
"undifined"
:
"undifined"
}
<
/TableCell
>
<
TableCell
>
<
Box
color
=
"black"
>
$
{
order
.
shipping_price
}
<
/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