Kantongku: fix - saldo 0 = nyawa 0% kritis
This commit is contained in:
@@ -192,22 +192,31 @@ export function DashboardScreen() {
|
||||
|
||||
// Nyawa keuangan (health bar)
|
||||
const hpPct =
|
||||
avgDailyExpense > 0
|
||||
balance <= 0
|
||||
? 0
|
||||
: avgDailyExpense > 0
|
||||
? Math.min(100, Math.round(((coverageDays ?? 0) / remainingDays) * 100))
|
||||
: 100;
|
||||
let hpStatus = 'SEHAT';
|
||||
let hpColor = '#16A34A';
|
||||
let hpBarColor = '#22C55E';
|
||||
let hpMsg =
|
||||
avgDailyExpense > 0
|
||||
? `Nyawa aman — saldo cukup ${coverageDays} hari (sisa ${remainingDays}) 🛡️`
|
||||
: 'Belum ada pengeluaran bulan ini — nyawa penuh! 😎';
|
||||
if (avgDailyExpense > 0 && hpPct < 40) {
|
||||
let hpMsg = '';
|
||||
if (balance <= 0) {
|
||||
hpStatus = 'KRITIS';
|
||||
hpColor = '#DC2626';
|
||||
hpBarColor = '#EF4444';
|
||||
hpMsg = 'Saldo kosong! Catat pemasukan sekarang 🚨';
|
||||
} else if (avgDailyExpense > 0) {
|
||||
hpMsg = `Nyawa aman — saldo cukup ${coverageDays} hari (sisa ${remainingDays}) 🛡️`;
|
||||
} else {
|
||||
hpMsg = 'Belum ada pengeluaran bulan ini — nyawa penuh! 😎';
|
||||
}
|
||||
if (balance > 0 && avgDailyExpense > 0 && hpPct < 40) {
|
||||
hpStatus = 'KRITIS';
|
||||
hpColor = '#DC2626';
|
||||
hpBarColor = '#EF4444';
|
||||
hpMsg = `Saldo cukup ${coverageDays} dari ${remainingDays} hari — kurangi belanja! 🚨`;
|
||||
} else if (avgDailyExpense > 0 && hpPct < 75) {
|
||||
} else if (balance > 0 && avgDailyExpense > 0 && hpPct < 75) {
|
||||
hpStatus = 'WASPADA';
|
||||
hpColor = '#D97706';
|
||||
hpBarColor = '#F59E0B';
|
||||
|
||||
Reference in New Issue
Block a user