From d0775796c5e7b917268daa60ddf8766c21bedd03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Filip=20Ma=C4=8Dina?=
<71822287+Maci7772@users.noreply.github.com>
Date: Mon, 6 May 2024 23:50:19 +0200
Subject: [PATCH 1/2] FE - added avg market price
---
.../src/components/reports/IndustryReport.tsx | 56 ++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)
diff --git a/apps/saip-fe/src/components/reports/IndustryReport.tsx b/apps/saip-fe/src/components/reports/IndustryReport.tsx
index 046d859..74f3457 100644
--- a/apps/saip-fe/src/components/reports/IndustryReport.tsx
+++ b/apps/saip-fe/src/components/reports/IndustryReport.tsx
@@ -138,7 +138,7 @@ function IndustryReport() {
- |
+ |
Spoločnosť |
Hodnota jednej akcie
@@ -172,6 +172,60 @@ function IndustryReport() {
|
))}
+ {/* Add row for average stock price */}
+
+
+ Priemer
+ |
+ |
+
+ {/* Calculate and display average stock price */}
+ {data && (
+
+ {numberWithSpaces(
+ (
+ Object.values(data.industry).reduce(
+ (acc, curr) => acc + curr.stock_price,
+ 0,
+ ) / Object.keys(data.industry).length
+ ).toFixed(2),
+ )}{" "}
+ €
+
+ )}
+ |
+
+ {/* Calculate and display average net profit */}
+ {data && (
+
+ {numberWithSpaces(
+ (
+ Object.values(data.industry).reduce(
+ (acc, curr) => acc + curr.net_profit,
+ 0,
+ ) / Object.keys(data.industry).length
+ ).toFixed(2),
+ )}{" "}
+ €
+
+ )}
+ |
+
+ {/* Calculate and display average sell price */}
+ {data && (
+
+ {numberWithSpaces(
+ Object.values(data.industry).reduce(
+ (acc, curr) => acc + curr.sell_price,
+ 0,
+ ) / Object.keys(data.industry).length,
+ )}{" "}
+ €/ks
+
+ )}
+ |
+ |
+
From 416c2352e2a8de0846d479cfe80362473e84ad52 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Filip=20Ma=C4=8Dina?=
<71822287+Maci7772@users.noreply.github.com>
Date: Mon, 6 May 2024 23:56:56 +0200
Subject: [PATCH 2/2] FE - build fix
---
.../src/components/reports/IndustryReport.tsx | 67 +++++++++++--------
1 file changed, 39 insertions(+), 28 deletions(-)
diff --git a/apps/saip-fe/src/components/reports/IndustryReport.tsx b/apps/saip-fe/src/components/reports/IndustryReport.tsx
index 74f3457..032a0c7 100644
--- a/apps/saip-fe/src/components/reports/IndustryReport.tsx
+++ b/apps/saip-fe/src/components/reports/IndustryReport.tsx
@@ -159,37 +159,46 @@ function IndustryReport() {
{index + 1} |
{industry[0]} |
- {numberWithSpaces(industry[1].stock_price)} €
+ {industry[1]?.stock_price &&
+ numberWithSpaces(industry[1]?.stock_price)}{" "}
+ €
|
- {numberWithSpaces(industry[1].net_profit)} €
+ {industry[1]?.net_profit &&
+ numberWithSpaces(industry[1]?.net_profit)}{" "}
+ €
|
- {numberWithSpaces(industry[1].sell_price)} €/ks
+ {industry[1]?.sell_price &&
+ numberWithSpaces(industry[1]?.sell_price)}{" "}
+ €/ks
|
- {numberWithSpaces(industry[1].market_share)} %
+ {industry[1]?.market_share &&
+ numberWithSpaces(industry[1]?.market_share)}{" "}
+ %
|
))}
{/* Add row for average stock price */}
+ |
Priemer
|
- |
{/* Calculate and display average stock price */}
{data && (
- {numberWithSpaces(
- (
- Object.values(data.industry).reduce(
- (acc, curr) => acc + curr.stock_price,
- 0,
- ) / Object.keys(data.industry).length
- ).toFixed(2),
- )}{" "}
+ {data.industry &&
+ numberWithSpaces(
+ (
+ Object.values(data.industry).reduce(
+ (acc, curr) => acc + (curr?.stock_price || 0),
+ 0,
+ ) / Object.keys(data.industry).length
+ ).toFixed(2),
+ )}{" "}
€
)}
@@ -198,14 +207,15 @@ function IndustryReport() {
{/* Calculate and display average net profit */}
{data && (
- {numberWithSpaces(
- (
- Object.values(data.industry).reduce(
- (acc, curr) => acc + curr.net_profit,
- 0,
- ) / Object.keys(data.industry).length
- ).toFixed(2),
- )}{" "}
+ {data.industry &&
+ numberWithSpaces(
+ (
+ Object.values(data.industry).reduce(
+ (acc, curr) => acc + (curr?.net_profit || 0),
+ 0,
+ ) / Object.keys(data.industry).length
+ ).toFixed(2),
+ )}{" "}
€
)}
@@ -214,17 +224,18 @@ function IndustryReport() {
{/* Calculate and display average sell price */}
{data && (
- {numberWithSpaces(
- Object.values(data.industry).reduce(
- (acc, curr) => acc + curr.sell_price,
- 0,
- ) / Object.keys(data.industry).length,
- )}{" "}
+ {data.industry &&
+ numberWithSpaces(
+ Object.values(data.industry).reduce(
+ (acc, curr) => acc + (curr?.sell_price || 0),
+ 0,
+ ) / Object.keys(data.industry).length,
+ )}{" "}
€/ks
)}
|
- |
+ |