refactor: enforce enum machine codes #18
Frontend verify / commits (push) Skipped
Frontend verify / security (push) Successful in 11s
Frontend verify / verify (push) Successful in 9m31s

Use owner enums for known codes; preserve wire values and unknown fallbacks.

Verified npm ci and verify: 379 tests, 5 lint checks, app and Storybook builds.
This commit was merged in pull request #41.
This commit is contained in:
2026-09-28 16:36:40 +03:00
committed by ksv741
parent 12c3b72bfb
commit 5b69003516
26 changed files with 248 additions and 79 deletions
@@ -11,7 +11,7 @@ import {
useBrokerageOperations,
} from "@/entities/broker-operation";
import { useScreenSync } from "@/features/tbank-connection";
import { apiErrorCode } from "@/shared/api";
import { ApiErrorCode, apiErrorCode, isApiErrorCode } from "@/shared/api";
type AccountOperationsPageViewModel
= | {
@@ -114,7 +114,7 @@ const useAccountOperationsPageVm = (
const resetCursors = () => setPagination({ cursors: [], scopeKey });
const retry = () => {
if (apiErrorCode(operations.error) === "INVALID_OPERATIONS_CURSOR") {
if (isApiErrorCode(apiErrorCode(operations.error), ApiErrorCode.InvalidOperationsCursor)) {
void queryClient.invalidateQueries({
exact: true,
queryKey: brokerageOperationsQueryOptions(accountId, firstPageQuery)
@@ -136,7 +136,7 @@ const useAccountOperationsPageVm = (
if (
(operations.isError || operations.meta?.sync.state === "failed")
&& (!operations.data
|| apiErrorCode(operations.error) === "INVALID_OPERATIONS_CURSOR")
|| isApiErrorCode(apiErrorCode(operations.error), ApiErrorCode.InvalidOperationsCursor))
)
return { onReset, retry, state: "error" };
if (!operations.data) return { state: "loading" };