Commit cf0319c4 authored by Kevin Kaminski's avatar Kevin Kaminski

[AFP-26] 🚧 Product type working

parent fc2ae2dc
import React from 'react'; import React, { useState, useEffect } from 'react';
import { OrderService } from 'services'; import { OrderService } from 'services';
import { Product } from 'Order'; import { Product } from 'Order';
const OrderShowDetails = (props: any) => { const OrderShowDetails = (props: any) => {
const orderProductDetails = props.products.map((prod: any, idx: any) => { const [products, setProducts] = useState<Product[]>()
useEffect(() => {
setProducts(props.products)
}, [props.products])
if (!products) {
return(<></>)
}
const orderProductDetails = products.map((prod: Product, idx: any) => {
return ( return (
<tr key={idx}> <tr key={idx}>
<td><img src={prod.productImageUrl} alt="img placeholder"/></td> <td><img src={prod.productImageUrl} alt="img placeholder"/></td>
......
import React, {useState, useEffect} from 'react'; import React, {useState, useEffect} from 'react';
import { OrderService } from 'services'; import { OrderService } from 'services';
import {OrderShowDetails} from 'components'; import {OrderShowDetails} from 'components';
import { Order } from 'Order'; import { Order, Product } from 'Order';
const OrderShowPage = (props: any) => { const OrderShowPage = (props: any) => {
const location = parseInt(props.match.params.id); const location = parseInt(props.match.params.id);
const [order, setOrder] = useState<Order>(); const [order, setOrder] = useState<Order>();
const [products, setProducts] = useState<Product[]>()
useEffect(() => { useEffect(() => {
OrderService.orderById(location).then((res: any) => { OrderService.orderById(location).then((res: any) => {
setOrder(res); setOrder(res);
setProducts(res.orderItems);
}) })
}) })
...@@ -24,7 +26,7 @@ const OrderShowPage = (props: any) => { ...@@ -24,7 +26,7 @@ const OrderShowPage = (props: any) => {
<h3>Order Status: Fulfilled</h3> <h3>Order Status: Fulfilled</h3>
</span> </span>
<OrderShowDetails products={order.orderItems}/> <OrderShowDetails products={products}/>
</> </>
) )
} }
......
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