@@ -3,27 +3,32 @@ import { type SubmitHandler, useForm } from 'react-hook-form';
33import { KeyboardAvoidingView } from 'react-native' ;
44import z from 'zod' ;
55
6- import { Button , ControlledInput , Text , View } from '@/ui' ;
6+ import { translate } from '@/core' ;
7+ import { Button , ControlledInput , Text , View } from '@/ui' ;
78
89const MIN_PASSWORD_LENGTH = 6 ;
910
1011const passwordSchema = z
11- . string ( { required_error : 'Password is required' } )
12- . min ( MIN_PASSWORD_LENGTH , 'Password must be at least 6 characters' ) ;
12+ . string ( { required_error : translate ( 'auth.sign_up.error.passwordRequired' ) } )
13+ . min ( MIN_PASSWORD_LENGTH , translate ( 'auth.sign_up.error.shortPassword' ) ) ;
1314
1415const schema = z
1516 . object ( {
1617 email : z
17- . string ( { required_error : 'Email is required' } )
18- . email ( 'Invalid email format' ) ,
19- name : z . string ( { required_error : 'Name is required' } ) ,
18+ . string ( { required_error : translate ( 'auth.sign_up.error.emailRequired' ) } )
19+ . email ( translate ( 'auth.sign_up.error.emailInvalid' ) ) ,
20+ name : z . string ( {
21+ required_error : translate ( 'auth.sign_up.error.nameRequired' ) ,
22+ } ) ,
2023 password : passwordSchema ,
2124 passwordConfirmation : z . string ( {
22- required_error : 'Password confirmation is required' ,
25+ required_error : translate (
26+ 'auth.sign_up.error.passwordConfirmationRequired' ,
27+ ) ,
2328 } ) ,
2429 } )
2530 . refine ( ( data ) => data . password === data . passwordConfirmation , {
26- message : 'Passwords do not match' ,
31+ message : translate ( 'auth.sign_up.error.passwordsDoNotMatch' ) ,
2732 path : [ 'passwordConfirmation' ] ,
2833 } ) ;
2934
@@ -48,49 +53,50 @@ export const SignUpForm = ({
4853 behavior = "padding"
4954 keyboardVerticalOffset = { 10 }
5055 >
51- < View className = "flex-1 justify-center p-4" >
52- < Text testID = "form-title" className = "pb-6 text-center text-2xl" >
53- Sign Up
56+ < View className = "flex-1 justify-center gap-4 p-4" >
57+ < Text testID = "form-title" className = "text-center text-2xl" >
58+ { translate ( 'auth.sign_up.title' ) }
5459 </ Text >
60+ < View >
61+ < ControlledInput
62+ testID = "email-input"
63+ autoCapitalize = "none"
64+ autoComplete = "email"
65+ control = { control }
66+ name = "email"
67+ label = { translate ( 'auth.sign_up.fields.email' ) }
68+ />
69+ < ControlledInput
70+ testID = "name-input"
71+ control = { control }
72+ name = "name"
73+ label = { translate ( 'auth.sign_up.fields.name' ) }
74+ />
75+ < ControlledInput
76+ testID = "password-input"
77+ control = { control }
78+ name = "password"
79+ label = { translate ( 'auth.sign_up.fields.password' ) }
80+ placeholder = "***"
81+ secureTextEntry = { true }
82+ />
83+ < ControlledInput
84+ testID = "password-confirmation-input"
85+ control = { control }
86+ name = "passwordConfirmation"
87+ label = { translate ( 'auth.sign_up.fields.password' ) }
88+ placeholder = "***"
89+ secureTextEntry = { true }
90+ />
5591
56- < ControlledInput
57- testID = "email-input"
58- autoCapitalize = "none"
59- autoComplete = "email"
60- control = { control }
61- name = "email"
62- label = "Email"
63- />
64- < ControlledInput
65- testID = "name-input"
66- control = { control }
67- name = "name"
68- label = "Name"
69- />
70- < ControlledInput
71- testID = "password-input"
72- control = { control }
73- name = "password"
74- label = "Password"
75- placeholder = "***"
76- secureTextEntry = { true }
77- />
78- < ControlledInput
79- testID = "password-confirmation-input"
80- control = { control }
81- name = "passwordConfirmation"
82- label = "Password Confirmation"
83- placeholder = "***"
84- secureTextEntry = { true }
85- />
86-
87- < Button
88- testID = "sign-up-button"
89- label = "Sign Up"
90- onPress = { handleSubmit ( onSubmit ) }
91- loading = { isPending }
92- disabled = { isPending }
93- />
92+ < Button
93+ testID = "sign-up-button"
94+ label = { translate ( 'auth.sign_up.signUpButton' ) }
95+ onPress = { handleSubmit ( onSubmit ) }
96+ loading = { isPending }
97+ disabled = { isPending }
98+ />
99+ </ View >
94100 </ View >
95101 </ KeyboardAvoidingView >
96102 ) ;
0 commit comments