2022-09-07 09:00:28 +02:00
|
|
|
import React, { FC } from 'react';
|
2021-01-31 21:36:14 -08:00
|
|
|
import classNames from 'classnames';
|
|
|
|
|
2021-02-06 22:38:58 -05:00
|
|
|
import { StatusState } from '../../utils/input-statuses';
|
2021-01-31 21:36:14 -08:00
|
|
|
|
2022-09-07 09:00:28 +02:00
|
|
|
export type FormStatusIndicatorProps = {
|
2021-01-31 21:36:14 -08:00
|
|
|
status: StatusState;
|
2022-09-07 09:00:28 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export const FormStatusIndicator: FC<FormStatusIndicatorProps> = ({ status }) => {
|
2021-01-31 21:36:14 -08:00
|
|
|
const { type, icon, message } = status || {};
|
|
|
|
const classes = classNames({
|
|
|
|
'status-container': true,
|
|
|
|
[`status-${type}`]: type,
|
|
|
|
empty: !message,
|
|
|
|
});
|
|
|
|
return (
|
2021-02-20 15:14:50 -08:00
|
|
|
<span className={classes}>
|
2021-01-31 21:36:14 -08:00
|
|
|
{icon ? <span className="status-icon">{icon}</span> : null}
|
|
|
|
{message ? <span className="status-message">{message}</span> : null}
|
2021-02-20 15:14:50 -08:00
|
|
|
</span>
|
2021-01-31 21:36:14 -08:00
|
|
|
);
|
2022-09-07 09:00:28 +02:00
|
|
|
};
|
|
|
|
export default FormStatusIndicator;
|