forked from tdjsnelling/sqtracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_error.js
More file actions
63 lines (56 loc) · 1.68 KB
/
Copy path_error.js
File metadata and controls
63 lines (56 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React, { useContext, useState, useEffect } from "react";
import Link from "next/link";
import getConfig from "next/config";
import NextErrorComponent from "next/error";
import * as Sentry from "@sentry/nextjs";
import SEO from "../components/SEO";
import Text from "../components/Text";
import LocaleContext from "../utils/LocaleContext";
const ErrorPage = () => {
const [rateLimited, setRateLimited] = useState(false);
const {
publicRuntimeConfig: { SQ_API_URL },
} = getConfig();
useEffect(() => {
const checkRateLimit = async () => {
try {
const res = await fetch(SQ_API_URL);
if (res.status === 429) setRateLimited(true);
} catch (e) {}
};
checkRateLimit();
}, []);
const { getLocaleString } = useContext(LocaleContext);
return (
<>
<SEO title={getLocaleString("404NotFound")} />
<Text as="h1" mb={5}>
{getLocaleString("errSomethingWentWrong")} :(
</Text>
{rateLimited ? (
<Text>{getLocaleString("errTooManyRequests")}</Text>
) : (
<Text>
{getLocaleString("errIfErrorPersist")}{" "}
<a
href="https://github.com/tdjsnelling/sqtracker/issues"
target="_blank"
rel="noreferrer"
>
{getLocaleString("errReportIt")}
</a>
. For now,{" "}
<Link href="/" passHref>
<a>{getLocaleString("404ReturnHome")}</a>
</Link>
.
</Text>
)}
</>
);
};
ErrorPage.getInitialProps = async (contextData) => {
await Sentry.captureUnderscoreErrorException(contextData);
return NextErrorComponent.getInitialProps(contextData);
};
export default ErrorPage;