@equinor/fusion-react-power-bi
Version:
React component for displaying an person information
30 lines • 1.69 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useContext } from 'react';
// import { ErrorMessage } from '@equinor/fusion-components';
import { useSelector } from '@equinor/fusion/lib/epic';
import { context } from '../../context';
import { processActionError } from './process-action-error';
import PowerBIReportInfo from '../../../ReportInfo';
import processReportInfoError from './process-reportInfo-error';
const ErrorMessage = (props) => {
return (_jsxs("div", { children: [_jsx("h1", { style: { color: 'red' }, children: "missing error message container" }), _jsx("h2", { children: props.title }), _jsx("p", { children: props.title })] }));
};
// TODO: move me
const compareArray = (a, b) => a.length === b.length && a.every((value, index) => value.action === b[index].action);
export const PowerBIReportErrorBoundary = (props) => {
const { store } = useContext(context);
const id = useSelector(store, 'id');
const errors = useSelector(store, 'errors', compareArray);
const reportInfoError = errors?.find(({ error }) => error.statusCode === 403);
if (reportInfoError) {
const reportInfoErrorString = processReportInfoError(reportInfoError);
return _jsx(PowerBIReportInfo, { id: id || '', ...reportInfoErrorString });
}
if (errors?.length) {
const { title, message, type } = processActionError(errors[0]);
return _jsx(ErrorMessage, { hasError: true, title: title, message: message, errorType: type });
}
return _jsx(_Fragment, { children: props.children });
};
export default PowerBIReportErrorBoundary;
//# sourceMappingURL=PowerBIReportErrorBoundary.js.map