Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ecommerce-maven
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ascend
ecommerce-maven
Commits
77ba1f47
Commit
77ba1f47
authored
May 11, 2021
by
Christopher Cottier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
order history page now grabbing history from get orders by id route
parent
1be1a354
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
33 deletions
+35
-33
order-history.jsx
ecom-web/src/components/order-history/order-history.jsx
+4
-1
order_api_util.js
ecom-web/src/util/order_api_util.js
+31
-32
No files found.
ecom-web/src/components/order-history/order-history.jsx
View file @
77ba1f47
import
React
,
{
useEffect
,
useState
}
from
'react'
import
React
,
{
useEffect
,
useState
}
from
'react'
import
{
useSelector
}
from
'react-redux'
;
import
{
getOrderHistory
}
from
'../../util/order_api_util'
;
import
{
getOrderHistory
}
from
'../../util/order_api_util'
;
import
Order
from
'./Order'
;
import
Order
from
'./Order'
;
...
@@ -8,10 +9,12 @@ const OrderHistory = () => {
...
@@ -8,10 +9,12 @@ const OrderHistory = () => {
const
[
orderHistory
,
setOrderHistory
]
=
useState
([]);
const
[
orderHistory
,
setOrderHistory
]
=
useState
([]);
const
[
callMade
,
setCallMade
]
=
useState
(
false
);
const
[
callMade
,
setCallMade
]
=
useState
(
false
);
const
{
currentUser
}
=
useSelector
(
state
=>
state
.
user
);
useEffect
(
async
()
=>
{
useEffect
(
async
()
=>
{
if
(
callMade
)
return
;
if
(
callMade
)
return
;
const
userHistory
=
await
getOrderHistory
(
'e-com-test-id2'
);
//insert user id from user details stored in redux
const
userHistory
=
await
getOrderHistory
(
currentUser
.
userId
);
//insert user id from user details stored in redux
setOrderHistory
(
userHistory
);
setOrderHistory
(
userHistory
);
setCallMade
(
true
);
setCallMade
(
true
);
});
});
...
...
ecom-web/src/util/order_api_util.js
View file @
77ba1f47
...
@@ -2,37 +2,36 @@ import Config from "../config";
...
@@ -2,37 +2,36 @@ import Config from "../config";
export
const
getOrderHistory
=
async
(
userId
)
=>
{
export
const
getOrderHistory
=
async
(
userId
)
=>
{
//This is what we will return once our oder history API is operational
const
res
=
await
fetch
(
`
${
Config
.
orderHistoryApiUrlMethod
(
userId
)}
`
);
// const res = await fetch(`${Config.orderHistoryApiUrlMethod(userId)}`);
const
orders
=
await
res
.
json
();
// const orders = await res.json();
return
orders
;
// return orders;
return
(
//
return (
[
//
[
{
//
{
id
:
"609968a89cc32e1ef8208e8b"
,
//
id: "609968a89cc32e1ef8208e8b",
orderTrackingCode
:
"N/A"
,
//
orderTrackingCode: "N/A",
orderStatus
:
"RECEIVED"
,
//
orderStatus: "RECEIVED",
orderCreatedAt
:
1620666536727
,
//
orderCreatedAt: 1620666536727,
orderUpdatedAt
:
1620666536727
,
//
orderUpdatedAt: 1620666536727,
customerId
:
"e-com-test-id2"
,
//
customerId: "e-com-test-id2",
customerEmailAddress
:
"test@test.test"
,
//
customerEmailAddress: "test@test.test",
orderItems
:
[
//
orderItems: [
{
//
{
itemId
:
"AFP-989"
,
//
itemId: "AFP-989",
itemName
:
"this item"
,
//
itemName: "this item",
itemSku
:
"AFP-989"
,
//
itemSku: "AFP-989",
itemQuantity
:
2
,
//
itemQuantity: 2,
itemPrice
:
14.0
//
itemPrice: 14.0
}
//
}
],
//
],
customerAddress
:
{
//
customerAddress: {
street
:
"Grand"
,
//
street: "Grand",
city
:
"chicago"
,
//
city: "chicago",
state
:
"IL"
,
//
state: "IL",
zip
:
"90210"
//
zip: "90210"
}
//
}
}
//
}
]
//
]
)
//
)
}
}
\ No newline at end of file
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