refactor: simplify resource queries and layout tests
Frontend security / security (push) Successful in 10s
Frontend verify / verify (push) Successful in 5m51s

This commit was merged in pull request #40.
This commit is contained in:
2026-09-27 18:53:12 +03:00
parent 5e076470aa
commit c1b08735e3
18 changed files with 508 additions and 122 deletions
+9 -10
View File
@@ -22,6 +22,12 @@ function unwrapResourceResult<T extends Resource, E>(
result: UseQueryResult<T, E>,
) {
const missing = result.isSuccess && result.data.data === null;
const data: T["data"] | undefined = result.data?.data;
const meta: T["meta"] | undefined = result.data?.meta;
const status: UseQueryResult<T, E>["status"] = missing
? "pending"
: result.status;
// Project resource fields; refetch still returns the transport envelope.
return {
...result,
transport: {
@@ -29,18 +35,11 @@ function unwrapResourceResult<T extends Resource, E>(
fetchStatus: result.fetchStatus,
error: result.error,
},
data: result.data?.data ?? undefined,
meta: result.data?.meta,
data: data ?? undefined,
meta,
isPending: result.isPending || missing,
isSuccess: result.isSuccess && !missing,
status: missing ? "pending" : result.status,
} as UseQueryResult<NonNullable<T["data"]>, E> & {
meta?: T["meta"];
transport: {
status: UseQueryResult<T, E>["status"];
fetchStatus: UseQueryResult<T, E>["fetchStatus"];
error: E | null;
};
status,
};
}