Skip to content

Commit

Permalink
Merge pull request #289 from fiit-tp-tim20/main
Browse files Browse the repository at this point in the history
avg_market_price
  • Loading branch information
Maci7772 authored May 6, 2024
2 parents 4396437 + 2ee5119 commit f7250c8
Showing 1 changed file with 70 additions and 5 deletions.
75 changes: 70 additions & 5 deletions apps/saip-fe/src/components/reports/IndustryReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function IndustryReport() {
<table className="table-auto table-white">
<thead>
<tr>
<th className="px-4 py-2 text-left table-header"> </th>
<th className="px-4 py-2 text-left table-header" />
<th className="px-4 py-2 text-left table-header text-white">Spoločnosť</th>
<th className="px-4 py-2 text-left table-header text-white">
Hodnota jednej akcie
Expand All @@ -159,19 +159,84 @@ function IndustryReport() {
<td className="px-4 py-2">{index + 1}</td>
<td className="px-4 py-2">{industry[0]}</td>
<td className="px-4 py-2">
{numberWithSpaces(industry[1].stock_price)}
{industry[1]?.stock_price &&
numberWithSpaces(industry[1]?.stock_price)}{" "}
</td>
<td className="px-4 py-2">
{numberWithSpaces(industry[1].net_profit)}
{industry[1]?.net_profit &&
numberWithSpaces(industry[1]?.net_profit)}{" "}
</td>
<td className="px-4 py-2">
{numberWithSpaces(industry[1].sell_price)} €/ks
{industry[1]?.sell_price &&
numberWithSpaces(industry[1]?.sell_price)}{" "}
€/ks
</td>
<td className="px-4 py-2">
{numberWithSpaces(industry[1].market_share)} %
{industry[1]?.market_share &&
numberWithSpaces(industry[1]?.market_share)}{" "}
%
</td>
</tr>
))}
{/* Add row for average stock price */}
<tr>
<td className="px-4 py-2" />
<td className="px-4 py-2">
<b>Priemer</b>
</td>
<td className="px-4 py-2">
{/* Calculate and display average stock price */}
{data && (
<b>
{data.industry &&
numberWithSpaces(
(
Object.values(data.industry).reduce(
(acc, curr) => acc + (curr?.stock_price || 0),
0,
) / Object.keys(data.industry).length
).toFixed(2),
)}{" "}
</b>
)}
</td>
<td className="px-4 py-2">
{/* Calculate and display average net profit */}
{data && (
<b>
{data.industry &&
numberWithSpaces(
(
Object.values(data.industry).reduce(
(acc, curr) => acc + (curr?.net_profit || 0),
0,
) / Object.keys(data.industry).length
).toFixed(2),
)}{" "}
</b>
)}
</td>
<td className="px-4 py-2">
{/* Calculate and display average sell price */}
{data && (
<b>
{data.industry &&
numberWithSpaces(
Object.values(data.industry).reduce(
(acc, curr) => acc + (curr?.sell_price || 0),
0,
) / Object.keys(data.industry).length,
)}{" "}
€/ks
</b>
)}
</td>
<td className="px-4 py-2" />
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit f7250c8

Please sign in to comment.