From 94a4f3adfd748e24c1ba22c9cbde82593c920657 Mon Sep 17 00:00:00 2001
From: Avery Felts
Date: Sat, 24 Jan 2026 12:11:08 -0700
Subject: [PATCH] Change savings tracking from daily to weekly units for more
accurate calculations
---
src/components/SavingsSetupDialog.tsx | 8 ++++----
src/components/SavingsTrackerCard.tsx | 10 ++++++----
src/lib/storage.ts | 5 +++--
3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/src/components/SavingsSetupDialog.tsx b/src/components/SavingsSetupDialog.tsx
index dfbeaac..e797e1f 100644
--- a/src/components/SavingsSetupDialog.tsx
+++ b/src/components/SavingsSetupDialog.tsx
@@ -163,10 +163,10 @@ export function SavingsSetupDialog({
- {/* Units Per Day */}
+ {/* Units Per Week */}
@@ -186,7 +186,7 @@ export function SavingsSetupDialog({
- Optional: Set a savings goal
+ See your real time savings:
diff --git a/src/components/SavingsTrackerCard.tsx b/src/components/SavingsTrackerCard.tsx
index 92f7564..83856d2 100644
--- a/src/components/SavingsTrackerCard.tsx
+++ b/src/components/SavingsTrackerCard.tsx
@@ -34,12 +34,14 @@ export function SavingsTrackerCard({
const projections = useMemo(() => {
if (!savingsConfig) return { daily: 0, weekly: 0, monthly: 0, yearly: 0 };
- const dailySavings = savingsConfig.costPerUnit * savingsConfig.unitsPerDay;
+ // unitsPerDay is now actually unitsPerWeek
+ const weeklySavings = savingsConfig.costPerUnit * savingsConfig.unitsPerDay;
+ const dailySavings = weeklySavings / 7;
return {
daily: dailySavings,
- weekly: dailySavings * 7,
- monthly: dailySavings * 30,
- yearly: dailySavings * 365,
+ weekly: weeklySavings,
+ monthly: weeklySavings * 4.33,
+ yearly: weeklySavings * 52,
};
}, [savingsConfig]);
diff --git a/src/lib/storage.ts b/src/lib/storage.ts
index 7dca2b6..26d43be 100644
--- a/src/lib/storage.ts
+++ b/src/lib/storage.ts
@@ -370,9 +370,10 @@ export function calculateTotalSaved(
if (daysSinceStart <= 0) return 0;
- // Expected spending if they continued at baseline
+ // Expected spending if they continued at baseline (unitsPerDay is now unitsPerWeek)
+ const weeksSinceStart = daysSinceStart / 7;
const expectedSpend =
- daysSinceStart * savingsConfig.costPerUnit * savingsConfig.unitsPerDay;
+ weeksSinceStart * savingsConfig.costPerUnit * savingsConfig.unitsPerDay;
// Actual usage converted to cost (assuming ~20 puffs/hits per unit)
const relevantUsage = usageData.filter(