import { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { api } from "../api";
import { useSettings } from "../settings";
import { useConfirm } from "../confirm";
import { useToast } from "../toast";
import Icon from "../components/Icon";
import IconChip from "../components/IconChip";
import Modal from "../components/Modal";
import EditableAmount from "../components/EditableAmount";
import { formatMoney, formatMonthLabel } from "../format";
function ProgressBar({ actual, planned }) {
const pct = planned > 0 ? Math.min(actual / planned, 1) * 100 : actual > 0 ? 100 : 0;
const over = actual > planned;
return (
{formatMonthLabel(v.label, locale)}
{v.customized && (
)}
{v.income.length > 0 && (
{t("budget.income")}
= totv.planned_income ? "pos" : "neg"}`}>{fmt(totv.received_income)}
/ {fmt(totv.planned_income)}
)}
{v.groups.map((g) => (
{g.name}
{fmt(g.actual_cents)}
/ {fmt(g.planned_cents)}
{g.categories.map((c) => (
{c.name}
{fmt(c.actual_cents)}
saveMonth(v.label, c.category_id, cents)} />
))}
))}
{t("budget.totalExpense")}
totv.planned_expense ? "neg" : ""}`}>{fmt(totv.actual_expense)}
/ {fmt(totv.planned_expense)}
);
}
if (!views) return
{t("budget.title")}
{mode === "month" ? (
<>
{rangeTitle}
{t("budget.monthsShown")}
{[1, 2, 3].map((n) => (
))}
{views.map((v) => )}
>
) : (
<>
{t("budget.templateHint")}
{t("budget.expenses")}
{expenseGroups.map((g) => (
{g.name}
{g.categories.map((c) => (
{c.name}
saveTemplate(c.id, cents)} />
))}
))}
{t("budget.income")}
{template.income.length === 0 ? (
{t("budget.noIncome")}
) : (
{template.income.map((i) => (
| {i.label} |
{formatMoney(i.planned_cents, base)} |
|
))}
)}
>
)}
{incomeModal && (
setIncomeModal(null)}
footer={
<>
>
}
>
)}
);
}