32 lines
782 B
TypeScript
32 lines
782 B
TypeScript
import React, {Component} from 'react';
|
|
|
|
import {broker_status} from "../openapi";
|
|
import {Alert} from "@mui/material";
|
|
|
|
type MyProps = {
|
|
s?: broker_status
|
|
}
|
|
|
|
type MyState = {}
|
|
|
|
class ErrorMessage extends Component<MyProps, MyState> {
|
|
|
|
errorMessage = () : string | undefined => {
|
|
if (this.props.s === undefined)
|
|
return "Not connected to Jungfraujoch instance; check if jfjoch_broker is running"
|
|
else if (this.props.s.error_message !== undefined)
|
|
return this.props.s.error_message;
|
|
return undefined;
|
|
}
|
|
|
|
render() {
|
|
const err = this.errorMessage();
|
|
if (err === undefined)
|
|
return <></>
|
|
else
|
|
return <Alert severity="error">{err}</Alert>
|
|
}
|
|
}
|
|
|
|
export default ErrorMessage;
|