Change savings tracking from daily to weekly units for more accurate calculations
This commit is contained in:
parent
2491c79b0a
commit
94a4f3adfd
@ -163,10 +163,10 @@ export function SavingsSetupDialog({
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Units Per Day */}
|
||||
{/* Units Per Week */}
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="unitsPerDay">
|
||||
Packs/units per day (before quitting)
|
||||
Packs/vapes per week (before quitting)
|
||||
</Label>
|
||||
<Input
|
||||
id="unitsPerDay"
|
||||
@ -178,7 +178,7 @@ export function SavingsSetupDialog({
|
||||
placeholder="1"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
How many packs/units did you typically use per day?
|
||||
How many packs/vapes did you typically use per week?
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@ -186,7 +186,7 @@ export function SavingsSetupDialog({
|
||||
<div className="pt-4 border-t space-y-4">
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<Target className="h-4 w-4" />
|
||||
<span>Optional: Set a savings goal</span>
|
||||
<span>See your real time savings:</span>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
|
||||
@ -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]);
|
||||
|
||||
|
||||
@ -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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user