refactor: enforce enum machine codes #18
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:
@@ -5,6 +5,8 @@ import { StateView } from "@wealthledger/ui";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { ApiErrorCode, isApiErrorCode } from "@/shared/api";
|
||||
|
||||
type AccountsPageErrorProps = { code?: string; retry?: () => void };
|
||||
|
||||
const AccountsPageError: FC<AccountsPageErrorProps> = (props) => {
|
||||
@@ -15,7 +17,7 @@ const AccountsPageError: FC<AccountsPageErrorProps> = (props) => {
|
||||
{t("accounts.openSettings")}
|
||||
</Button>
|
||||
);
|
||||
if (code === "TBANK_NOT_CONNECTED")
|
||||
if (isApiErrorCode(code, ApiErrorCode.TbankNotConnected))
|
||||
return (
|
||||
<StateView
|
||||
action={settingsAction}
|
||||
@@ -24,7 +26,7 @@ const AccountsPageError: FC<AccountsPageErrorProps> = (props) => {
|
||||
title={t("accounts.notConnectedTitle")}
|
||||
/>
|
||||
);
|
||||
if (code === "INVALID_TBANK_TOKEN")
|
||||
if (isApiErrorCode(code, ApiErrorCode.InvalidTbankToken))
|
||||
return (
|
||||
<StateView
|
||||
action={settingsAction}
|
||||
@@ -33,7 +35,7 @@ const AccountsPageError: FC<AccountsPageErrorProps> = (props) => {
|
||||
title={t("accounts.invalidTokenTitle")}
|
||||
/>
|
||||
);
|
||||
if (code === "TBANK_UNAVAILABLE")
|
||||
if (isApiErrorCode(code, ApiErrorCode.TbankUnavailable))
|
||||
return (
|
||||
<StateView
|
||||
action={(
|
||||
|
||||
Reference in New Issue
Block a user