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 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';
...@@ -9,9 +10,11 @@ const OrderHistory = () => { ...@@ -9,9 +10,11 @@ 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);
}); });
......
...@@ -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
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