@computools/react-native-template-controller 1.0.39 → 1.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/template/package.json
CHANGED
@@ -26,24 +26,24 @@
|
|
26
26
|
"aab:stage": "cd android && ./gradlew clean && ./gradlew bundleStagingRelease"
|
27
27
|
},
|
28
28
|
"dependencies": {
|
29
|
-
"@hookform/resolvers": "
|
30
|
-
"@react-navigation/native": "
|
31
|
-
"@react-navigation/native-stack": "
|
32
|
-
"axios": "
|
29
|
+
"@hookform/resolvers": "4.1.3",
|
30
|
+
"@react-navigation/native": "7.0.17",
|
31
|
+
"@react-navigation/native-stack": "7.3.1",
|
32
|
+
"axios": "1.8.4",
|
33
33
|
"i18next": "24.2.2",
|
34
|
-
"mobx": "6.13.
|
34
|
+
"mobx": "6.13.7",
|
35
35
|
"mobx-react-lite": "4.1.0",
|
36
36
|
"react": "19.0.0",
|
37
37
|
"react-hook-form": "7.54.2",
|
38
|
-
"react-i18next": "15.4.
|
38
|
+
"react-i18next": "15.4.1",
|
39
39
|
"react-native": "0.78.1",
|
40
40
|
"react-native-bootsplash": "6.3.2",
|
41
41
|
"react-native-config": "1.5.3",
|
42
42
|
"react-native-mmkv": "3.2.0",
|
43
|
-
"react-native-safe-area-context": "5.
|
44
|
-
"react-native-screens": "4.9.
|
43
|
+
"react-native-safe-area-context": "5.3.0",
|
44
|
+
"react-native-screens": "4.9.2",
|
45
45
|
"react-native-svg": "15.11.2",
|
46
|
-
"
|
46
|
+
"zod": "3.24.2"
|
47
47
|
},
|
48
48
|
"devDependencies": {
|
49
49
|
"@babel/core": "^7.25.2",
|
@@ -1,18 +1,18 @@
|
|
1
|
+
import {z} from 'zod';
|
1
2
|
import React from 'react';
|
2
|
-
import * as yup from 'yup';
|
3
3
|
import {useLocalObservable} from 'mobx-react-lite';
|
4
|
-
import {
|
4
|
+
import {zodResolver} from '@hookform/resolvers/zod';
|
5
5
|
import {View, Text, StyleSheet} from 'react-native';
|
6
6
|
import {CommonActions} from '@react-navigation/native';
|
7
7
|
import {useForm, Controller, ControllerProps} from 'react-hook-form';
|
8
8
|
import {type NativeStackScreenProps} from '@react-navigation/native-stack';
|
9
9
|
|
10
|
-
import {
|
11
|
-
import {Computools} from '@ui-kit/icons/computools/Computools.icon';
|
10
|
+
import {LoginController} from './login.controller';
|
12
11
|
import {InputField} from '@ui-kit/InputField.component';
|
13
12
|
import {Button} from '@ui-kit/buttons/Button.component';
|
14
13
|
import {localization} from '@localization/localization';
|
15
|
-
import {
|
14
|
+
import {Computools} from '@ui-kit/icons/computools/Computools.icon';
|
15
|
+
import {MainStackParamsList, MainStackRoutes} from '@infra/MainStackRoutes.routes';
|
16
16
|
|
17
17
|
enum LoginField {
|
18
18
|
UserName = 'username',
|
@@ -25,13 +25,12 @@ interface Form {
|
|
25
25
|
}
|
26
26
|
|
27
27
|
const minPassLength = 8;
|
28
|
-
const schema =
|
28
|
+
const schema = z
|
29
29
|
.object({
|
30
|
-
[LoginField.UserName]:
|
31
|
-
[LoginField.Password]:
|
32
|
-
.string()
|
33
|
-
.
|
34
|
-
.min(minPassLength, localization.t('validation.minChars', {min: minPassLength})),
|
30
|
+
[LoginField.UserName]: z.string({required_error: localization.t('validation.usernameRequired')}),
|
31
|
+
[LoginField.Password]: z
|
32
|
+
.string({required_error: localization.t('validation.passRequired')})
|
33
|
+
.min(minPassLength, {message: localization.t('validation.minChars', {min: minPassLength})}),
|
35
34
|
})
|
36
35
|
.required();
|
37
36
|
|
@@ -39,7 +38,7 @@ export const Login: React.FC<NativeStackScreenProps<MainStackParamsList, MainSta
|
|
39
38
|
const controller = useLocalObservable(() => new LoginController());
|
40
39
|
const {control, handleSubmit, getValues} = useForm<Form>({
|
41
40
|
mode: 'onBlur',
|
42
|
-
resolver:
|
41
|
+
resolver: zodResolver(schema),
|
43
42
|
defaultValues: {
|
44
43
|
[LoginField.UserName]: '',
|
45
44
|
[LoginField.Password]: '',
|
@@ -1,16 +1,16 @@
|
|
1
|
+
import {z} from 'zod';
|
1
2
|
import React from 'react';
|
2
|
-
import
|
3
|
-
import {yupResolver} from '@hookform/resolvers/yup';
|
3
|
+
import {zodResolver} from '@hookform/resolvers/zod';
|
4
4
|
import {useForm, Controller, ControllerProps} from 'react-hook-form';
|
5
5
|
import {View, Text, StyleSheet, Alert, SafeAreaView} from 'react-native';
|
6
6
|
import {type NativeStackScreenProps} from '@react-navigation/native-stack';
|
7
7
|
|
8
|
-
import {MainStackParamsList, MainStackRoutes} from '@infra/MainStackRoutes.routes';
|
9
|
-
import {Computools} from '@ui-kit/icons/computools/Computools.icon';
|
10
8
|
import {InputField} from '@ui-kit/InputField.component';
|
11
9
|
import {Button} from '@ui-kit/buttons/Button.component';
|
12
10
|
import {HeaderBack} from '@ui-kit/HeaderBack.component';
|
13
11
|
import {localization} from '@localization/localization';
|
12
|
+
import {Computools} from '@ui-kit/icons/computools/Computools.icon';
|
13
|
+
import {MainStackParamsList, MainStackRoutes} from '@infra/MainStackRoutes.routes';
|
14
14
|
|
15
15
|
enum SignUpField {
|
16
16
|
UserName = 'username',
|
@@ -25,26 +25,27 @@ interface Form {
|
|
25
25
|
}
|
26
26
|
|
27
27
|
const minPassLength = 8;
|
28
|
-
const schema =
|
28
|
+
const schema = z
|
29
29
|
.object({
|
30
|
-
[SignUpField.UserName]:
|
31
|
-
[SignUpField.Password]:
|
32
|
-
.string()
|
33
|
-
.
|
34
|
-
|
35
|
-
|
36
|
-
.
|
37
|
-
.required(localization.t('validation.passRequired'))
|
38
|
-
.min(minPassLength, localization.t('validation.minChars', {min: minPassLength}))
|
39
|
-
.oneOf([yup.ref(SignUpField.Password)], localization.t('validation.passNotMatch')),
|
30
|
+
[SignUpField.UserName]: z.string().min(2, localization.t('validation.usernameRequired')),
|
31
|
+
[SignUpField.Password]: z
|
32
|
+
.string({required_error: localization.t('validation.passRequired')})
|
33
|
+
.min(minPassLength, {message: localization.t('validation.minChars', {min: minPassLength})}),
|
34
|
+
[SignUpField.RepeatPassword]: z
|
35
|
+
.string({required_error: localization.t('validation.passRequired')})
|
36
|
+
.min(minPassLength, {message: localization.t('validation.minChars', {min: minPassLength})}),
|
40
37
|
})
|
41
|
-
.required()
|
38
|
+
.required()
|
39
|
+
.refine(data => data[SignUpField.Password] === data[SignUpField.RepeatPassword], {
|
40
|
+
message: localization.t('validation.passNotMatch'),
|
41
|
+
path: [SignUpField.RepeatPassword],
|
42
|
+
});
|
42
43
|
|
43
44
|
export const SignUp: React.FC<NativeStackScreenProps<MainStackParamsList, MainStackRoutes.SignUp>> = ({route, navigation}) => {
|
44
45
|
const {username, password} = route.params || {username: '', password: ''};
|
45
46
|
const {control, handleSubmit} = useForm<Form>({
|
46
47
|
mode: 'onBlur',
|
47
|
-
resolver:
|
48
|
+
resolver: zodResolver(schema),
|
48
49
|
defaultValues: {
|
49
50
|
[SignUpField.UserName]: username,
|
50
51
|
[SignUpField.Password]: password,
|