import React, { FC } from 'react'; import { Card } from 'reactstrap'; import classNames from 'classnames'; import { faCircleNotch as preloader } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; type MessageType = 'default' | 'error'; const getClassForType = (type: MessageType) => { const map: Record = { error: 'border-danger', default: '', }; return map[type]; }; const getTextClassForType = (type: MessageType) => { const map: Record = { error: 'text-danger', default: 'text-muted', }; return map[type]; }; interface MessageProps { noMargin?: boolean; loading?: boolean; type?: MessageType; } const Message: FC = ({ children, loading = false, noMargin = false, type = 'default' }) => { const cardClasses = classNames('bg-light', getClassForType(type), { 'mt-4': !noMargin }); return (

{loading && } {loading && {children ?? 'Loading...'}} {!loading && children}

); }; export default Message;