import type { FC } from "react";
import {
Alert,
Button,
Group,
MultiSelect,
Stack,
Title,
} from "@mantine/core";
import { DatePickerInput } from "@mantine/dates";
import { StateView } from "@wealthledger/ui";
import { useTranslation } from "react-i18next";
import {
brokerageOperationGroupKey,
LedgerEntryRow,
operationCategories,
OperationGroup,
} from "@/entities/broker-operation";
import { groupItems } from "@/shared/lib";
import { SourceSyncStatus } from "@/shared/ui";
import type { AccountOperationsPageViewModel } from "../AccountOperationsPage.vm";
type AccountOperationsPageLoadedProps = Extract<
AccountOperationsPageViewModel,
{ state: "loaded" }
>;
const AccountOperationsPageLoadedOperations: FC<
AccountOperationsPageLoadedProps
> = (props) => {
const { t } = useTranslation();
const { items } = props;
if (items.length > 0) {
const entries = groupItems(
items.map(operation => ({
key: JSON.stringify([
operation.account?.id,
operation.id,
operation.logoName,
]),
operation,
})),
entry => props.allAccounts
? brokerageOperationGroupKey(entry.operation)
: null,
);
return (
{entries.map(entry => entry.type === "group"
? (
)
: (
))}
);
}
if (props.partial) {
return;
}
return ;
};
const AccountOperationsPageLoaded: FC = (
props,
) => {
const { t } = useTranslation();
const categoryData = operationCategories.map(category => ({
label: t(`ledger.category.${category}`),
value: category,
}));
return (
{t("ledger.title")}
{!!props.partial && {t("investment.partial")}}
{!!props.historyLoading && {t("investment.history")}}
{!!(props.hasNext || props.hasPrevious) && (
)}
);
};
export { AccountOperationsPageLoaded };