feat: render hourly investment states
Frontend verify / commits (push) Skipped
Frontend verify / security (push) Successful in 12s
Frontend verify / verify (push) Successful in 7m41s

This commit was merged in pull request #51.
This commit is contained in:
2026-10-09 21:13:34 +03:00
committed by ksv741
parent 20b2cdfd43
commit 3c226f8c29
36 changed files with 1388 additions and 1238 deletions
@@ -32,6 +32,21 @@ describe("SourceSyncStatus", () => {
expect(screen.getByRole("status")).toHaveTextContent("Обновление не удалось");
});
it("announces an active or failed source attempt with text", () => {
renderStatus({
lastAttempt: {
finishedAt: null,
problems: [],
startedAt: "2026-02-03T10:15:00.000Z",
state: "running",
},
});
expect(screen.getByRole("status")).toHaveTextContent(
"Обновление выполняется",
);
});
it("keeps the notices next to the timestamp they belong to", () => {
renderStatus({
errorText: "Обновление не удалось",
@@ -3,6 +3,8 @@ import type { FC } from "react";
import { Text } from "@mantine/core";
import { useTranslation } from "react-i18next";
import type { InvestmentResourceMeta } from "@/shared/api";
import { formatSnapshotTime } from "@/shared/lib";
// Owns the "when did the source last answer" line and the two notices that
@@ -10,6 +12,7 @@ import { formatSnapshotTime } from "@/shared/lib";
// shows a muted line, a page header a progress bar — that is a product call.
type SourceSyncStatusProps = {
errorText?: null | string;
lastAttempt?: InvestmentResourceMeta["lastAttempt"];
lastSuccessfulAt?: null | string;
stale?: boolean;
};
@@ -17,6 +20,12 @@ type SourceSyncStatusProps = {
const SourceSyncStatus: FC<SourceSyncStatusProps> = (props) => {
const { t } = useTranslation();
const attempt = props.lastAttempt;
const attemptText = attempt && attempt.state !== "none"
? t(`investment.attempt.${attempt.state}`)
: null;
return (
<>
{!!props.lastSuccessfulAt && (
@@ -29,6 +38,12 @@ const SourceSyncStatus: FC<SourceSyncStatusProps> = (props) => {
{!!props.stale && <Text size="xs">{t("investment.stale")}</Text>}
{!!attemptText && (
<Text role="status" size="xs">
{attemptText}
</Text>
)}
{!!props.errorText && <Text role="status">{props.errorText}</Text>}
</>
);