mirror of
https://github.com/theoludwig/theoludwig.git
synced 2024-12-08 00:44:30 +01:00
40 lines
909 B
TypeScript
40 lines
909 B
TypeScript
|
import useTranslation from 'next-translate/useTranslation'
|
||
|
|
||
|
export interface FormStateProps extends React.ComponentPropsWithRef<'p'> {
|
||
|
state: 'success' | 'error' | 'loading'
|
||
|
children: string
|
||
|
}
|
||
|
|
||
|
export const FormState: React.FC<FormStateProps> = props => {
|
||
|
const { state, children, ...rest } = props
|
||
|
const { t } = useTranslation()
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
<div className='form-result text-center'>
|
||
|
<p className={state} {...rest}>
|
||
|
{['error', 'success'].includes(state) && (
|
||
|
<b>
|
||
|
{state === 'error' ? t('home:contact.error') : t('home:contact.success')}:
|
||
|
</b>
|
||
|
)}{' '}
|
||
|
{children}
|
||
|
</p>
|
||
|
</div>
|
||
|
|
||
|
<style jsx>{`
|
||
|
.form-result {
|
||
|
margin: 30px;
|
||
|
}
|
||
|
.success {
|
||
|
color: #90ee90;
|
||
|
}
|
||
|
.error {
|
||
|
color: #ff7f7f;
|
||
|
}
|
||
|
`}
|
||
|
</style>
|
||
|
</>
|
||
|
)
|
||
|
}
|