Skip to content

Commit

Permalink
Add button to download regulated half hitas housing company report
Browse files Browse the repository at this point in the history
  • Loading branch information
indigane committed May 31, 2024
1 parent 7a32509 commit 286d8c7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
3 changes: 3 additions & 0 deletions frontend/src/common/services/hitasApi/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export const downloadSalesByPostalCodeAndAreaReportPDF = ({
export const downloadRegulatedHousingCompaniesPDF = () =>
fetchAndDownloadPDF("/reports/download-regulated-housing-companies-report");

export const downloadRegulatedHalfHitasHousingCompaniesExcel = () =>
fetchAndDownloadPDF("/reports/download-regulated-half-hitas-housing-companies-report");

export const downloadUnregulatedHousingCompaniesPDF = () =>
fetchAndDownloadPDF("/reports/download-unregulated-housing-companies-report");

Expand Down
5 changes: 4 additions & 1 deletion frontend/src/common/services/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export const fetchAndDownloadPDF = (url: string, method: "GET" | "POST" = "GET",
}
})
// eslint-disable-next-line no-console
.catch((error) => console.error(error));
.catch((error) => {
console.error(error);

Check warning on line 58 in frontend/src/common/services/utils.ts

View workflow job for this annotation

GitHub Actions / Frontend checks

Unexpected console statement
hdsToast.error(`Virhe ladattaessa tiedostoa. (${error?.message ?? error})`);
});
};

export const safeInvalidate = (error, tags) => (!error ? tags : []);
3 changes: 3 additions & 0 deletions frontend/src/features/reports/ReportsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Accordion} from "hds-react";
import {Divider, Heading} from "../../common/components";
import {
HousingCompanyReportRegulated,
HousingCompanyReportRegulatedHalfHitas,
HousingCompanyReportReleased,
HousingCompanyStatusTable,
} from "./components/HousingCompanyReports";
Expand Down Expand Up @@ -34,6 +35,8 @@ const ReportsPage = () => {
<Divider size="s" />
<HousingCompanyReportRegulated />
<Divider size="s" />
<HousingCompanyReportRegulatedHalfHitas />
<Divider size="s" />
<HousingCompanyReportReleased />
</Accordion>

Expand Down
18 changes: 18 additions & 0 deletions frontend/src/features/reports/components/HousingCompanyReports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {DownloadButton, Heading, QueryStateHandler} from "../../../common/compon
import {IHousingCompanyState} from "../../../common/schemas";
import {
downloadHousingCompanyStatesReportPDF,
downloadRegulatedHalfHitasHousingCompaniesExcel,
downloadRegulatedHousingCompaniesPDF,
downloadUnregulatedHousingCompaniesPDF,
useGetHousingCompanyStatesQuery,
Expand Down Expand Up @@ -70,6 +71,23 @@ export const HousingCompanyReportRegulated = () => {
);
};

export const HousingCompanyReportRegulatedHalfHitas = () => {
return (
<div className="report-container">
<div className="column">
<Heading type="sub">Säännellyt Puolihitas-yhtiöt</Heading>
<span>Listaus sääntelyn piirissä olevista Puolihitas-taloyhtiöistä</span>
<div>
<DownloadButton
buttonText="Lataa raportti"
onClick={downloadRegulatedHalfHitasHousingCompaniesExcel}
/>
</div>
</div>
</div>
);
};

export const HousingCompanyReportReleased = () => {
return (
<div className="report-container">
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/features/reports/components/OwnerReports.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DownloadButton, Heading} from "../../../common/components";
import {Divider, DownloadButton, Heading} from "../../../common/components";
import {downloadMultipleOwnershipsReportPDF, downloadRegulatedOwnershipsReportExcel} from "../../../common/services";

const OwnerReports = () => {
Expand All @@ -19,6 +19,7 @@ const OwnerReports = () => {
</div>
</div>
</div>
<Divider size="s" />
<div className="report-container">
<div className="column">
<Heading type="sub">Sääntelyn piirissä olevien Hitas-asuntojen omistajat</Heading>
Expand Down

0 comments on commit 286d8c7

Please sign in to comment.