lemmy-ui/src/shared/components/app/error-page.tsx

71 lines
2.1 KiB
TypeScript
Raw Normal View History

2023-05-14 15:08:06 +00:00
import { Component } from "inferno";
2023-05-21 18:13:06 +00:00
import { T } from "inferno-i18next-dess";
2023-05-14 15:08:06 +00:00
import { Link } from "inferno-router";
2023-05-21 18:13:06 +00:00
import { i18n } from "../../i18next";
import { IsoDataOptionalSite } from "../../interfaces";
import { setIsoData } from "../../utils";
2023-05-14 15:08:06 +00:00
export class ErrorPage extends Component<any, any> {
2023-05-14 23:49:55 +00:00
private isoData: IsoDataOptionalSite = setIsoData(this.context);
2023-05-14 15:08:06 +00:00
constructor(props: any, context: any) {
super(props, context);
}
render() {
const { errorPageData } = this.isoData;
2023-05-14 15:08:06 +00:00
return (
<div className="container-lg text-center">
2023-05-21 18:13:06 +00:00
<h1>
{errorPageData
? i18n.t("error_page_title")
: i18n.t("not_found_page_title")}
</h1>
<p className="p-4">
{errorPageData ? (
2023-05-21 18:13:06 +00:00
<T i18nKey="error_page_paragraph" class="d-inline">
#<a href="https://lemmy.ml/c/lemmy_support">#</a>#
<a href="https://matrix.to/#/#lemmy-space:matrix.org">#</a>#
</T>
) : (
2023-05-21 18:42:17 +00:00
i18n.t("not_found_page_message")
)}
2023-05-14 15:08:06 +00:00
</p>
{!errorPageData && (
<Link to="/" replace>
2023-05-21 18:13:06 +00:00
{i18n.t("not_found_return_home_button")}
</Link>
2023-05-14 15:08:06 +00:00
)}
{errorPageData?.adminMatrixIds &&
errorPageData.adminMatrixIds.length > 0 && (
<>
2023-05-14 15:08:06 +00:00
<div>
2023-05-21 18:13:06 +00:00
{i18n.t("error_page_admin_matrix", {
instance:
this.isoData.site_res?.site_view.site.name ??
"this instance",
})}
2023-05-14 15:08:06 +00:00
</div>
<ul className="mx-auto mt-2" style={{ width: "fit-content" }}>
2023-05-14 15:08:06 +00:00
{errorPageData.adminMatrixIds.map(matrixId => (
<li key={matrixId} className="text-info">
{matrixId}
</li>
2023-05-14 15:08:06 +00:00
))}
</ul>
</>
2023-05-14 15:08:06 +00:00
)}
{errorPageData?.error && (
<code
style={{ "text-align": "start" }}
className="d-block bg-dark text-light p-2 mt-4"
>
{errorPageData.error}
</code>
)}
2023-05-14 15:08:06 +00:00
</div>
);
}
}