Files
frontend/src/features/instrument-details/model/section.ts
T
ksv741 6b1b26aa34
Frontend verify / commits (pull_request) Successful in 45s
Frontend verify / security (pull_request) Successful in 14s
Frontend verify / verify (pull_request) Successful in 6m45s
feat: render hourly investment states
2026-10-09 19:56:20 +03:00

31 lines
642 B
TypeScript

import type { InvestmentResourceMeta } from "@/shared/api";
type SectionState = {
error: boolean;
hasData: boolean;
loading: boolean;
partial?: boolean;
};
function hasSectionData(data: unknown) {
return data !== undefined;
}
function section(query: {
data: unknown;
isError: boolean;
meta?: InvestmentResourceMeta;
}): SectionState {
const isError = query.isError || query.meta?.lastAttempt.state === "failed";
const hasData = hasSectionData(query.data);
return {
error: isError,
hasData,
loading: !hasData && !isError,
partial: query.meta?.completeness === "incomplete",
};
}
export { section, type SectionState };