CEC-180 Cache Control (#30)

* Set cache expire to 1 day
Add snapshot tests for new screens

* Fix table pagniation random ids for snapshot tests

* Auto reload on chunk load error

* OTA Admin Portal => Admin Portal
This commit is contained in:
John Wu
2021-04-13 17:52:10 -07:00
committed by GitHub
parent 1f9db5454f
commit 7a1125cb1f
13 changed files with 3180 additions and 173 deletions

View File

@@ -2,25 +2,60 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import { Typography } from "@material-ui/core";
const reload = () => {
window.location.reload();
};
export default class ErrorBoundary extends Component {
state = {
error: "",
errorInfo: "",
hasError: false,
};
static getDerivedStateFromError(error) {
return { hasError: true, error };
}
componentDidCatch(error, errorInfo) {
this.setState({ errorInfo });
}
render() {
if (this.state.hasError)
if (this.state.hasError) {
if (this.state.error && this.state.error.name === "ChunkLoadError") {
reload();
return;
}
return (
<Typography variant="h3" align="center">
Client-side Error Occured and Logged
</Typography>
<div
style={{
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
}}
>
<Typography variant="h3" align="center">
Sorry, an error has occured and been logged
</Typography>
<Typography
variant="h5"
align="center"
style={{
cursor: "pointer",
textDecorationColor: "Blue",
textDecorationStyle: "solid",
textDecorationLine: "underline",
color: "Blue",
}}
onClick={reload}
>
Click to reload
</Typography>
</div>
);
}
return this.props.children;
}
}