mirror of
https://github.com/Zproger/Aurum.git
synced 2026-10-13 11:06:40 +07:00
Aurum — a self-hosted personal finance operating system: cash flow, net worth tracking, budgets, goals, recurring payments, reports, proactive alerts, and a compound-interest returns calculator, all bilingual (RU/EN) and mobile-first. Ships as a three-container Docker Compose stack (Postgres + FastAPI + nginx-served React frontend). See README.md for setup and CONTRIBUTING.md for development.
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { useState } from "react";
|
|
import { RoiCalculatorCard } from "@/components/roi/RoiCalculatorCard";
|
|
import { RoiProjectionCard } from "@/components/roi/RoiProjectionCard";
|
|
|
|
export function RoiPage() {
|
|
const [investment, setInvestment] = useState("");
|
|
const [monthlyIncome, setMonthlyIncome] = useState("");
|
|
|
|
const investmentAmount = Number(investment);
|
|
const monthlyAmount = Number(monthlyIncome);
|
|
const hasInputs = investment !== "" && monthlyIncome !== "" && investmentAmount > 0;
|
|
|
|
const annualIncome = monthlyAmount * 12;
|
|
const annualRoiPercent = hasInputs ? (annualIncome / investmentAmount) * 100 : null;
|
|
const paybackYears = annualRoiPercent !== null && annualIncome > 0 ? investmentAmount / annualIncome : null;
|
|
|
|
return (
|
|
<div className="space-y-5">
|
|
<RoiCalculatorCard
|
|
investment={investment}
|
|
onInvestmentChange={setInvestment}
|
|
monthlyIncome={monthlyIncome}
|
|
onMonthlyIncomeChange={setMonthlyIncome}
|
|
annualRoiPercent={annualRoiPercent}
|
|
paybackYears={paybackYears}
|
|
/>
|
|
|
|
{annualRoiPercent !== null && (
|
|
<RoiProjectionCard
|
|
investmentAmount={investmentAmount}
|
|
annualIncome={annualIncome}
|
|
annualRoiPercent={annualRoiPercent}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|