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