fix bug preventing adding scenario comparison

This commit is contained in:
Khalim Conn-Kowlessar 2024-08-05 16:42:25 +01:00
parent bd3a141e2b
commit 92bd82a0d5
3 changed files with 9 additions and 3 deletions

View file

@ -12,7 +12,9 @@ const SelectComparisonModal = ({
scenarios: { name: string | null; id: bigint }[];
onAddColumn: (columnName: string) => void;
}) => {
const [selectedScenario, setSelectedScenario] = useState("");
const [selectedScenario, setSelectedScenario] = useState(() => {
return scenarios && scenarios.length > 0 ? scenarios[0].id.toString() : "";
});
const addColumn = () => {
onAddColumn(selectedScenario);

View file

@ -32,6 +32,8 @@ export async function getComparsionOverviewScenarioData(
next: { revalidate: 60 },
});
if (!response.ok) {
// Print the error
console.error(response.statusText);
throw new Error("Network response was not ok");
}
return response.json();
@ -180,7 +182,9 @@ const SummaryTable = ({
isOpen={isModalOpen}
setIsOpen={setIsModalOpen}
scenarios={scenarios}
onAddColumn={(id: string) => setSelectedScenarioId(id)}
onAddColumn={(id: string) => {
setSelectedScenarioId(id);
}}
/>
<div className="overflow-x-auto shadow-md sm:rounded-lg">

View file

@ -27,7 +27,7 @@ function PlanCard({
<EpcCard
epcRating={expectedEpcRating}
fullMargin={true}
expected={isDefault}
expected={true}
/>
</div>
<div className="flex-grow pl-4 flex flex-col justify-between">