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 { useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Animated,
|
Animated,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Ionicons } from '@expo/vector-icons';
|
|
||||||
import { LinearGradient } from 'expo-linear-gradient';
|
import { LinearGradient } from 'expo-linear-gradient';
|
||||||
import { useFocusEffect, useRoute } from '@react-navigation/native';
|
import { useFocusEffect, useRoute } from '@react-navigation/native';
|
||||||
import type { RouteProp } from '@react-navigation/native';
|
import type { RouteProp } from '@react-navigation/native';
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
View,
|
View,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { colors } from '../theme/colors';
|
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 { TransactionType } from '../types';
|
||||||
import type { RootStackParamList } from '../navigation';
|
import type { RootStackParamList } from '../navigation';
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ export function DashboardScreen() {
|
|||||||
}, [heartScale]);
|
}, [heartScale]);
|
||||||
|
|
||||||
const [monthExpense, setMonthExpense] = useState(0);
|
const [monthExpense, setMonthExpense] = useState(0);
|
||||||
const [monthIncome, setMonthIncome] = useState(0);
|
|
||||||
const [topCategory, setTopCategory] = useState<{
|
const [topCategory, setTopCategory] = useState<{
|
||||||
categoryName: string;
|
categoryName: string;
|
||||||
categoryIcon: string;
|
categoryIcon: string;
|
||||||
@@ -108,7 +107,6 @@ export function DashboardScreen() {
|
|||||||
setRecent(r);
|
setRecent(r);
|
||||||
setCompare(c);
|
setCompare(c);
|
||||||
setMonthExpense(m.expense);
|
setMonthExpense(m.expense);
|
||||||
setMonthIncome(m.income);
|
|
||||||
setTopCategory(top);
|
setTopCategory(top);
|
||||||
setTopCategoryLast(topLast);
|
setTopCategoryLast(topLast);
|
||||||
setUserName(un ?? '');
|
setUserName(un ?? '');
|
||||||
@@ -166,7 +164,6 @@ export function DashboardScreen() {
|
|||||||
const avgDailyExpense = dayOfMonth > 0 ? monthExpense / dayOfMonth : 0;
|
const avgDailyExpense = dayOfMonth > 0 ? monthExpense / dayOfMonth : 0;
|
||||||
const coverageDays =
|
const coverageDays =
|
||||||
avgDailyExpense > 0 ? Math.floor(balance / avgDailyExpense) : null;
|
avgDailyExpense > 0 ? Math.floor(balance / avgDailyExpense) : null;
|
||||||
const coverageOk = coverageDays !== null && coverageDays >= remainingDays;
|
|
||||||
|
|
||||||
// Tip otomatis dari pola kategori
|
// Tip otomatis dari pola kategori
|
||||||
let tip: string | null = null;
|
let tip: string | null = null;
|
||||||
@@ -188,12 +185,13 @@ export function DashboardScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const hasTodayActivity = today.income > 0 || today.expense > 0;
|
const hasTodayActivity = today.income > 0 || today.expense > 0;
|
||||||
const monthNet = monthIncome - monthExpense;
|
|
||||||
|
|
||||||
// Nyawa keuangan (health bar)
|
// Nyawa keuangan (health bar)
|
||||||
const hpPct =
|
const hpPct =
|
||||||
balance <= 0
|
balance <= 0
|
||||||
? 0
|
? 0
|
||||||
|
: remainingDays <= 0
|
||||||
|
? 100
|
||||||
: avgDailyExpense > 0
|
: avgDailyExpense > 0
|
||||||
? Math.min(100, Math.round(((coverageDays ?? 0) / remainingDays) * 100))
|
? Math.min(100, Math.round(((coverageDays ?? 0) / remainingDays) * 100))
|
||||||
: 100;
|
: 100;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Ionicons } from '@expo/vector-icons';
|
|
||||||
import { LinearGradient } from 'expo-linear-gradient';
|
import { LinearGradient } from 'expo-linear-gradient';
|
||||||
import { useNavigation, useRoute } from '@react-navigation/native';
|
import { useNavigation, useRoute } from '@react-navigation/native';
|
||||||
import type { RouteProp } from '@react-navigation/native';
|
import type { RouteProp } from '@react-navigation/native';
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
View,
|
View,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { colors } from '../theme/colors';
|
import { colors } from '../theme/colors';
|
||||||
import { formatRibuan, formatRupiah } from '../utils/format';
|
import { formatRibuan } from '../utils/format';
|
||||||
import { getCategoryIcon3d } from '../utils/categoryIcons3d';
|
import { getCategoryIcon3d } from '../utils/categoryIcons3d';
|
||||||
import { addRecurring, getCategories } from '../db/repositories';
|
import { addRecurring, getCategories } from '../db/repositories';
|
||||||
import type { Category, TransactionType } from '../types';
|
import type { Category, TransactionType } from '../types';
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
View,
|
View,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { colors } from '../theme/colors';
|
import { colors } from '../theme/colors';
|
||||||
import { formatRibuan, formatRupiah } from '../utils/format';
|
import { formatRibuan } from '../utils/format';
|
||||||
import { addSavingsTarget } from '../db/repositories';
|
import { addSavingsTarget } from '../db/repositories';
|
||||||
|
|
||||||
const EMOJIS = ['🎯', '💼', '🏠', '✈️', '🚗', '💍', '📱', '💻', '🎮', '🐷', '🛡️', '🎁'];
|
const EMOJIS = ['🎯', '💼', '🏠', '✈️', '🚗', '💍', '📱', '💻', '🎮', '🐷', '🛡️', '🎁'];
|
||||||
|
|||||||
Reference in New Issue
Block a user