generated from YashTotale/boilerplate-react-with-redux-and-firebase
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathError.tsx
91 lines (85 loc) · 2.43 KB
/
Error.tsx
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// React Imports
import React, { FC, useState } from "react";
import { FallbackProps } from "react-error-boundary";
import { Helmet } from "react-helmet";
import { generatePageTitle } from "../Utils/funcs";
// Firebase Imports
import { auth } from "../Utils/Config/firebase";
const ClearButton: FC<FallbackProps> = (props) => {
const [hover, setHover] = useState(false);
const onClear = () => {
localStorage.clear();
auth.signOut();
props.resetErrorBoundary();
window.location.reload();
};
return (
<button
onMouseEnter={() => setHover(true)}
onMouseLeave={() => setHover(false)}
style={{
display: "inline-flex",
justifyContent: "center",
border: hover
? "1px solid #d32f2f"
: "1px solid rgba(211, 47, 47, 0.5)",
borderRadius: "4px",
backgroundColor: hover ? "rgba(211, 47, 47, 0.04)" : "transparent",
transition:
"background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
color: "#d32f2f",
padding: "5px 15px",
cursor: "pointer",
lineHeight: "1.75",
fontSize: "0.875rem",
fontFamily: "'Roboto','Helvetica','Arial',sans-serif",
fontWeight: 500,
}}
onClick={onClear}
>
Clear Site Data
</button>
);
};
const ErrorPage: FC<FallbackProps> = (props) => {
return (
<>
<Helmet>
<title>{generatePageTitle("Error")}</title>
</Helmet>
<div
style={{
height: "100vh",
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
margin: "0px 10px",
}}
>
<img src="/logo192.png" alt="" width="50" />
<h1
style={{
fontFamily: "Cabin, 'sans-serif'",
textAlign: "center",
margin: "15px 0px",
}}
>
{props.error.name ?? "Error"}
</h1>
<h2
style={{
fontFamily: "Cabin, 'sans-serif'",
textAlign: "center",
marginBottom: "15px",
marginTop: "0px",
}}
>
{props.error.message ?? "An unexpected error occurred."}
</h2>
<ClearButton {...props} />
</div>
</>
);
};
export default ErrorPage;