mirror of
https://github.com/theoludwig/theoludwig.git
synced 2024-12-08 00:44:30 +01:00
32 lines
648 B
TypeScript
32 lines
648 B
TypeScript
import useTranslation from 'next-translate/useTranslation'
|
|
|
|
import { FormState } from './FormState'
|
|
import { ResultState } from './index'
|
|
|
|
export interface FormResultProps {
|
|
state: ResultState
|
|
}
|
|
|
|
export const FormResult: React.FC<FormResultProps> = (props) => {
|
|
const { state } = props
|
|
const { t } = useTranslation()
|
|
|
|
if (state === 'idle') {
|
|
return null
|
|
}
|
|
|
|
if (state === 'loading' || state === 'success') {
|
|
return (
|
|
<FormState state={state}>
|
|
{t(`home:contact.result.${state}`)}
|
|
</FormState>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<FormState state='error'>
|
|
{t(`home:contact.result.${state}`)}
|
|
</FormState>
|
|
)
|
|
}
|