aboutsummaryrefslogtreecommitdiff
path: root/src/components/Display/SummaryDisplay.js
blob: 8acddc980737e8aa25c6f53a20386f2965df8f50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from "react";
import "./Display.css";

const getSummary = (items) => {
  let totalRawPrice = 0;
  let totalQuantity = 0;
  for (let i = 0; i < items.length; i++) {
    totalRawPrice += items[i].Price;
    totalQuantity += items[i].Quantity
  }

  return (
    {
      "TotalRawPrice": totalRawPrice,
      "TotalQuantity": totalQuantity
    }
  );
}

const SummaryDisplayTR = (props) => {
  const summary = getSummary(props.items);
  console.log(summary)

  return (
    <tr>
      <td>Total</td>
      <td className={"altBorder"}></td>
      <td className={"altBorder"}></td>
      <td>{summary.TotalQuantity}</td>
      <td>{summary.TotalRawPrice}</td>
      <td className={"altBorder"}></td>
      <td className={"altBorder"}></td>
    </tr>
  );
}

export default SummaryDisplayTR;