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
b9dbcf28
Commit
b9dbcf28
authored
Oct 05, 2023
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: show order detail on admin
parent
72966fce
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
2 deletions
+23
-2
AdminOrderController.js
app/controllers/AdminOrderController.js
+16
-0
admin.js
app/routes/admin.js
+1
-0
[id].js
src/pages/admin/order/[id].js
+6
-2
No files found.
app/controllers/AdminOrderController.js
View file @
b9dbcf28
...
...
@@ -35,6 +35,22 @@ const AdminOrderController = {
res
.
json
({
status
:
300
,
message
:
"Error with server"
});
}
},
/**
*
* @param {Request} req
* @param {Response} res
*/
async
detail
(
req
,
res
)
{
try
{
const
{
id
}
=
req
.
query
;
let
orderdetail
=
await
db
.
order_detail
.
findMany
({
where
:
{
order_id
:
Number
(
id
)
},
});
res
.
json
(
orderdetail
);
}
catch
(
err
)
{
res
.
status
(
403
).
json
({
status
:
100
,
message
:
"found error on server"
});
}
},
};
export
default
AdminOrderController
;
app/routes/admin.js
View file @
b9dbcf28
...
...
@@ -19,5 +19,6 @@ adminRouter.delete("/category", CategoryController.delete);
adminRouter
.
get
(
"/order"
,
AdminOrderController
.
index
);
adminRouter
.
put
(
"/order/sending"
,
AdminOrderController
.
sending
);
adminRouter
.
get
(
"/order/detail"
,
AdminOrderController
.
detail
);
export
default
adminRouter
;
src/pages/admin/order/[id].js
View file @
b9dbcf28
...
...
@@ -31,9 +31,13 @@ export default function AdminOrderDetail() {
const
fetchOrderDetail
=
async
()
=>
{
if
(
!
user
.
value
?.
token
)
return
;
try
{
let
response
=
await
axios
.
get
(
"/api/u/order/detail?id="
+
router
.
query
.
id
,
{
let
response
=
await
axios
.
get
(
"/api/admin/order/detail?id="
+
router
.
query
.
id
,
{
headers
:
{
token
:
user
.
value
.
token
},
});
}
);
console
.
log
(
response
.
data
);
setOrderDetailList
(
response
.
data
);
}
catch
(
err
)
{
console
.
log
(
err
);
...
...
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