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

70 lines
2.2 KiB
TypeScript
Raw Normal View History

import { setIsoData } from "@utils/app";
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 { IsoDataOptionalSite } from "../../interfaces";
2023-06-22 00:54:35 +00:00
import { I18NextService } from "../../services";
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 (
2023-06-20 18:46:16 +00:00
<div className="error-page container-lg text-center">
2023-05-21 18:13:06 +00:00
<h1>
{errorPageData
2023-06-22 00:54:35 +00:00
? I18NextService.i18n.t("error_page_title")
: I18NextService.i18n.t("not_found_page_title")}
2023-05-21 18:13:06 +00:00
</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>
) : (
2023-06-22 00:54:35 +00:00
<p>{I18NextService.i18n.t("not_found_page_message")}</p>
2023-05-22 16:57:52 +00:00
)}
2023-05-14 15:08:06 +00:00
{!errorPageData && (
<Link to="/" replace>
2023-06-22 00:54:35 +00:00
{I18NextService.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-06-22 00:54:35 +00:00
{I18NextService.i18n.t("error_page_admin_matrix", {
2023-05-21 18:13:06 +00:00
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>
);
}
}