Part of the quiet-user-feedback change; docs and specs land in their own repositories.
50 lines
1.1 KiB
TypeScript
50 lines
1.1 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";
|
|
|
|
type AccountsPageErrorProps = { code?: string };
|
|
|
|
const AccountsPageError: FC<AccountsPageErrorProps> = (props) => {
|
|
const { code } = props;
|
|
const { t } = useTranslation();
|
|
|
|
const settingsAction = (
|
|
<Button component={Link} to="/settings" variant="light">
|
|
{t("accounts.openSettings")}
|
|
</Button>
|
|
);
|
|
|
|
if (isApiErrorCode(code, ApiErrorCode.TbankNotConnected))
|
|
return (
|
|
<StateView
|
|
action={settingsAction}
|
|
error
|
|
text={t("accounts.notConnectedText")}
|
|
title={t("accounts.notConnectedTitle")}
|
|
/>
|
|
);
|
|
if (isApiErrorCode(code, ApiErrorCode.InvalidTbankToken))
|
|
return (
|
|
<StateView
|
|
action={settingsAction}
|
|
error
|
|
text={t("accounts.invalidTokenText")}
|
|
title={t("accounts.invalidTokenTitle")}
|
|
/>
|
|
);
|
|
|
|
return (
|
|
<StateView
|
|
text={t("states.unavailableText")}
|
|
title={t("states.unavailableTitle")}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export { AccountsPageError };
|