import classNames from "clsx" import useTranslation from "next-translate/useTranslation" import type { FetchState as FormStateType } from "react-component-form" import { Loader } from "./Loader" export interface FormStateProps extends React.ComponentPropsWithoutRef<"div"> { state: FormStateType message?: string 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(`common:${state}`)}: {message}
) }