From def45e9e5bf25d8704fc3d91f21e34b9f24bccd9 Mon Sep 17 00:00:00 2001 From: Bro Date: Sun, 16 Aug 2026 20:59:51 +0700 Subject: [PATCH] Kantongku: audit - bersihkan unused + fix division-by-zero nyawa di akhir bulan --- src/components/SwipeableRow.tsx | 1 - src/screens/AddTransactionScreen.tsx | 1 - src/screens/CategoryFormScreen.tsx | 2 +- src/screens/DashboardScreen.tsx | 6 ++---- src/screens/EditTransactionScreen.tsx | 1 - src/screens/RecurringFormScreen.tsx | 2 +- src/screens/TargetFormScreen.tsx | 2 +- 7 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/components/SwipeableRow.tsx b/src/components/SwipeableRow.tsx index b5d1a59..4ef686b 100644 --- a/src/components/SwipeableRow.tsx +++ b/src/components/SwipeableRow.tsx @@ -1,4 +1,3 @@ -import { Ionicons } from '@expo/vector-icons'; import { useRef, useState } from 'react'; import { Animated, diff --git a/src/screens/AddTransactionScreen.tsx b/src/screens/AddTransactionScreen.tsx index b354ea7..e25ed1f 100644 --- a/src/screens/AddTransactionScreen.tsx +++ b/src/screens/AddTransactionScreen.tsx @@ -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'; diff --git a/src/screens/CategoryFormScreen.tsx b/src/screens/CategoryFormScreen.tsx index 5f33c2e..ed028be 100644 --- a/src/screens/CategoryFormScreen.tsx +++ b/src/screens/CategoryFormScreen.tsx @@ -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'; diff --git a/src/screens/DashboardScreen.tsx b/src/screens/DashboardScreen.tsx index e907209..44f9631 100644 --- a/src/screens/DashboardScreen.tsx +++ b/src/screens/DashboardScreen.tsx @@ -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; diff --git a/src/screens/EditTransactionScreen.tsx b/src/screens/EditTransactionScreen.tsx index 0e8f171..18e5825 100644 --- a/src/screens/EditTransactionScreen.tsx +++ b/src/screens/EditTransactionScreen.tsx @@ -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'; diff --git a/src/screens/RecurringFormScreen.tsx b/src/screens/RecurringFormScreen.tsx index 0511b9f..119d6bf 100644 --- a/src/screens/RecurringFormScreen.tsx +++ b/src/screens/RecurringFormScreen.tsx @@ -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'; diff --git a/src/screens/TargetFormScreen.tsx b/src/screens/TargetFormScreen.tsx index 8f2e485..e46d7f2 100644 --- a/src/screens/TargetFormScreen.tsx +++ b/src/screens/TargetFormScreen.tsx @@ -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 = ['🎯', '💼', '🏠', '✈️', '🚗', '💍', '📱', '💻', '🎮', '🐷', '🛡️', '🎁'];