Commit 770e7d2e authored by Christopher Cottier's avatar Christopher Cottier

added sample return data

parent 1fb4a1bd
This source diff could not be displayed because it is too large. You can view the blob instead.
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;
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
import React from 'react';
const Order = (props) => {
const {order} = props;
console.log(order);
return (
null
)
}
export default Order;
\ No newline at end of file
import { connect } from 'react-redux';
import OrderHistory from './order-history';
const mSTP = state => ({
});
const mDTP = dispatch => ({
});
export default connect(mSTP, mDTP)(OrderHistory);
\ No newline at end of file
main {
margin: 0 auto;
max-width: 1080px;
}
\ No newline at end of file
import React, { Component } from 'react'
import React, { useEffect, useState } from 'react'
import { getOrderHistory } from '../../actions/order_actions';
import Order from './Order';
export default class OrderHistory extends Component {
constructor(props) {
super(props)
this.state = {}
}
import './order-history.css'
const OrderHistory = () => {
const [orderHistory, setOrderHistory] = useState([]);
render() {
return (
<div>
This is the OrderHistory component
useEffect( async () => {
const userHistory = await getOrderHistory('e-com-test-id2');
setOrderHistory(userHistory);
}, [orderHistory]);
return (
<main>
<h1>Order History</h1>
<div id="orders">
{orderHistory.map(order => {
return <Order order={order}/>;
})}
</div>
)
}
}
\ No newline at end of file
</main>
)
}
export default OrderHistory;
\ No newline at end of file
......@@ -5,7 +5,7 @@ import SessionContainer from './session/session-container';
import ProductMarketContainer from './product-market/product-market-container';
import ShoppingCartContainer from './shopping-cart/shopping-cart-container';
import CheckoutContianer from './checkout/checkout-container';
import OrderHistoryContainer from './order-history/order-history';
import OrderHistory from './order-history/order-history';
const Root = ({ store }) => (
<Provider store={ store }>
......@@ -17,7 +17,7 @@ const Root = ({ store }) => (
return (
// this.state.isUserAuthenticated ? // This can be changed for however our frontend user auth will operate
// <Redirect to="/product-market" /> :
<Redirect to="/product-market" />
<Redirect to="/orders" />
)
}}
/>
......@@ -25,7 +25,7 @@ const Root = ({ store }) => (
<Route path="/product-market" component={ ProductMarketContainer } />
<Route path="/cart" component={ ShoppingCartContainer } />
<Route path="/checkout" component={ CheckoutContianer } />
<Route path="/orders" component={ OrderHistoryContainer } />
<Route path="/orders" component={ OrderHistory } />
</Switch>
</BrowserRouter>
</Provider>
......
class Config {
static baseApiUrl = "http://localhost:8080/api"; //env file
static orderHistoryApiUrlMethod = (userId) => `${this.baseApiUrl}/users/${userId}/orders`;
}
export default Config;
\ 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