import type { FC } from "react";
import {
Alert,
Button,
Group,
MultiSelect,
Progress,
Stack,
Text,
Title,
} from "@mantine/core";
import { DatePickerInput } from "@mantine/dates";
import { StateView } from "@wealthledger/ui";
import { useTranslation } from "react-i18next";
import { LedgerEntryRow } from "@/entities/broker-operation";
import { formatSnapshotTime } from "@/shared/lib";
import type { AccountOperationsPageViewModel } from "../AccountOperationsPage.vm";
import { useAccountOperationsPageLoadedVm } from "./AccountOperationsPageLoaded.vm";
type AccountOperationsPageLoadedProps = Extract<
AccountOperationsPageViewModel,
{ state: "loaded" }
>;
const AccountOperationsPageLoadedOperations: FC<
AccountOperationsPageLoadedProps
> = (props) => { // eslint-disable-line sonarjs/function-return-type -- React renders elements and lists.
const { t } = useTranslation();
const { items } = props;
if (items.length > 0) {
return items.map(operation => (
));
}
if (props.partial) {
return;
}
return ;
};
const AccountOperationsPageLoaded: FC = (
props,
) => {
const {
canApply,
categoryData,
draftCategories,
draftFrom,
draftTo,
hasNext,
hasPrevious,
onApply,
onCategoriesChange,
onNext,
onPeriodChange,
onPrevious,
onReset,
t,
} = useAccountOperationsPageLoadedVm(props);
return (
{!!props.lastSuccessfulAt && (
{t("investment.sourceTime", {
date: formatSnapshotTime(props.lastSuccessfulAt),
})}
)}
{t("ledger.title")}
{!!props.partial && {t("investment.partial")}}
{!!props.historyLoading && {t("investment.history")}}
{!!props.refreshing && }
{!!props.refreshError && (
{t(
props.sourceError
? "investment.syncFailed"
: "accounts.refreshError",
)}
)}
{!!(hasNext || hasPrevious) && (
)}
);
};
export { AccountOperationsPageLoaded };