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

70 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>
2023-05-22 16:57:52 +00:00
{errorPageData ? (
<T i18nKey="error_page_paragraph" className="p-4" parent="p">
#<a href="https://lemmy.ml/c/lemmy_support">#</a>#
<a href="https://matrix.to/#/#lemmy-space:matrix.org">#</a>#
</T>
) : (
<p>{i18n.t("not_found_page_message")}</p>
)}
2023-05-14 15:08:06 +00:00
{!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 && (
2023-05-22 16:57:52 +00:00
<T
i18nKey="error_code_message"
parent="p"
interpolation={{ error: errorPageData.error }}
>
#<strong className="text-danger">#</strong>#
</T>
)}
2023-05-14 15:08:06 +00:00
</div>
);
}
}