diff --git a/src/app.tsx b/src/app.tsx
index 742d1a81d..5f6f8d6a9 100644
--- a/src/app.tsx
+++ b/src/app.tsx
@@ -24,8 +24,6 @@ import ScssVars from "./assets/styles/styles/custom/_variables.module.scss";
import { ApplicationStateModel } from "./state/models/application-state.model";
import { ScheduleKey } from "./api/persistance-store.model";
import { AppMode, useAppConfig } from "./state/app-config-context";
-import * as Sentry from "@sentry/react";
-import AppErrorModal from "./components/common-components/modal/app-error-modal/app-error.modal.component";
import { cropScheduleDMToMonthDM } from "./logic/schedule-container-convertion/schedule-container-convertion";
const useStyles = makeStyles(() => ({
@@ -104,39 +102,25 @@ function App(): JSX.Element {
fetchGlobalState();
}, [fetchGlobalState]);
- const [open, setIsOpen] = useState(false);
- const fallback = useCallback(
- ({ resetError }): JSX.Element => (
-
- ),
- [open, setIsOpen]
- );
-
- const onError = useCallback((): void => {
- setIsOpen(true);
- }, [setIsOpen]);
-
return (
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
- {isElectron() ? <>> : }
-
-
-
-
-
+
+ {isElectron() ? <>> : }
+
+
+
+
);
}
diff --git a/src/components/app-error-boundary/app-error-boundary.component.tsx b/src/components/app-error-boundary/app-error-boundary.component.tsx
new file mode 100644
index 000000000..337bbd24e
--- /dev/null
+++ b/src/components/app-error-boundary/app-error-boundary.component.tsx
@@ -0,0 +1,27 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+import React, { ReactNode, useCallback, useState } from "react";
+import AppErrorModal from "../common-components/modal/app-error-modal/app-error.modal.component";
+import * as Sentry from "@sentry/react";
+
+interface AppErrorBoundaryOptions {
+ children: ReactNode;
+}
+
+export function AppErrorBoundary(props: AppErrorBoundaryOptions): JSX.Element {
+ const [open, setIsOpen] = useState(false);
+ const fallback = useCallback(
+ ({ resetError }): JSX.Element => (
+
+ ),
+ [open, setIsOpen]
+ );
+
+ const onError = useCallback((): void => {
+ setIsOpen(true);
+ }, [setIsOpen]);
+
+ return ;
+}
diff --git a/src/components/common-components/modal/report-issue-modal/report-issue-modal.component.tsx b/src/components/common-components/modal/report-issue-modal/report-issue-modal.component.tsx
index 3017b7889..a02cee7a4 100644
--- a/src/components/common-components/modal/report-issue-modal/report-issue-modal.component.tsx
+++ b/src/components/common-components/modal/report-issue-modal/report-issue-modal.component.tsx
@@ -117,6 +117,14 @@ export default function ReportIssueModal(options: ReportIssueModalOptions): JSX.
});
}
+ // Only for testing purposes
+ if (
+ process.env.REACT_APP_TEST_MODE &&
+ issueDescription.toLowerCase() === process.env.REACT_APP_ERROR_WORKER
+ ) {
+ throw new Error("[TEST MODE] Error message was entered");
+ }
+
const body = (
{isSent &&
Wysłano powiadomienie o błędzie.
}
diff --git a/src/components/schedule-page/table/schedule/schedule.component.tsx b/src/components/schedule-page/table/schedule/schedule.component.tsx
index 7a990d7c3..7da457164 100644
--- a/src/components/schedule-page/table/schedule/schedule.component.tsx
+++ b/src/components/schedule-page/table/schedule/schedule.component.tsx
@@ -35,7 +35,7 @@ export function ScheduleComponent({
.map((worker) => worker.toLowerCase())
.includes(process.env.REACT_APP_ERROR_WORKER ?? "ERROR")
) {
- throw new Error("Schedule in dev mode includes error user");
+ throw new Error("[TEST MODE] Error user was added");
}
return (
diff --git a/src/index.tsx b/src/index.tsx
index ebce7229a..14cd81df1 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -19,6 +19,7 @@ import thunkMiddleware from "redux-thunk";
import { appReducer } from "./state/app.reducer";
import { createBrowserHistory } from "history";
import { composeWithDevTools } from "redux-devtools-extension";
+import { AppErrorBoundary } from "./components/app-error-boundary/app-error-boundary.component";
const history = createBrowserHistory();
@@ -42,17 +43,19 @@ const composedEnhancer = composeWithDevTools(
export const appStore = createStore(appReducer, composedEnhancer);
ReactDOM.render(
-
-
-
-
-
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+
+
+
+
+
+ ,
document.getElementById("root")
);
/* eslint-disable @typescript-eslint/no-explicit-any */