diff --git a/web/package.json b/web/package.json
index 11b3913..c9b27e2 100644
--- a/web/package.json
+++ b/web/package.json
@@ -28,7 +28,7 @@
"source-map-explorer": "^2.5.3"
},
"scripts": {
- "start": "export NODE_OPTIONS=--openssl-legacy-provider && react-scripts start",
+ "start": "export NODE_OPTIONS=--openssl-legacy-provider && WDS_SOCKET_PORT=80 react-scripts start",
"build": "export NODE_OPTIONS=--openssl-legacy-provider && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
diff --git a/web/src/Components/Bridging/Graphs/BridgeGraph.tsx b/web/src/Components/Bridging/Graphs/BridgeGraph.tsx
index d2547ee..8952d92 100644
--- a/web/src/Components/Bridging/Graphs/BridgeGraph.tsx
+++ b/web/src/Components/Bridging/Graphs/BridgeGraph.tsx
@@ -19,8 +19,8 @@ const CustomTooltip = ({ active, payload, label }) => {
{`Particle size : ${label}µm`}
- {payload.map((graphData: any) => (
-
{`${graphData.name}: ${graphData.value}%`}
+ {payload.map((graphData: any, index: number) => (
+
{`${graphData.name}: ${graphData.value}%`}
))}
diff --git a/web/src/Components/Combinations/CombinationCard.tsx b/web/src/Components/Combinations/CombinationCard.tsx
index d684716..f4f65e5 100644
--- a/web/src/Components/Combinations/CombinationCard.tsx
+++ b/web/src/Components/Combinations/CombinationCard.tsx
@@ -1,16 +1,15 @@
import React, { useContext, useEffect, useState } from 'react'
-// @ts-ignore
-import { Button, Icon, Switch, Input, Tooltip, Divider } from '@equinor/eds-core-react'
+import { Button, Icon, Switch, Input, Tooltip } from '@equinor/eds-core-react'
import CombinationTable from './CombinationTable'
import styled from 'styled-components'
import { Card } from './CardContainer'
import { Bridge, Combination, GraphData, Product, Products } from '../../Types'
import EditProducts from '../Common/EditProducts'
import { CombinationAPI } from '../../Api'
-import { ErrorToast } from '../Common/Toast'
import { findDValue, findGraphData } from '../../Utils'
import { IAuthContext, AuthContext } from 'react-oauth2-code-pkce'
-import { edit, close, delete_to_trash } from '@equinor/eds-icons'
+import { edit, delete_to_trash } from '@equinor/eds-icons'
+import { toast } from 'react-toastify'
const CardHeader = styled.div`
display: flex;
@@ -82,6 +81,11 @@ export const CombinationCard = ({
let newMass: number = 0
let newDensity: number = 0
Object.values(combination.values).forEach(prod => {
+ if (!allProducts[prod.id]) {
+ console.error(`Product with id '${prod.id}' not found in allProducts`)
+ toast.error(`Product with id '${prod.id}' not found. Try resetting the application data.`, { autoClose: false })
+ return
+ }
newMass += allProducts[prod.id].sackSize * prod.value
newDensity += prod.value
})
@@ -102,7 +106,7 @@ export const CombinationCard = ({
})
.catch(error => {
console.error('fetch error' + error)
- ErrorToast(`${error.response.data}`, error.response.status)
+ toast.error(`Failed to calculate bridge for combination '${combination.name}'`, { autoClose: false })
})
}, [combination, allProducts])
diff --git a/web/src/Components/Common/ErrorBoundary.tsx b/web/src/Components/Common/ErrorBoundary.tsx
new file mode 100644
index 0000000..55070d7
--- /dev/null
+++ b/web/src/Components/Common/ErrorBoundary.tsx
@@ -0,0 +1,57 @@
+import { Icon, List, Typography } from '@equinor/eds-core-react'
+import { account_circle } from '@equinor/eds-icons'
+import { Component, ErrorInfo, ReactNode } from 'react'
+
+interface Props {
+ children?: ReactNode
+}
+
+interface State {
+ hasError: boolean
+}
+
+class ErrorBoundary extends Component {
+ constructor(props) {
+ super(props)
+ this.state = { hasError: false }
+ }
+ // public state: State = {
+ // hasError: false,
+ // }
+
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ static getDerivedStateFromError(_: Error): State {
+ // Update state so the next render will show the fallback UI.
+ return { hasError: true }
+ }
+
+ public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
+ console.error('Uncaught error:', error)
+ }
+
+ render() {
+ if (this.state.hasError) {
+ return (
+ <>
+ Ops... Something went wrong 😞
+ You should try the following:
+
+ Refresh the page (F5)
+
+ Resetting the application by clicking the icon, and then{' '}
+ "reset application data".
+
+
+ Contact technical support by email at{' '}
+ fg_team_hermes@equinor.com
+
+
+ >
+ )
+ }
+
+ return this.props.children
+ }
+}
+
+export default ErrorBoundary
diff --git a/web/src/Components/Common/Toast.tsx b/web/src/Components/Common/Toast.tsx
index 4dac491..70cb1df 100644
--- a/web/src/Components/Common/Toast.tsx
+++ b/web/src/Components/Common/Toast.tsx
@@ -1,8 +1,6 @@
import { toast } from 'react-toastify'
import React from 'react'
-export const InfoToast = (msg: string) => toast.info(msg)
-export const WarningToast = (msg: string) => toast.warning(msg)
export const ErrorToast = (msg: string, code?: number): any => {
const title = Error
const config: Object = { autoClose: 7000 }
diff --git a/web/src/Components/Navbar/ContactButton.tsx b/web/src/Components/Navbar/ContactButton.tsx
index 8be1671..3108881 100644
--- a/web/src/Components/Navbar/ContactButton.tsx
+++ b/web/src/Components/Navbar/ContactButton.tsx
@@ -7,11 +7,11 @@ export const ContactButton = () => {
const [dialogOpen, setDialogOpen] = useState(false)
return (
- <>
-