import classNames from 'classnames' import useTranslation from 'next-translate/useTranslation' import { FetchState as FormStateType } from '../../../hooks/useFetchState' import { Loader } from '../Loader' export interface FormStateProps extends React.ComponentPropsWithoutRef<'div'> { state: FormStateType message?: string | null id?: string } export const FormState: React.FC = (props) => { const { state, message, id, ...rest } = props const { t } = useTranslation() if (state === 'loading') { return (
) } if (state === 'idle' || message == null) { return null } return ( <>
{t(`errors:${state}`)}: {message}
) }