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
+11 -13
View File
@@ -1,8 +1,4 @@
import {
apiQueryClient,
type paths,
useAuthenticatedQuery,
} from "@/shared/api";
import { apiQueryClient, type paths, useResourceQuery } from "@/shared/api";
type BondPeriod = NonNullable<
NonNullable<
@@ -13,7 +9,7 @@ type BondPeriod = NonNullable<
const BOND_STALE_TIME_MS = 30_000;
function useBondSearch(query: string) {
return useAuthenticatedQuery({
return useResourceQuery({
...apiQueryClient.queryOptions("get", "/api/v1/bonds", {
params: { query: { query } },
}),
@@ -36,11 +32,11 @@ function useBond(identifier: string) {
identifier,
);
const byUid = useAuthenticatedQuery({
const byUid = useResourceQuery({
...bondQueryOptions(identifier),
enabled: Boolean(identifier) && isUid,
});
const byTicker = useAuthenticatedQuery({
const byTicker = useResourceQuery({
...apiQueryClient.queryOptions("get", "/api/v1/bonds/by-ticker/{ticker}", {
params: { path: { ticker: identifier } },
}),
@@ -50,7 +46,7 @@ function useBond(identifier: string) {
return isUid ? byUid : byTicker;
}
function useBondMetrics(uid: string) {
return useAuthenticatedQuery({
return useResourceQuery({
...apiQueryClient.queryOptions("get", "/api/v1/bonds/{uid}/metrics", {
params: { path: { uid } },
}),
@@ -59,7 +55,7 @@ function useBondMetrics(uid: string) {
});
}
function useBondQuote(uid: string) {
return useAuthenticatedQuery({
return useResourceQuery({
...apiQueryClient.queryOptions("get", "/api/v1/bonds/{uid}/quote", {
params: { path: { uid } },
}),
@@ -68,7 +64,7 @@ function useBondQuote(uid: string) {
});
}
function useBondCandles(uid: string, period: BondPeriod) {
return useAuthenticatedQuery({
return useResourceQuery({
...apiQueryClient.queryOptions("get", "/api/v1/bonds/{uid}/candles", {
params: { path: { uid }, query: { period } },
}),
@@ -77,7 +73,8 @@ function useBondCandles(uid: string, period: BondPeriod) {
});
}
function useBondPosition(uid: string) {
return useAuthenticatedQuery({
return useResourceQuery({
meta: { accessGroup: "brokerage" },
...apiQueryClient.queryOptions("get", "/api/v1/bonds/{uid}/position", {
params: { path: { uid } },
}),
@@ -86,7 +83,8 @@ function useBondPosition(uid: string) {
});
}
function useBondCoupons(uid: string) {
return useAuthenticatedQuery({
return useResourceQuery({
meta: { accessGroup: "brokerage" },
...apiQueryClient.queryOptions("get", "/api/v1/bonds/{uid}/coupons", {
params: { path: { uid } },
}),