import React, { useState, useEffect } from 'react'; import { Text, StyleSheet } from 'react-native'; import { useTheme } from '../../app/contexts/ThemeContext'; import useFetch from '../../hooks/useFetch'; import { CategoryType } from '../../services/database'; import {useCategoryData} from '../../hooks/useCategoryData'; const styles = StyleSheet.create({ container: { margin: 10, borderRadius: 5, alignItems: 'center', justifyContent: 'center' }, text: { fontSize: 26, color: `black` }, boldText: { fontWeight: 'bold' }, negativeText: { color: 'red', }, positiveText: { color: 'green', }, }); interface BudgetTotalProps { goodColor?: string; badColor?: string; } const BudgetTotal: React.FC = ({ goodColor = 'green', badColor = 'red' }) => { const { colors } = useTheme(); const { data, isLoading } = useCategoryData(CategoryType.EXPENSE); const { total, expenseTotal } = data; const remaining = total - expenseTotal; if (isLoading) { return Loading...; } return ( <> You have spent {expenseTotal.toFixed(2)}€ out of your Budget of {total.toFixed(2)}€ . ); }; export default BudgetTotal;