formatting co2 titles in summary page

This commit is contained in:
Khalim Conn-Kowlessar 2024-08-13 16:49:38 +01:00
parent 295d7abaff
commit fd6be9a790
3 changed files with 19 additions and 4 deletions

View file

@ -74,7 +74,7 @@ export async function GET(
],
},
{
title: "Co2/unit",
title: "CO2/unit",
scenarios: [
{
scenarioName: scenarioName,

View file

@ -18,7 +18,7 @@ import {
import SelectComparisonModal from "./SelectComparisonModal";
import EpcBarChart from "./EpcBarChart";
import { DataItem, ChartData } from "@/app/portfolio/[slug]/utils";
import { QueryKey, UseQueryOptions, useQuery } from "@tanstack/react-query";
import { UseQueryOptions, useQuery } from "@tanstack/react-query";
export async function getComparsionOverviewScenarioData(
scenarioId: string
@ -64,6 +64,18 @@ const shouldHighlightRow = (title: string) => {
].includes(title);
};
const formatCo2Title = (content: any) => {
if (content === "CO2/unit") {
return "CO₂/unit";
}
if (content === "£ per CO2 reduction") {
return "£ per CO₂ reduction";
}
return content;
};
const SummaryTable = ({
data,
scenarios,
@ -215,7 +227,10 @@ const SummaryTable = ({
>
{row.getVisibleCells().map((cell) => (
<TableCell key={cell.id} className="px-6 py-4">
{flexRender(cell.column.columnDef.cell, cell.getContext())}
{flexRender(cell.column.columnDef.cell, {
...cell.getContext(),
getValue: () => formatCo2Title(cell.getValue()),
})}
</TableCell>
))}
</TableRow>

View file

@ -186,7 +186,7 @@ export async function getOverviewPortfolioData(
],
},
{
title: "Co2/unit",
title: "CO2/unit",
scenarios: [
{ scenarioName: "Today", data: data[0].co2PerUnitPreRetrofit || "" },
{