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