feat: improve ledger event rows

This commit is contained in:
2026-08-26 15:03:48 +03:00
parent c1a8674f16
commit 488ccad540
12 changed files with 480 additions and 193 deletions
+34
View File
@@ -399,6 +399,40 @@ describe("AccountPage states", () => {
expect(screen.getByText("Вторая")).toBeInTheDocument();
});
it("uses the ledger row for a recent outgoing operation", () => {
renderPage(
<AccountPageLoaded
{...loadedProps()}
recentOperations={{
state: "loaded",
to: "/accounts/account-1/operations",
items: [
{
id: "operation-1",
occurredAt: "2026-08-14T10:00:00Z",
type: "OPERATION_TYPE_BUY",
category: "trade",
description: "Покупка акции",
figi: "FIGI-1",
instrumentUid: "UID-1",
ticker: "SBER",
instrumentType: "share",
logoName: null,
payment: { currency: "RUB", value: "-12" },
quantity: null,
price: null,
accruedInterest: null,
commission: null,
},
],
}}
/>,
);
expect(screen.getByText("Списание")).toBeInTheDocument();
expect(screen.getByText("−12 ₽")).toBeInTheDocument();
});
it("keeps the portfolio visible when upcoming events fail", () => {
renderPage(
<AccountPageLoaded
@@ -1,9 +1,8 @@
import { Alert, Button, Paper, Stack, Text } from "@mantine/core";
import { Alert, Button, Stack, Text } from "@mantine/core";
import type { FC } from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router";
import { formatMoney } from "@/entities/portfolio";
import classes from "../AccountPage.module.css";
import { LedgerEntryRow } from "@/entities/broker-operation";
import type { AccountPageRecentOperations } from "../AccountPage.vm";
type RecentOperationsProps = {
@@ -27,14 +26,7 @@ const RecentOperations: FC<RecentOperationsProps> = (props) => {
) : null}
{operations.state === "loaded"
? operations.items.map((operation) => (
<Paper className={classes.cash} key={operation.id} withBorder>
<Text>{operation.description || operation.type}</Text>
<Text fw={700}>
{operation.payment
? formatMoney(operation.payment)
: t("ledger.noMoney")}
</Text>
</Paper>
<LedgerEntryRow key={operation.id} operation={operation} />
))
: null}
<Button component={Link} to={operations.to} variant="subtle">