Commit f699f4d8 authored by Kevin Kaminski's avatar Kevin Kaminski

[AFP-26] 🚧 Fix errors on OrderIndexPage and OrderShowPage, add...

[AFP-26] 🚧 Fix errors on OrderIndexPage and OrderShowPage, add table to OrderShowPage, change OrderIndexPage table to relevant information [@kkaminski]
parent 57e4fcf6
import React from 'react' import React from 'react'
import { Link } from 'react-router-dom'
const OrderDetails = () => { const OrderDetails = (props: any) => {
const orderNumber = props.orderNumber
const date = props.date;
const status = props.status
return ( return (
<tr> <>
<td>6396964924168</td> <td><Link to={"/orders/" + orderNumber}>{orderNumber}</Link></td>
<td>shfd87tw878w</td> <td>{date}</td>
<td>Apex One</td> <td>{status}</td>
</tr> </>
) )
} }
......
import React from 'react'
const OrderShowDetails = (props: any) => {
const orderProductDetails = props.products.map((prod: any, idx: any) => {
return (
<tr key={idx}>
<td><img src={prod.productImageUrl} alt="img placeholder"/></td>
<td>{prod.productName}</td>
<td>{prod.productDescription}</td>
<td>{prod.sku}</td>
<td>{prod.upc}</td>
<td>{prod.price}</td>
<td>{prod.quantity}</td>
</tr>
)
})
return (
<table>
<tbody>
<tr>
<th>image</th>
<th>productName</th>
<th>description</th>
<th>sku</th>
<th>upc</th>
<th>price</th>
<th>quantity</th>
</tr>
{orderProductDetails}
</tbody>
</table>
)
}
export default OrderShowDetails
...@@ -2,4 +2,5 @@ export {default as AccountForm} from './AccountForm' ...@@ -2,4 +2,5 @@ export {default as AccountForm} from './AccountForm'
export {default as LoginForm} from './LoginForm' export {default as LoginForm} from './LoginForm'
export {default as Nav} from './Nav' export {default as Nav} from './Nav'
export {default as OrderDetails} from './OrderDetails' export {default as OrderDetails} from './OrderDetails'
export {default as SignUpForm} from './SignUpForm' export {default as SignUpForm} from './SignUpForm'
\ No newline at end of file export {default as OrderShowDetails} from './OrderShowDetails'
\ No newline at end of file
...@@ -15,3 +15,8 @@ code { ...@@ -15,3 +15,8 @@ code {
* { * {
border: 2px solid orangered; border: 2px solid orangered;
} }
span {
display: flex;
justify-content: space-around;
}
import React from 'react' import React from 'react'
import {OrderDetails} from 'components' import {OrderDetails} from 'components'
import { OrderService } from 'services';
const OrderIndexPage = () => { const OrderIndexPage = () => {
const allOrders = OrderService.allOrders;
const orderDetailsArr = allOrders.map((order: any, idx: any) => {
return <tr key={idx}><OrderDetails
date={order.date}
orderNumber={order.orderNumber}
status="fulfilled"
/></tr>
})
return ( return (
<table> <table>
<tr> <tbody>
<th>sku</th> <tr>
<th>upc</th> <th>order number</th>
<th>productName</th> <th>date</th>
</tr> <th>status</th>
<OrderDetails /> </tr>
<OrderDetails /> {orderDetailsArr}
<OrderDetails /> </tbody>
</table> </table>
) )
......
import React from 'react' import React from 'react'
import { OrderService } from 'services' import { OrderService } from 'services'
import {OrderDetails} from 'components' import {OrderShowDetails} from 'components'
const OrderShowPage = () => { const OrderShowPage = (props: any) => {
const location = parseInt(props.match.params.id)
const orderInfo = OrderService.orderById(location);
console.log(props);
// orderInfo.
// const orderShowDetailsArr = orderInfo
// const [order, setOrder] = React.useState(null) // const [order, setOrder] = React.useState(null)
// React.useEffect(() => { // React.useEffect(() => {
...@@ -16,16 +24,18 @@ const OrderShowPage = () => { ...@@ -16,16 +24,18 @@ const OrderShowPage = () => {
// } // }
// }) // })
return ( return (
<table> <>
<tr> <span>
<th>sku</th> <h3>Order Date: {orderInfo.date}</h3>
<th>upc</th> <h3>Order Number: {orderInfo.orderNumber}</h3>
<th>productName</th> <h3>Order Status: Fulfilled</h3>
</tr> </span>
<OrderDetails />
</table> <OrderShowDetails products={orderInfo.orderItems}/>
</>
) )
} }
......
...@@ -4,14 +4,19 @@ import orderData from './mock-order-data.json' ...@@ -4,14 +4,19 @@ import orderData from './mock-order-data.json'
// sku: number // sku: number
// } // }
export const allOrders = () => new Promise((res, rej) => { // export const allOrders = () => new Promise((res, rej) => {
setTimeout(() => { res(orderData) }, 2000) // setTimeout(() => { res(orderData) }, 2000)
}); // });
export const orderById = () => new Promise((res, rej) => { export const allOrders = orderData;
setTimeout(() => { res(orderData[0]) }, 2000)
})
// export const orderById = () => new Promise((res, rej) => {
// setTimeout(() => { res(orderData[0]) }, 2000)
// })
export const orderById = (idx: any) => {
return orderData[idx];
}
export default { export default {
......
[ [
{ {
"_id": "x588s78xvhs", "date": "01/01/01",
"sku": "2192649", "orderNumber": "0",
"upc": "221481649", "orderItems": [
"productName": "Apex One", {
"productDescription": "Janky", "_id": "x588s78xvhs",
"price": 5500.50, "sku": "2192649",
"stock": 9, "upc": "221481649",
"productImageUrl": "https://picsum.photos/300/300", "productName": "Apex One",
"brand": "Apex", "productDescription": "Janky",
"category": "Security" "price": 5500.50,
"quantity": 9,
"productImageUrl": "https://picsum.photos/100/100",
"brand": "Apex",
"category": "Security"
},
{
"_id": "akldfgjaf",
"sku": "111111",
"upc": "222333",
"productName": "1 Liter",
"productDescription": "Water bottle",
"price": 500000.50,
"quantity": 30,
"productImageUrl": "https://picsum.photos/100/100",
"brand": "Nalgene",
"category": "Hydration"
}
]
},
{
"date": "01/02/03",
"orderNumber": "1",
"orderItems": [
{
"_id": "apsdifua",
"sku": "333444",
"upc": "0101010101",
"productName": "Passport",
"productDescription": "US Passport (fake)",
"price": 5500.50,
"quantity": 9,
"productImageUrl": "https://picsum.photos/100/100",
"brand": "USAUSAUSA",
"category": "Security"
},
{
"_id": "poadsfs",
"sku": "55556666",
"upc": "3636363636",
"productName": "Octopus",
"productDescription": "glass octopus paper weight",
"price": 500000.50,
"quantity": 30,
"productImageUrl": "https://picsum.photos/100/100",
"brand": "Glass",
"category": "paper weights"
}
]
} }
]
\ 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