@@ -74,6 +74,11 @@ export function DailyAllowance({
7474 const status =
7575 effectiveBudget > thresholds . good ? "good" : effectiveBudget > thresholds . tight ? "tight" : "danger" ;
7676
77+ // Tomorrow's budget if we stop spending now
78+ const daysAfterToday = Math . max ( 1 , daysUntilIncome - 1 ) ;
79+ const tomorrowBudget = Math . max ( 0 , Math . round ( ( dailyBudget * daysUntilIncome - todaySpentAll ) / daysAfterToday ) ) ;
80+ const tomorrowStatus = tomorrowBudget > thresholds . good ? "text-positive" : tomorrowBudget > thresholds . tight ? "text-chart-3" : "text-negative" ;
81+
7782 return (
7883 < div className = "daily-allowance-grid" >
7984 < Card className = "daily-allowance-hero" data-status = { status } >
@@ -119,40 +124,36 @@ export function DailyAllowance({
119124 { locale === "fi" ? "Laskuja " : "Bills " }
120125 < span className = "text-negative" > < F v = { upcomingBills } s = { ` ${ currency } ` } /> </ span >
121126 { ". " }
122- { daysUntilIncome > 0 && `${ mask ( daysUntilIncome ) } ${ t . dashboard . daysUntilNextIncome } .` }
127+ { locale === "fi" ? "Huomenna " : "Tomorrow " }
128+ < span className = { tomorrowStatus } > < F v = { tomorrowBudget } s = { ` ${ currency } ` } /> </ span >
129+ { daysUntilIncome > 0 && ` \u00B7 ${ mask ( daysUntilIncome ) } ${ t . dashboard . daysUntilNextIncome } .` }
123130 </ >
124131 ) : overspent ? (
125132 < >
126133 { locale === "fi" ? "Ylitetty " : "Exceeded by " }
127134 < span className = "text-negative" > < F v = { Math . abs ( todayRemaining ) } s = { ` ${ currency } ` } /> </ span >
128- { locale === "fi" ? " verran. Päiväbudjetti " : ". Daily budget " }
129- < span className = { status === "good" ? "text-positive" : status === "tight" ? "text-chart-3" : "text-negative" } > < F v = { dailyBudget } s = { ` ${ currency } ` } /> </ span >
130- { locale === "fi" ? ", käytetty " : ", spent " }
135+ { locale === "fi" ? " verran. Käytetty " : ". Spent " }
131136 < span className = "text-negative" > < F v = { todaySpentAll } s = { ` ${ currency } ` } /> </ span >
132- { daysUntilIncome > 0 && (
133- < >
134- { ". " }
135- { locale === "fi" ? "Huomisen budjetti noin " : "Tomorrow's budget approx. " }
136- { ( ( ) => {
137- const tomorrowBudget = Math . max ( 0 , Math . round ( dailyBudget - Math . abs ( todayRemaining ) / daysUntilIncome ) ) ;
138- const tStatus = tomorrowBudget > thresholds . good ? "text-positive" : tomorrowBudget > thresholds . tight ? "text-chart-3" : "text-negative" ;
139- return < span className = { tStatus } > < F v = { tomorrowBudget } s = { ` ${ currency } ` } /> </ span > ;
140- } ) ( ) }
141- { ` \u00B7 ${ mask ( daysUntilIncome ) } ${ t . dashboard . daysUntilNextIncome } .` }
142- </ >
143- ) }
137+ { ". " }
138+ { locale === "fi" ? "Huomenna " : "Tomorrow " }
139+ < span className = { tomorrowStatus } > < F v = { tomorrowBudget } s = { ` ${ currency } ` } /> </ span >
140+ { daysUntilIncome > 0 && ` \u00B7 ${ mask ( daysUntilIncome ) } ${ t . dashboard . daysUntilNextIncome } .` }
144141 </ >
145142 ) : todaySpentAll > 0 ? (
146143 < >
147- { locale === "fi" ? "Päiväbudjetti " : "Budget " }
148- < span className = { status === "good" ? "text-positive" : status === "tight" ? "text-chart-3" : "text-negative" } > < F v = { dailyBudget } s = { ` ${ currency } ` } /> </ span >
149- { " \u00B7 " }
150- { locale === "fi" ? "käytetty " : "spent " }
144+ { locale === "fi" ? "Käytetty " : "Spent " }
151145 < span className = "text-negative" > < F v = { todaySpentAll } s = { ` ${ currency } ` } /> </ span >
146+ { ". " }
147+ { locale === "fi" ? "Huomenna " : "Tomorrow " }
148+ < span className = { tomorrowStatus } > < F v = { tomorrowBudget } s = { ` ${ currency } ` } /> </ span >
152149 { daysUntilIncome > 0 && ` \u00B7 ${ daysUntilIncome } ${ t . dashboard . daysUntilNextIncome } ` }
153150 </ >
154151 ) : (
155- `${ mask ( daysUntilIncome ) } ${ t . dashboard . daysUntilNextIncome } `
152+ < >
153+ { locale === "fi" ? "Huomenna " : "Tomorrow " }
154+ < span className = { tomorrowStatus } > < F v = { tomorrowBudget } s = { ` ${ currency } ` } /> </ span >
155+ { daysUntilIncome > 0 && ` \u00B7 ${ mask ( daysUntilIncome ) } ${ t . dashboard . daysUntilNextIncome } ` }
156+ </ >
156157 ) }
157158 { ! billsDelayNeeded && ! overspent && status === "danger" && `. ${ t . dashboard . cutNonEssentials } ` }
158159 { ! billsDelayNeeded && ! overspent && status === "tight" && `. ${ t . dashboard . beCareful } ` }
0 commit comments