Commit 77ba1f47 authored by Christopher Cottier's avatar Christopher Cottier

order history page now grabbing history from get orders by id route

parent 1be1a354
import React, { useEffect, useState } from 'react'
import { useSelector } from 'react-redux';
import { getOrderHistory } from '../../util/order_api_util';
import Order from './Order';
......@@ -8,10 +9,12 @@ const OrderHistory = () => {
const [orderHistory, setOrderHistory] = useState([]);
const [callMade, setCallMade] = useState(false);
const {currentUser} = useSelector(state => state.user);
useEffect( async () => {
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);
setCallMade(true);
});
......
......@@ -2,37 +2,36 @@ import Config from "../config";
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 orders = await res.json();
// return orders;
const res = await fetch(`${Config.orderHistoryApiUrlMethod(userId)}`);
const orders = await res.json();
return orders;
return (
[
{
id: "609968a89cc32e1ef8208e8b",
orderTrackingCode: "N/A",
orderStatus: "RECEIVED",
orderCreatedAt: 1620666536727,
orderUpdatedAt: 1620666536727,
customerId: "e-com-test-id2",
customerEmailAddress: "test@test.test",
orderItems: [
{
itemId: "AFP-989",
itemName: "this item",
itemSku: "AFP-989",
itemQuantity: 2,
itemPrice: 14.0
}
],
customerAddress: {
street: "Grand",
city: "chicago",
state: "IL",
zip: "90210"
}
}
]
)
// return (
// [
// {
// id: "609968a89cc32e1ef8208e8b",
// orderTrackingCode: "N/A",
// orderStatus: "RECEIVED",
// orderCreatedAt: 1620666536727,
// orderUpdatedAt: 1620666536727,
// customerId: "e-com-test-id2",
// customerEmailAddress: "test@test.test",
// orderItems: [
// {
// itemId: "AFP-989",
// itemName: "this item",
// itemSku: "AFP-989",
// itemQuantity: 2,
// itemPrice: 14.0
// }
// ],
// customerAddress: {
// street: "Grand",
// city: "chicago",
// state: "IL",
// zip: "90210"
// }
// }
// ]
// )
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment