Kantongku: audit - bersihkan unused + fix division-by-zero nyawa di akhir bulan
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import { useRef, useState } from 'react';
|
||||
import {
|
||||
Animated,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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,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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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 = ['🎯', '💼', '🏠', '✈️', '🚗', '💍', '📱', '💻', '🎮', '🐷', '🛡️', '🎁'];
|
||||
|
||||
Reference in New Issue
Block a user