feat: show persisted investment data and sync state

Consume the provided resource-envelope API snapshot. Preserve financial snapshots during
refresh, observe synchronization without importing, and fence late responses across
account and connection changes.
This commit is contained in:
2026-09-26 21:22:49 +03:00
parent b987fd8e78
commit 4e5f564fa1
81 changed files with 4714 additions and 1420 deletions
@@ -177,7 +177,13 @@ const InstrumentChart: FC<InstrumentChartProps> = (props) => {
</Accordion>
</>
) : (
<Text c="dimmed">{t("stock.noCandles")}</Text>
<Text c="dimmed">
{t(
vm.candlesState.partial
? "investment.partial"
: "stock.noCandles",
)}
</Text>
)
) : null}
</InstrumentSection>
@@ -60,7 +60,11 @@ const InstrumentEvents: FC<InstrumentEventsProps> = (props) => {
</Stack>
) : (
<Text c="dimmed" py="lg">
{t("stock.noOperations")}
{t(
vm.operationsState.partial
? "investment.partial"
: "stock.noOperations",
)}
</Text>
)}
<Group justify="space-between" mt="md">
@@ -11,6 +11,7 @@ import {
import { LoadingSkeleton } from "@wealthledger/ui";
import type { FC, PropsWithChildren, ReactNode } from "react";
import { useTranslation } from "react-i18next";
import { formatSnapshotTime } from "@/shared/lib";
import type { SectionState } from "../model/section";
import classes from "./InstrumentDetails.module.css";
@@ -38,20 +39,40 @@ const InstrumentSection: FC<InstrumentSectionProps> = (props) => {
</Title>
{props.controls}
</Group>
{props.state.stale ? (
<Text size="xs">{t("investment.stale")}</Text>
) : null}
{props.state.partial ? (
<Text role="status">{t("investment.partial")}</Text>
) : null}
{props.state.lastSuccessfulAt ? (
<Text size="xs" c="dimmed">
{t("investment.sourceTime", {
date: formatSnapshotTime(props.state.lastSuccessfulAt),
})}
</Text>
) : null}
{props.state.refreshing ? (
<Text role="status" size="xs" c="dimmed">
{t("accounts.refreshing")}
</Text>
) : null}
{props.state.error ? (
<Alert color="orange" mb="sm" role="alert">
<Alert color="orange" mb="sm" role="status" aria-live="polite">
<Group justify="space-between">
<Text size="sm">
{props.state.hasData
? t("accounts.refreshError")
: t("stock.sectionError")}
{props.state.sourceError
? t("investment.syncFailed")
: props.state.hasData
? t("accounts.refreshError")
: t("stock.sectionError")}
</Text>
<Button size="xs" variant="default" onClick={props.state.retry}>
<Button
size="xs"
variant="default"
onClick={props.state.retry}
disabled={props.state.refreshing}
>
{t("accounts.retry")}
</Button>
</Group>