chore(example): fix translation with global message
This commit is contained in:
		| @@ -7,7 +7,7 @@ import { useFormTranslation } from '../hooks/useFormTranslation' | ||||
| import { userSchema } from '../models/User' | ||||
| import { FormState } from './design/FormState' | ||||
|  | ||||
| const wait = async (ms: number): Promise<void> => { | ||||
| const simulateServerRequest = async (ms: number): Promise<void> => { | ||||
|   return await new Promise((resolve) => { | ||||
|     setTimeout(resolve, ms) | ||||
|   }) | ||||
| @@ -22,12 +22,12 @@ export const FormExample: React.FC = () => { | ||||
|     formData, | ||||
|     formElement | ||||
|   ) => { | ||||
|     await wait(4000) | ||||
|     await simulateServerRequest(4000) | ||||
|     console.log('onSubmit:', formData) | ||||
|     formElement.reset() | ||||
|     return { | ||||
|       type: 'success', | ||||
|       message: t('common:success') | ||||
|       value: 'common:success-message' | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -58,7 +58,12 @@ export const FormExample: React.FC = () => { | ||||
|           Submit | ||||
|         </Button> | ||||
|       </Form> | ||||
|       <FormState id='message' state={fetchState} message={message} /> | ||||
|  | ||||
|       <FormState | ||||
|         id='message' | ||||
|         state={fetchState} | ||||
|         message={message != null ? t(message) : undefined} | ||||
|       /> | ||||
|     </section> | ||||
|   ) | ||||
| } | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| { | ||||
|   "about": "This is an example of using <0>`react-component-form`</0> inside a Next.js application. The application shows how to use the <0>`{`<Form />`}`</0> component with the <0>`useForm`</0> hook to validate and submit a form with a <0>`name`</0> and an <0>`email`</0> input.", | ||||
|   "about": "This is an example of using <0>`react-component-form`</0> inside a Next.js application. The application shows how to use the <0>`<Form />`</0> component with the <0>`useForm`</0> hook to validate and submit a form with a <0>`name`</0> and an <0>`email`</0> input.", | ||||
|   "name": "Name", | ||||
|   "error": "Error", | ||||
|   "success": "Success", | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| { | ||||
|   "about": "Ceci est un exemple d'utilisation de <0>`react-component-form`</0> dans une application Next.js. L'application montre comment utiliser le composant <0>`{`<Form />`}`</0> avec le hook <0>`useForm`</0> hook pour valider et soumettre un formulaire avec un input `name` et `email`.", | ||||
|   "about": "Ceci est un exemple d'utilisation de <0>`react-component-form`</0> dans une application Next.js. L'application montre comment utiliser le composant <0>`<Form />`</0> avec le hook <0>`useForm`</0> hook pour valider et soumettre un formulaire avec un input `name` et `email`.", | ||||
|   "name": "Nom", | ||||
|   "error": "Erreur", | ||||
|   "success": "Succès", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user