Files
frontend/src/pages/account/ui/AccountPage/components/AccountPageError.view.tsx
T
codex-bot 8ce1e8e444
Frontend verify / commits (push) Skipped
Frontend verify / security (push) Successful in 9s
Frontend verify / verify (push) Failing after 7m5s
feat(investments): warn and offer retry after exhausted read retries (WealthLedger/frontend#55) (#136)
2026-11-03 09:49:08 +03:00

69 lines
1.5 KiB
TypeScript

import type { FC } from "react";
import { Button } from "@mantine/core";
import { StateView } from "@wealthledger/ui";
import { useTranslation } from "react-i18next";
import { Link } from "react-router";
import { ApiErrorCode, isApiErrorCode } from "@/shared/api";
import { ReadRetryButton, type ReadRetryProps } from "@/shared/ui";
type AccountPageErrorProps = {
code?: string;
readRetry?: ReadRetryProps;
};
const AccountPageError: FC<AccountPageErrorProps> = (props) => {
const { code } = props;
const { t } = useTranslation();
if (isApiErrorCode(code, ApiErrorCode.NotFound))
return (
<StateView
action={(
<Button component={Link} to="/accounts">
{t("portfolio.back")}
</Button>
)}
error
text={t("portfolio.accountUnavailableText")}
title={t("portfolio.accountUnavailableTitle")}
/>
);
if (
isApiErrorCode(code, ApiErrorCode.TbankNotConnected)
|| isApiErrorCode(code, ApiErrorCode.InvalidTbankToken)
)
return (
<StateView
action={(
<Button component={Link} to="/settings">
{t("accounts.openSettings")}
</Button>
)}
error
text={t("portfolio.connectionErrorText")}
title={t("portfolio.connectionErrorTitle")}
/>
);
const retry = props.readRetry?.exhausted
? (
<ReadRetryButton
onRetry={props.readRetry.onRetry}
retrying={props.readRetry.retrying}
/>
)
: undefined;
return (
<StateView
action={retry}
text={t("states.unavailableText")}
title={t("states.unavailableTitle")}
/>
);
};
export { AccountPageError };