2023-05-14 15:08:06 +00:00
|
|
|
import { Component } from "inferno";
|
|
|
|
import { Link } from "inferno-router";
|
2023-05-14 23:49:55 +00:00
|
|
|
import { IsoDataOptionalSite } from "shared/interfaces";
|
2023-05-14 15:08:06 +00:00
|
|
|
import { ErrorPageData, setIsoData } from "../../utils";
|
|
|
|
|
|
|
|
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.getErrorPageData();
|
|
|
|
|
|
|
|
return (
|
2023-05-14 20:25:03 +00:00
|
|
|
<div className="container-lg text-center">
|
2023-05-14 15:08:06 +00:00
|
|
|
<h1>{errorPageData ? "Error!" : "Page Not Found"}</h1>
|
2023-05-15 03:01:39 +00:00
|
|
|
<p className="p-4">
|
|
|
|
{errorPageData ? (
|
|
|
|
<>
|
|
|
|
<span>
|
|
|
|
There was an error on the server. Try refreshing your browser.
|
|
|
|
If that doesn't work, come back at a later time. If the
|
|
|
|
problem persists,
|
|
|
|
</span>{" "}
|
|
|
|
<a href="https://github.com/LemmyNet/lemmy/issues">
|
|
|
|
consider opening an issue.
|
|
|
|
</a>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
"The page you are looking for does not exist."
|
|
|
|
)}
|
2023-05-14 15:08:06 +00:00
|
|
|
</p>
|
|
|
|
{!errorPageData && (
|
2023-05-15 03:01:39 +00:00
|
|
|
<Link to="/" replace>
|
|
|
|
Click here to return to your home page.
|
|
|
|
</Link>
|
2023-05-14 15:08:06 +00:00
|
|
|
)}
|
|
|
|
{errorPageData?.adminMatrixIds &&
|
|
|
|
errorPageData.adminMatrixIds.length > 0 && (
|
2023-05-15 03:01:39 +00:00
|
|
|
<>
|
2023-05-14 15:08:06 +00:00
|
|
|
<div>
|
|
|
|
If you would like to reach out to one of{" "}
|
2023-05-14 23:49:55 +00:00
|
|
|
{this.isoData.site_res?.site_view.site.name ?? "this instance"}
|
|
|
|
's admins for support, try the following Matrix addresses:
|
2023-05-14 15:08:06 +00:00
|
|
|
</div>
|
2023-05-15 03:01:39 +00:00
|
|
|
<ul className="mx-auto mt-2" style={{ width: "fit-content" }}>
|
2023-05-14 15:08:06 +00:00
|
|
|
{errorPageData.adminMatrixIds.map(matrixId => (
|
2023-05-15 03:01:39 +00:00
|
|
|
<li key={matrixId} className="text-info">
|
|
|
|
{matrixId}
|
|
|
|
</li>
|
2023-05-14 15:08:06 +00:00
|
|
|
))}
|
|
|
|
</ul>
|
2023-05-15 03:01:39 +00:00
|
|
|
</>
|
2023-05-14 15:08:06 +00:00
|
|
|
)}
|
2023-05-14 20:25:03 +00:00
|
|
|
{errorPageData?.error && (
|
2023-05-15 03:01:39 +00:00
|
|
|
<code
|
|
|
|
style={{ "text-align": "start" }}
|
|
|
|
className="d-block bg-dark text-light p-2 mt-4"
|
|
|
|
>
|
|
|
|
{errorPageData.error}
|
|
|
|
</code>
|
2023-05-14 20:25:03 +00:00
|
|
|
)}
|
2023-05-14 15:08:06 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private getErrorPageData() {
|
|
|
|
const errorPageData = this.isoData.routeData[0] as
|
|
|
|
| ErrorPageData
|
|
|
|
| undefined;
|
|
|
|
if (errorPageData?.type === "error") {
|
|
|
|
return errorPageData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
}
|