diff --git a/components/stats/BudgetRemaining.tsx b/components/stats/BudgetRemaining.tsx index d5209fd..98a5cf0 100644 --- a/components/stats/BudgetRemaining.tsx +++ b/components/stats/BudgetRemaining.tsx @@ -5,15 +5,33 @@ import useFetch from '../../hooks/useFetch'; import { CategoryType } from '../../services/database'; const styles = StyleSheet.create({ + container: { + margin: 10, + borderRadius: 5, + alignItems: 'center', + justifyContent: 'center' + }, text: { fontSize: 26, }, boldText: { - fontWeight: 'bold', + fontWeight: 'bold' + }, + negativeText: { + color: 'red', + }, + positiveText: { + color: 'green', }, }); -const BudgetRemaining = () => { + +interface BudgetRemainingProps { + goodColor?: string; + badColor?: string; +} + +const BudgetRemaining: React.FC = ({ goodColor = 'green', badColor = 'red' }) => { const { colors } = useTheme(); const [spent, setSpent] = useState(0); const [budget, setBudget] = useState(0); @@ -47,10 +65,18 @@ const BudgetRemaining = () => { } return ( - - You have {remaining.toFixed(2)}€ left. + + {remaining >= 0 ? ( + <> + Your remaining Budget is {remaining.toFixed(2)}€. + + ) : ( + <> + Your Budget is overspent by by -{Math.abs(remaining).toFixed(2)}€. + + )} - ); + ); }; export default BudgetRemaining;