From 85ecdebe528c092f8a38a0d31e857105b2683699 Mon Sep 17 00:00:00 2001 From: Matej96 Date: Mon, 17 Jun 2024 00:54:48 +0200 Subject: [PATCH 1/2] industry export fix --- apps/saip-fe/src/components/reports/IndustryReport.tsx | 4 ++-- apps/saip-fe/src/i18n/locales/sk/translation.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/saip-fe/src/components/reports/IndustryReport.tsx b/apps/saip-fe/src/components/reports/IndustryReport.tsx index 5fc69bb..f63fff4 100644 --- a/apps/saip-fe/src/components/reports/IndustryReport.tsx +++ b/apps/saip-fe/src/components/reports/IndustryReport.tsx @@ -59,9 +59,9 @@ function IndustryReport() { }; const exportToCSV = () => { - const csvData = [["Spoločnosť", "Hodnota jednej akcie", "Výsledok hospodárenia po zdanení", "Predajná cena", "Podiel na trhu"]]; + const csvData = [[t("dashboard.industry_report.table.company"), t("dashboard.industry_report.table.value"), t("dashboard.industry_report.table.after_tax"), t("dashboard.industry_report.table.price"), t("dashboard.industry_report.table.share"), t("dashboard.industry_report.table.upgrades")]]; data && Object.entries(data.industry).forEach(([company, info]) => { - csvData.push([company, numberWithSpaces(info.stock_price) + " €", numberWithSpaces(info.net_profit) + " €", numberWithSpaces(info.sell_price) + " €/ks", numberWithSpaces(info.market_share) + " %"]); + csvData.push([company, info.stock_price, info.net_profit, info.sell_price, info.market_share, info.finished_upgrades]); }); return csvData; }; diff --git a/apps/saip-fe/src/i18n/locales/sk/translation.json b/apps/saip-fe/src/i18n/locales/sk/translation.json index 009ad92..b3b7edf 100644 --- a/apps/saip-fe/src/i18n/locales/sk/translation.json +++ b/apps/saip-fe/src/i18n/locales/sk/translation.json @@ -154,7 +154,7 @@ "title": "Archív rozhodnutí", "marketing": "Archív marketingu", "prod": "Archív produkcie", - "quantity": "Vyrobené množstvo=", + "quantity": "Vyrobené množstvo", "price": "Predajná cena", "capital": "Investície do kapitálu", "upgrades": "Investície do vylepšení", From 1c84d9782a56d49cb42e4c2ba2c48147cdabc670 Mon Sep 17 00:00:00 2001 From: Matej96 Date: Mon, 17 Jun 2024 02:20:18 +0200 Subject: [PATCH 2/2] archive report export --- .../src/components/reports/ArchiveReport.tsx | 41 +++++++++++++++++++ .../src/components/reports/CompanyReport.tsx | 39 ++++++++++-------- .../src/components/reports/IndustryReport.tsx | 2 +- .../src/i18n/locales/en/translation.json | 3 +- .../src/i18n/locales/sk/translation.json | 4 +- 5 files changed, 67 insertions(+), 22 deletions(-) diff --git a/apps/saip-fe/src/components/reports/ArchiveReport.tsx b/apps/saip-fe/src/components/reports/ArchiveReport.tsx index a77a966..100f820 100644 --- a/apps/saip-fe/src/components/reports/ArchiveReport.tsx +++ b/apps/saip-fe/src/components/reports/ArchiveReport.tsx @@ -7,6 +7,7 @@ import { useTranslation } from "react-i18next"; // @ts-ignore import { MyContext } from "../../api/MyContext"; import getCompanyReport from "../../api/GetCompanyReport"; +import {CSVLink} from "react-csv"; function ArchiveReport() { const { t } = useTranslation(); @@ -38,6 +39,40 @@ function ArchiveReport() { })); }; + const exportMarketingToCSV = () => { + const csvData = [[t("misc.round"), t("marketing.types.tv.title"), t("marketing.types.viral.title"), t("marketing.types.billboards.title"), "OOH", t("marketing.types.podcasts.title")]]; + const keys = Object.keys(data.marketing); + + for (let i = 0; i < data.marketing.tv.length; i++) { + const row: number[] = []; + row.push(i); + for (const key of keys) { + row.push(data.marketing[key][i]); + } + csvData.push(row); + } + + return csvData; + }; + + const exportProductionToCSV = () => { + const csvData = [[t("misc.round"), t("dashboard.decision_archive.quantity"), t("dashboard.decision_archive.price"), t("dashboard.decision_archive.capital"), t("dashboard.decision_archive.upgrades"), t("dashboard.decision_archive.done")]]; + + for (let i = 0; i < data.marketing.tv.length; i++) { + const row: number[] = []; + row.push(i); + row.push(data.production.volume[i]); + row.push(data.production.sell_price[i]); + row.push(data.factory.capital[i]); + row.push(data.factory.upgrades[i]); + row.push(data.factory.upgrade_turn[i]); + + csvData.push(row); + } + + return csvData; + }; + // poradie return (
@@ -93,6 +128,9 @@ function ArchiveReport() {

{t("dashboard.decision_archive.marketing") as string}

+ + {t("dashboard.decision_archive.export_to_csv") as string} +
@@ -130,6 +168,9 @@ function ArchiveReport() {

{t("dashboard.decision_archive.prod") as string}

+ + {t("dashboard.decision_archive.export_to_csv") as string} +
diff --git a/apps/saip-fe/src/components/reports/CompanyReport.tsx b/apps/saip-fe/src/components/reports/CompanyReport.tsx index 0a956ba..a52f85a 100644 --- a/apps/saip-fe/src/components/reports/CompanyReport.tsx +++ b/apps/saip-fe/src/components/reports/CompanyReport.tsx @@ -108,29 +108,32 @@ function CompanyReport() {

{t("dashboard.company_report.title") as string}

-
+
- - +
+ + +
{isLoading ? ( diff --git a/apps/saip-fe/src/components/reports/IndustryReport.tsx b/apps/saip-fe/src/components/reports/IndustryReport.tsx index f63fff4..af7edc3 100644 --- a/apps/saip-fe/src/components/reports/IndustryReport.tsx +++ b/apps/saip-fe/src/components/reports/IndustryReport.tsx @@ -112,7 +112,7 @@ function IndustryReport() {

{t("dashboard.industry_report.ranking") as string}

- Export CSV + {t("dashboard.decision_archive.export_to_csv") as string} {/* Add a button to open the tutorial */}