import { FC, PropsWithChildren } from 'react'; import { Card, Row } 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]; }; export type MessageProps = PropsWithChildren<{ className?: string; loading?: boolean; fullWidth?: boolean; type?: MessageType; }>; export const Message: FC = ( { className, children, loading = false, type = 'default', fullWidth = false }, ) => { const classes = classNames({ 'col-md-12': fullWidth, 'col-md-10 offset-md-1': !fullWidth, }); return (

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

); };