Kantongku: audit - bersihkan unused + fix division-by-zero nyawa di akhir bulan

This commit is contained in:
Bro
2026-08-16 20:59:51 +07:00
parent 35e2f5a0df
commit def45e9e5b
7 changed files with 5 additions and 10 deletions
-1
View File
@@ -1,4 +1,3 @@
import { Ionicons } from '@expo/vector-icons';
import { useRef, useState } from 'react';
import {
Animated,
-1
View File
@@ -1,4 +1,3 @@
import { Ionicons } from '@expo/vector-icons';
import { LinearGradient } from 'expo-linear-gradient';
import { useFocusEffect, useRoute } from '@react-navigation/native';
import type { RouteProp } from '@react-navigation/native';
+1 -1
View File
@@ -13,7 +13,7 @@ import {
View,
} from 'react-native';
import { colors } from '../theme/colors';
import { addCategory, getCategories, updateCategory } from '../db/repositories';
import { addCategory, updateCategory } from '../db/repositories';
import type { TransactionType } from '../types';
import type { RootStackParamList } from '../navigation';
+2 -4
View File
@@ -75,7 +75,6 @@ export function DashboardScreen() {
}, [heartScale]);
const [monthExpense, setMonthExpense] = useState(0);
const [monthIncome, setMonthIncome] = useState(0);
const [topCategory, setTopCategory] = useState<{
categoryName: string;
categoryIcon: string;
@@ -108,7 +107,6 @@ export function DashboardScreen() {
setRecent(r);
setCompare(c);
setMonthExpense(m.expense);
setMonthIncome(m.income);
setTopCategory(top);
setTopCategoryLast(topLast);
setUserName(un ?? '');
@@ -166,7 +164,6 @@ export function DashboardScreen() {
const avgDailyExpense = dayOfMonth > 0 ? monthExpense / dayOfMonth : 0;
const coverageDays =
avgDailyExpense > 0 ? Math.floor(balance / avgDailyExpense) : null;
const coverageOk = coverageDays !== null && coverageDays >= remainingDays;
// Tip otomatis dari pola kategori
let tip: string | null = null;
@@ -188,12 +185,13 @@ export function DashboardScreen() {
}
const hasTodayActivity = today.income > 0 || today.expense > 0;
const monthNet = monthIncome - monthExpense;
// Nyawa keuangan (health bar)
const hpPct =
balance <= 0
? 0
: remainingDays <= 0
? 100
: avgDailyExpense > 0
? Math.min(100, Math.round(((coverageDays ?? 0) / remainingDays) * 100))
: 100;
-1
View File
@@ -1,4 +1,3 @@
import { Ionicons } from '@expo/vector-icons';
import { LinearGradient } from 'expo-linear-gradient';
import { useNavigation, useRoute } from '@react-navigation/native';
import type { RouteProp } from '@react-navigation/native';
+1 -1
View File
@@ -15,7 +15,7 @@ import {
View,
} from 'react-native';
import { colors } from '../theme/colors';
import { formatRibuan, formatRupiah } from '../utils/format';
import { formatRibuan } from '../utils/format';
import { getCategoryIcon3d } from '../utils/categoryIcons3d';
import { addRecurring, getCategories } from '../db/repositories';
import type { Category, TransactionType } from '../types';
+1 -1
View File
@@ -12,7 +12,7 @@ import {
View,
} from 'react-native';
import { colors } from '../theme/colors';
import { formatRibuan, formatRupiah } from '../utils/format';
import { formatRibuan } from '../utils/format';
import { addSavingsTarget } from '../db/repositories';
const EMOJIS = ['🎯', '💼', '🏠', '✈️', '🚗', '💍', '📱', '💻', '🎮', '🐷', '🛡️', '🎁'];