Couple daily can and spend limits via usual can size
Link daily caps through the user's chosen standard can size (250/355/473ml) and built-in prices. Onboarding asks for size and can ceiling with derived spend preview. Settings syncs cans and spend bidirectionally. Forecast lock button sets both limits together. Co-authored-by: nh9961 <hello@nedhalksworth.com>
This commit is contained in:
@@ -94,6 +94,7 @@ import { createExcelExport, downloadBlob, parseExcelImport } from "./lib/excel";
|
||||
import {
|
||||
caffeineFor,
|
||||
caffeinePerCan,
|
||||
canLimitFromSpend,
|
||||
currency,
|
||||
currentStreak,
|
||||
daysSinceLast,
|
||||
@@ -656,6 +657,7 @@ function App() {
|
||||
onThemeChange={setThemeId}
|
||||
onSave={saveOnboarding}
|
||||
onClose={() => setSetupOpen(false)}
|
||||
initialLimits={userLimits}
|
||||
/>
|
||||
)}
|
||||
<input
|
||||
@@ -1753,9 +1755,12 @@ function SpendForecastCard({
|
||||
const saveLowerLimit = () => {
|
||||
if (!onSaveLimits) return;
|
||||
const lowerDailyLimit = Math.round(stats.avgDailySpend * 0.8 * 100) / 100;
|
||||
const size = userLimits.limitCanSizeMl ?? 250;
|
||||
onSaveLimits({
|
||||
...userLimits,
|
||||
limitCanSizeMl: size,
|
||||
dailySpendLimit: lowerDailyLimit,
|
||||
dailyCanLimit: canLimitFromSpend(lowerDailyLimit, size),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user