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
388c06f3
Commit
388c06f3
authored
May 10, 2021
by
Christopher Cottier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AFP-70: basic information on order history page
parent
bfb60f7e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
5 deletions
+33
-5
Order.jsx
ecom-web/src/components/order-history/Order.jsx
+22
-2
order-history.jsx
ecom-web/src/components/order-history/order-history.jsx
+6
-3
order_api_util.js
ecom-web/src/util/order_api_util.js
+0
-0
order_history_util.js
ecom-web/src/util/order_history_util.js
+5
-0
No files found.
ecom-web/src/components/order-history/Order.jsx
View file @
388c06f3
import
React
from
'react'
;
import
{
totalPrice
}
from
'../../util/order_history_util'
;
const
Order
=
(
props
)
=>
{
const
{
order
}
=
props
;
console
.
log
(
order
);
const
{
orderItems
,
customerAddress
}
=
order
;
const
orderTotalPrice
=
totalPrice
(
orderItems
);
const
orderPlaced
=
new
Date
(
order
.
orderCreatedAt
);
return
(
null
<
div
>
<
p
>
Order ID:
{
order
.
id
}
</
p
>
<
p
>
Order Status:
{
order
.
orderStatus
}
</
p
>
<
p
>
Order Placed:
{
orderPlaced
.
getUTCMonth
()
}
/
{
orderPlaced
.
getUTCDay
()
}
/
{
orderPlaced
.
getUTCFullYear
()
}
</
p
>
<
p
>
Delivery Address:
{
`
${customerAddress.street},
${customerAddress.city},
${customerAddress.state} ${customerAddress.zip}
`
}
</
p
>
<
p
>
Total Price: $
{
orderTotalPrice
}
</
p
>
</
div
>
)
}
...
...
ecom-web/src/components/order-history/order-history.jsx
View file @
388c06f3
import
React
,
{
useEffect
,
useState
}
from
'react'
import
{
getOrderHistory
}
from
'../../
actions/order_actions
'
;
import
{
getOrderHistory
}
from
'../../
util/order_api_util
'
;
import
Order
from
'./Order'
;
import
'./order-history.css'
...
...
@@ -7,11 +7,14 @@ import './order-history.css'
const
OrderHistory
=
()
=>
{
const
[
orderHistory
,
setOrderHistory
]
=
useState
([]);
const
[
callMade
,
setCallMade
]
=
useState
(
false
);
useEffect
(
async
()
=>
{
const
userHistory
=
await
getOrderHistory
(
'e-com-test-id2'
);
if
(
callMade
)
return
;
const
userHistory
=
await
getOrderHistory
(
'e-com-test-id2'
);
//insert user email from user details stored in redux
setOrderHistory
(
userHistory
);
},
[
orderHistory
]);
setCallMade
(
true
);
});
return
(
<
main
>
...
...
ecom-web/src/
actions/order_actions
.js
→
ecom-web/src/
util/order_api_util
.js
View file @
388c06f3
File moved
ecom-web/src/util/order_history_util.js
0 → 100644
View file @
388c06f3
export
const
totalPrice
=
(
items
)
=>
{
return
items
.
reduce
((
acc
,
item
)
=>
{
return
acc
+
item
.
itemPrice
;
},
0
).
toFixed
(
2
);
}
\ 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