2022-09-07 10:00:28 +03:00
|
|
|
import React, { FC } from 'react';
|
2021-02-01 08:36:14 +03:00
|
|
|
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
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export type FormStatusIndicatorProps = {
|
2021-02-01 08:36:14 +03:00
|
|
|
status: StatusState;
|
2022-09-07 10:00:28 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export const FormStatusIndicator: FC<FormStatusIndicatorProps> = ({ status }) => {
|
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
|
|
|
);
|
2022-09-07 10:00:28 +03:00
|
|
|
};
|
|
|
|
export default FormStatusIndicator;
|