refactor: enforce frontend view model boundaries
This commit is contained in:
@@ -2,6 +2,7 @@ import type { paths } from "@/shared/api";
|
||||
|
||||
type Meta
|
||||
= paths["/api/v1/tbank-sync/{id}"]["get"]["responses"][200]["content"]["application/json"]["resources"][number];
|
||||
|
||||
type SectionState = {
|
||||
error: boolean;
|
||||
hasData: boolean;
|
||||
@@ -13,6 +14,7 @@ type SectionState = {
|
||||
sourceError?: boolean;
|
||||
stale?: boolean;
|
||||
};
|
||||
|
||||
function section(
|
||||
query: {
|
||||
data: unknown;
|
||||
@@ -24,6 +26,7 @@ function section(
|
||||
retry?: () => unknown,
|
||||
): SectionState {
|
||||
const isError = query.isError || query.meta?.sync.state === "failed";
|
||||
|
||||
return {
|
||||
error: isError,
|
||||
hasData: Boolean(query.data),
|
||||
|
||||
Reference in New Issue
Block a user