Commit 0acf8d2b authored by Lukas Budginas's avatar Lukas Budginas Committed by Kristupas Bobraitis
Browse files

modify error boundary, add errors, update readme file

parent 3fd6d0c1
......@@ -56,9 +56,10 @@ export default function App() {
if (accountName) {
if (currentStartBlock < currentEndBlock) {
return true;
}
if (currentStartDate < currentEndDate) {
} else if (currentStartDate < currentEndDate) {
return true;
} else {
return false;
}
}
};
......@@ -141,7 +142,17 @@ export default function App() {
</div>
</>
) : (
""
<Alert
style={
renderContent() === false
? { display: "block" }
: { display: "none" }
}
severity="error"
>
Please check values of inputs. Start block/date can NOT be higher or
equal to end block/date !
</Alert>
)}
</div>
</div>
......
import React from "react";
import ErrorUI from "./ErrorUI /ErrorUI";
class ErrorBoundary extends React.Component {
constructor(props) {
......@@ -10,15 +11,10 @@ class ErrorBoundary extends React.Component {
return { hasError: true };
}
// componentDidCatch(error, errorInfo) {
// // You can also log the error to an error reporting service
// logErrorToMyService(error, errorInfo);
// }
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return <h1>Something went wrong.</h1>;
return <ErrorUI />;
}
return this.props.children;
}
......
import React from "react";
import styles from "./ErrorUI.module.css";
export default function ErrorUI() {
return (
<div className={styles["error--container"]}>
<h1>Oops... Something went wrong !</h1>
<p> Go to homepage and try again !</p>
<a href="/">Homepage</a>
</div>
);
}
.error--container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
......@@ -40,7 +40,7 @@ export default function Parameters({
const re = /^[0-9\b]+$/; ///<==== type only numbers validation //
// const startBlockErrors = () => {
// if (currentStartBlock > currentEndBlock) {
// if (startBlock > endBlock) {
// return true && "Start block must be lower than End block";
// }
// };
......@@ -49,6 +49,10 @@ export default function Parameters({
// if (currentStartBlock > currentEndBlock) {
// return true && "End block must be higher than start block";
// }
// if (currentEndBlock !== "" && currentStartBlock === currentEndBlock) {
// return true && "block can't be equal";
// }
// };
return (
......@@ -79,7 +83,6 @@ export default function Parameters({
}
>
<TextField
// error={startBlockErrors()}
required={showDates === true ? false : true}
className={styles.input}
value={startBlock}
......@@ -90,10 +93,12 @@ export default function Parameters({
id="outlined-basic"
label="Start Block"
variant="outlined"
// helperText={startBlockErrors()}
helperText={
currentStartBlock > currentEndBlock &&
"Start block must be lower than end block"
}
/>
<TextField
// error={endBlockErrors()}
required={showDates === true ? false : true}
className={styles.input}
value={endBlock}
......@@ -104,7 +109,10 @@ export default function Parameters({
id="outlined-basic"
label="End Block"
variant="outlined"
// helperText={endBlockErrors()}
helperText={
currentStartBlock > currentEndBlock &&
"End block must be higher than start block"
}
/>
</div>
......
import React from "react";
import ReactDOM from "react-dom";
import App from "./components/App/App";
import ErrorBoundary from "./components/ErrorBoundary";
import ErrorBoundary from "./components/Error/ErrorBoundary";
ReactDOM.render(
<ErrorBoundary>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment