From 8f49871e6fbfb2672726b4fb889e5470b7259136 Mon Sep 17 00:00:00 2001 From: TCFDONMEZ Date: Fri, 9 Oct 2026 23:56:04 +0300 Subject: [PATCH] fix: handle optional lifetime in consumption page UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lifetime is now optional in DailyConsumption — guard all .lifetime accesses. The Ömür boyu card uses the derived total (sum of days). Co-Authored-By: Claude --- web/src/app/consumption/page.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/src/app/consumption/page.tsx b/web/src/app/consumption/page.tsx index 5e7294f..163546a 100644 --- a/web/src/app/consumption/page.tsx +++ b/web/src/app/consumption/page.tsx @@ -28,7 +28,8 @@ export default async function ConsumptionPage({ const chartDays = days.map((day) => ({ date: day.date, kwh: day.day.kwh, km: day.day.km })); const total = sumDays(days); - const lifetime = days[days.length - 1].lifetime; + // Lifetime is derived: the sum of every day's totals, same as the backend computes. + const lifetime = { km: total.km, kwh: total.kwh, hours: total.hours, socDrop: 0 }; // Newest first for reading; the charts above keep chronological order. const table = [...days].reverse(); @@ -91,7 +92,7 @@ export default async function ConsumptionPage({
- +
) : ( @@ -163,7 +164,7 @@ export default async function ConsumptionPage({ value={day.day.hours > 0 ? `${num(day.day.km / day.day.hours)} km/h` : "—"} /> - +