import React, { FC, ComponentType } from 'react'; import { Alert } from 'reactstrap'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faSpinner } from '@fortawesome/free-solid-svg-icons'; interface StatusIndicatorProps { error?: Error; isLoading?: boolean; customErrorMsg?: JSX.Element; componentTitle?: string; } export const withStatusIndicator = (Component: ComponentType): FC => ({ error, isLoading, customErrorMsg, componentTitle, ...rest }) => { if (error) { return ( {customErrorMsg ? ( customErrorMsg ) : ( <> Error: Error fetching {componentTitle || Component.displayName}: {error.message} )} ); } if (isLoading) { return ( ); } return ; };