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
9ff8cb19
Commit
9ff8cb19
authored
Oct 05, 2023
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
report deposites in report
parent
c24a22ef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
10 deletions
+36
-10
Deposits.js
src/components/dashboard/Deposits.js
+35
-9
[id].js
src/pages/admin/order/[id].js
+1
-1
No files found.
src/components/dashboard/Deposits.js
View file @
9ff8cb19
import
*
as
React
from
'react'
;
import
Link
from
'@mui/material/Link'
;
import
Typography
from
'@mui/material/Typography'
;
import
Title
from
'./Title'
;
import
*
as
React
from
"react"
;
import
Link
from
"@mui/material/Link"
;
import
Typography
from
"@mui/material/Typography"
;
import
Title
from
"./Title"
;
import
{
AdminOrderContext
}
from
"../layout/AdminLayout"
;
import
{
UserContext
}
from
"@/pages/_app"
;
function
preventDefault
(
event
)
{
event
.
preventDefault
();
}
export
default
function
Deposits
()
{
const
[
totalSelling
,
setTotalSelling
]
=
React
.
useState
(
0
);
const
adminOrder
=
React
.
useContext
(
AdminOrderContext
);
const
user
=
React
.
useContext
(
UserContext
);
const
[
month
,
setMonth
]
=
React
.
useState
(
""
);
const
[
year
,
setYear
]
=
React
.
useState
(
"2023"
);
React
.
useEffect
(()
=>
{
if
(
!
user
.
value
?.
token
||
adminOrder
.
value
.
length
===
0
)
return
;
let
total
=
0
;
const
date
=
new
Date
(
adminOrder
.
value
[
0
].
date
);
const
month_now
=
date
.
toLocaleString
(
"default"
,
{
month
:
"long"
});
const
year_now
=
date
.
getFullYear
();
for
(
let
i
=
0
;
i
<
adminOrder
.
value
.
length
;
i
++
)
{
let
d
=
new
Date
(
adminOrder
.
value
[
i
].
date
);
let
m
=
date
.
toLocaleString
(
"default"
,
{
month
:
"long"
});
let
y
=
date
.
getFullYear
();
if
(
m
===
month_now
&&
y
===
year_now
)
{
total
+=
Number
(
adminOrder
.
value
[
i
].
total_price
);
}
}
setMonth
(
month_now
)
setYear
(
year_now
)
setTotalSelling
(
total
);
},
[
user
]);
return
(
<
React
.
Fragment
>
<
Title
>
Recent
Deposits
<
/Title
>
<
Title
>
ยอดขายทั้งหมด
<
/Title
>
<
Typography
component
=
"p"
variant
=
"h4"
>
$
3
,
024.00
$
{
Number
(
totalSelling
).
toLocaleString
()}
<
/Typography
>
<
Typography
color
=
"text.secondary"
sx
=
{{
flex
:
1
}}
>
on
15
March
,
2019
on
{
month
},
{
year
}
<
/Typography
>
<
div
>
<
Link
color
=
"primary"
href
=
"#"
onClick
=
{
preventDefault
}
>
...
...
@@ -24,4 +51,4 @@ export default function Deposits() {
<
/div
>
<
/React.Fragment
>
);
}
\ No newline at end of file
}
src/pages/admin/order/[id].js
View file @
9ff8cb19
...
...
@@ -63,7 +63,7 @@ export default function AdminOrderDetail() {
{
orderDetailList
.
length
?
(
<
Box
>
<
Box
sx
=
{{
textAlign
:
"right"
,
p
:
1
}}
>
<
Link
href
=
"/order"
>
<
Link
href
=
"/
admin/
order"
>
<
Button
color
=
"error"
>
<
ArrowBackIos
/>
ย้อนกลับ
<
/Button
>
...
...
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