So i'm currently making a receipt for my POS app.
I currently have stored an array in my database as: mongodb collection
And I want to map them to a receipt page
function renderTable(orderlist) {
return (
<tr className='service'>
<td className='tableitem'>
<p className='itemtext'>{orderlist.name}</p>
</td>
<td className='tableitem'>
<p className='itemtext'>{orderlist.qty}</p>
</td>
<td className='tableitem'>
<p className='itemtext'>{orderlist.subtotal}</p>
</td>
</tr>
);
}
const showReceipt = ({
values,
errors,
touched,
handleChange,
handleSubmit,
isSubmitting,
}) => {
return (
<div id='bot'>
<div id='table'>
<table>
<tbody>
<tr className='tabletitle'>
<td className='item'>
<h2>Item</h2>
</td>
<td className='Hours'>
<h2>Qty</h2>
</td>
</tr>
{values.order_list.map((orders) => {
renderTable(orders.order_list);
})}
<tr className='tabletitle'>
<td />
<td className='Rate'>
<h2>tax</h2>
</td>
<td className='payment'>
<h2>$419.25</h2>
</td>
</tr>
<tr className='tabletitle'>
<td />
<td className='Rate'>
<h2>Total</h2>
</td>
<td className='payment'>
<h2>{values.total}</h2>
</td>
</tr>
</tbody>
</table>
</div>
<div id='legalcopy'>
{/* <p className='legal'>
<strong>Thank you for your business!</strong> Payment is
expected within 31 days; please process this invoice within that
time. There will be a 5% interest charge per month on late invoices.
</p> */}
</div>
</div>
);
And it is currently showing me this error:
TypeError: Cannot read property 'map' of undefined
I can't for some reason map this one particular object.
I can, however, Return them as string with : JSON.Stringify(orderlist)
I can also log the object in console
For whatever reason I just can't map them. I want the function to return a row for each Order_list content