Commit 89136e79 authored by Shanelle Valencia's avatar Shanelle Valencia

Fix rebase issues

parents 6261f87b f124ab85
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
"name": "order-management-client", "name": "order-management-client",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"proxy": "http://localhost:8080",
"dependencies": { "dependencies": {
"@chakra-ui/react": "^1.6.0", "@chakra-ui/react": "^1.6.0",
"@emotion/react": "^11", "@emotion/react": "^11",
......
declare module "Order" { declare module "Order" {
export interface Order { export interface Order {
date: string, customerAddress: Address,
orderNumber: string, customerEmailAddress: string,
orderItems: Product[] customerId: string,
id: string,
orderCreatedAt: number,
orderItems: Item[],
orderStatus: string,
orderTrackingCode: string,
orderUpdatedAt: number
} }
export interface Product { export interface Address {
_id: string, city: string,
sku: string, state: string,
upc: string, street: string,
productName: string, zip: string
productDescription: string, }
price: number,
quantity: number, export interface Item {
productImageUrl: string, itemId: string,
brand: string, itemPrice: number,
category: string itemQuantity: number,
itemSku: number
} }
} }
\ No newline at end of file
...@@ -3,12 +3,12 @@ import { Link } from 'react-router-dom' ...@@ -3,12 +3,12 @@ import { Link } from 'react-router-dom'
const Nav = () => { const Nav = () => {
return ( return (
<header role="navigation"> <header className="nav-bar" role="navigation">
<div>Order Management Console PRO</div> <div className="order-management">Order Management Console PRO</div>
<ul> <ul className="nav-list">
<li><Link to="/orders">All orders</Link></li> <li><Link className="nav-link" to="/orders">All orders</Link></li>
<li><Link to="/account">(account logo here)</Link></li> <li><Link className="nav-link" to="/account">(account logo here)</Link></li>
<li><Link to="/">Login / Logout</Link></li> <li><Link className="nav-link" to="/">Login / Logout</Link></li>
</ul> </ul>
</header> </header>
) )
......
import React from 'react'; import React, { useState, useEffect } from 'react';
import { OrderService } from 'services'; import { Item } from 'Order';
import { Product } from 'Order';
const OrderShowDetails = (props: any) => { const OrderShowDetails = (props: any) => {
const orderProductDetails = props.products.map((prod: any, idx: any) => { const [items, setItems] = useState<Item[]>()
return ( useEffect(() => {
<tr key={idx}> setItems(props.items)
<td><img src={prod.productImageUrl} alt="img placeholder"/></td> }, [props.items])
<td>{prod.productName}</td>
<td>{prod.productDescription}</td> const itemMap = (items: Item[]) => {
<td>{prod.sku}</td> return items.map((item: Item, idx: number) => {
<td>{prod.upc}</td> return (
<td>{prod.price}</td> <tr key={idx}>
<td>{prod.quantity}</td> <td>{item.itemId}</td>
</tr> <td>{item.itemPrice}</td>
) <td>{item.itemQuantity}</td>
}) <td>{item.itemSku}</td>
</tr>
)
});
}
const itemDetails = items ? itemMap(items) : <></>
return ( return (
<table> items ?
<tbody> <table>
<tr> <tbody>
<th>image</th> <tr>
<th>productName</th> <th>ID</th>
<th>description</th> <th>Price</th>
<th>sku</th> <th>Quantity</th>
<th>upc</th> <th>SKU</th>
<th>price</th> </tr>
<th>quantity</th> {itemDetails}
</tr> </tbody>
{orderProductDetails} </table>
</tbody> :
</table> <div className="Order without items">
This order didn't contain any items.
</div>
) )
} }
......
...@@ -5,14 +5,17 @@ body { ...@@ -5,14 +5,17 @@ body {
sans-serif; sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
background-color: gray;
color: ghostwhite;
} }
code { code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace; monospace;
} }
* { tbody, tr, th, span, td {
border: 2px solid orangered; border: 2px solid orangered;
} }
...@@ -20,3 +23,53 @@ span { ...@@ -20,3 +23,53 @@ span {
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
} }
header {
display: flex;
height: 50px;
background-color: gray;
}
ul {
list-style-type: none;
display: flex;
margin: auto;
height: 100%;
}
table {
width: 100%;
padding: 20px;
}
td {
height: 100px;
}
li {
border-left: 2px solid green;
margin: 0;
height: 100%;
display: flex;
align-items: center;
}
.order-management {
padding-left: -30px;
padding-right: 75px;
margin: auto;
justify-content: left;
}
.nav-link {
margin: auto;
padding: 10px;
text-decoration: none;
color: ghostwhite;
background-color: lightslategray;
}
.nav-link:hover {
background-color: black;
}
\ No newline at end of file
import React from 'react' import React, { useState, useEffect } from 'react'
import {AccountForm} from 'components' import {AccountForm} from 'components'
const AccountPage = () => { const AccountPage = () => {
// const [appState, setAppState] = useState(0);
// useEffect(() => {
// const apiUrl = 'http://localhost:8080/api/orders';
// fetch(apiUrl).then((response) => response.json())
// .then((data) => console.log('This is your data', data));
// }, [appState])
// const tester = ()=> {
// setAppState(appState + 1);
// }
return ( return (
<div> <div>
{/* <button onClick={tester}>{appState}</button> */}
<AccountForm /> <AccountForm />
</div> </div>
) )
......
import React, {useState, useEffect} from 'react' import React, {useState, useEffect} from 'react'
import {OrderDetails, SearchOrder} from 'components' import {OrderDetails, SearchOrder} from 'components'
import { OrderService } from 'services'; import { OrderService } from 'services';
import { Order } from 'Order';
const OrderIndexPage = () => { const OrderIndexPage = () => {
let [orders, setOrders] = useState([]); let [orders, setOrders] = useState([]);
useEffect(() => { useEffect(() => {
OrderService.allOrders().then((res: any) => { OrderService.allOrders().then((res: any) => {
setOrders(res); setOrders(res);
...@@ -11,11 +13,20 @@ const OrderIndexPage = () => { ...@@ -11,11 +13,20 @@ const OrderIndexPage = () => {
}) })
const orderDetailsArr = orders.map((order: any, idx: any) => { // const orderDetailsArr = orders.map((order: any, idx: any) => {
// const apiUrl = 'http://localhost:8080/api/orders';
// fetch(apiUrl).then((response) => response.json())
// .then((data) => {
// console.log('This is your data', data)
// setOrders(data);
// });
// }, [setOrders])
const orderDetailsArr = orders.map((order: Order, idx: any) => {
return <tr key={idx}><OrderDetails return <tr key={idx}><OrderDetails
date={order.date} date={order.orderCreatedAt}
orderNumber={order.orderNumber} orderNumber={order.id}
status="fulfilled" status={order.orderStatus}
/></tr> /></tr>
}) })
...@@ -24,9 +35,9 @@ const OrderIndexPage = () => { ...@@ -24,9 +35,9 @@ const OrderIndexPage = () => {
<table> <table>
<tbody> <tbody>
<tr> <tr>
<th>order number</th> <th>Order number</th>
<th>date</th> <th>Created</th>
<th>status</th> <th>Order Status</th>
</tr> </tr>
{orderDetailsArr} {orderDetailsArr}
</tbody> </tbody>
......
import React, {useState, useEffect} from 'react'; import React, {useState, useEffect} from 'react';
import { OrderService } from 'services';
import {OrderShowDetails} from 'components'; import {OrderShowDetails} from 'components';
import { Order } from 'Order'; import { Order, Item } from 'Order';
const OrderShowPage = (props: any) => { const OrderShowPage = (props: any) => {
const location = parseInt(props.match.params.id); const location = props.match.params.id;
const apiUrl = 'http://localhost:8080/api/orders/' + location;
const [order, setOrder] = useState<Order>(); const [order, setOrder] = useState<Order>();
const [items, setItems] = useState<Item[]>()
useEffect(() => { useEffect(() => {
OrderService.orderById(location).then((res: any) => { fetch(apiUrl).then((response) => response.json())
setOrder(res); .then((data) => {
}) console.log('This is your order', data)
}) setOrder(data);
setItems(data.orderItems)
});
}, [setOrder, setItems, apiUrl])
if (!order) { if (!order) {
return(<></>); return(<></>);
} }
return ( return (
<> <>
<span> <span>
<h3>Order Date: {order.date}</h3> <h3>Order Date: {order.orderCreatedAt}</h3>
<h3>Order Number: {order.orderNumber}</h3> <h3>Order Number: {order.id}</h3>
<h3>Order Status: Fulfilled</h3> <h3>Order Status: {order.orderStatus}</h3>
</span> </span>
<OrderShowDetails products={order.orderItems}/> <OrderShowDetails items={items}/>
</> </>
) )
} }
......
import orderData from './mock-order-data' import orderList from './mock-order-data'
import { Order } from 'Order'; import { Order } from 'Order';
export const allOrders = () => new Promise<Order[]>((res, rej) => { export const allOrders = () => new Promise<Order[]>((res, rej) => {
setTimeout(() => { res(orderData) }, 2000) setTimeout(() => { res(orderList) }, 2000)
}); });
export const orderById = (id: number) => new Promise<Order>((res, rej) => { export const orderById = (id: string) => new Promise<Order>((res, rej) => {
setTimeout(() => { res(orderData[id]) }, 2000) setTimeout(() => {
const orderData = orderList.filter((order) => {
return order.id === id;
})
res(orderData[0])
}, 2000)
}) })
......
...@@ -2,125 +2,63 @@ import { Order } from 'Order' ...@@ -2,125 +2,63 @@ import { Order } from 'Order'
const orders: Order[] = [ const orders: Order[] = [
{ {
"date": "01/01/01", customerAddress: {
"orderNumber": "025412", city: "Lynnwood",
"orderItems": [ state: "Washington",
street: "9944 Fiction Way",
zip: "98087"
},
customerEmailAddress: "amdog@gmail.com",
customerId: "holyjabronie",
id: "342341234",
orderCreatedAt: 245245253452452,
orderItems: [
{ {
"_id": "x588s78xvhs", itemId: "string",
"sku": "2192649", itemPrice: 23,
"upc": "221481649", itemQuantity: 35,
"productName": "Apex One", itemSku: 944332
"productDescription": "Janky",
"price": 5500.50,
"quantity": 9,
"productImageUrl": "https://picsum.photos/100/100",
"brand": "Apex",
"category": "Security"
}, },
{ {
"_id": "akldfgjaf", itemId: "number",
"sku": "111111", itemPrice: 99,
"upc": "222333", itemQuantity: 1000,
"productName": "1 Liter", itemSku: 8943562
"productDescription": "Water bottle",
"price": 500000.50,
"quantity": 30,
"productImageUrl": "https://picsum.photos/100/100",
"brand": "Nalgene",
"category": "Hydration"
} }
] ],
orderStatus: "FULFILLED",
orderTrackingCode: "1Z1251432142343444",
orderUpdatedAt: 124563478
}, },
{ {
"date": "01/02/03", customerAddress: {
"orderNumber": "1887215", city: "San Francisco",
"orderItems": [ state: "CA",
street: "4325 Nonya Ave",
zip: "94112"
},
customerEmailAddress: "goodestboi96@hotmail.com",
customerId: "happypuppy",
id: "243523452",
orderCreatedAt: 245245253452452,
orderItems: [
{ {
"_id": "apsdifua", itemId: "Bottle",
"sku": "333444", itemPrice: 22,
"upc": "0101010101", itemQuantity: 55,
"productName": "Passport", itemSku: 5566434
"productDescription": "US Passport (fake)",
"price": 5500.50,
"quantity": 9,
"productImageUrl": "https://picsum.photos/100/100",
"brand": "USAUSAUSA",
"category": "Security"
}, },
{ {
"_id": "poadsfs", itemId: "Ruler",
"sku": "55556666", itemPrice: 10,
"upc": "3636363636", itemQuantity: 8,
"productName": "Octopus", itemSku: 7895435
"productDescription": "glass octopus paper weight",
"price": 500000.50,
"quantity": 30,
"productImageUrl": "https://picsum.photos/100/100",
"brand": "Glass",
"category": "paper weights"
} }
] ],
}, orderStatus: "UNFULFILLED",
{ orderTrackingCode: "298523452345",
"date": "07/17/07", orderUpdatedAt: 124563478
"orderNumber": "587125", }
"orderItems": [
{
"_id": "851adsafa6",
"sku": "9563285",
"upc": "18118181818",
"productName": "Keyboard",
"productDescription": "what you use to type",
"price": 1999.99,
"quantity": 20,
"productImageUrl": "https://picsum.photos/100/100",
"brand": "Apple",
"category": "Electronics"
},
{
"_id": "adv2515",
"sku": "282828",
"upc": "9892956",
"productName": "Trackpad",
"productDescription": "apple trackpad",
"price": 599.99,
"quantity": 10,
"productImageUrl": "https://picsum.photos/100/100",
"brand": "Apple",
"category": "Electronics"
}
]
},
{
"date": "10/11/21",
"orderNumber": "852634",
"orderItems": [
{
"_id": "855adf4s",
"sku": "5311469",
"upc": "271156325",
"productName": "Notepad",
"productDescription": "something to write on",
"price": 25.50,
"quantity": 39,
"productImageUrl": "https://picsum.photos/100/100",
"brand": "Notes",
"category": "Office supplies"
},
{
"_id": "csd125",
"sku": "256324",
"upc": "8775632",
"productName": "Pen",
"productDescription": "pennnn",
"price": 10.50,
"quantity": 50,
"productImageUrl": "https://picsum.photos/100/100",
"brand": "Notes",
"category": "Office supplies"
}
]
},
] ]
......
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