@kiosinc/commons-rn 0.1.7
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/LICENSE +20 -0
- package/README.md +31 -0
- package/lib/commonjs/auth/api/authentication.js +20 -0
- package/lib/commonjs/auth/api/authentication.js.map +1 -0
- package/lib/commonjs/auth/appLogo.svg +9 -0
- package/lib/commonjs/auth/hooks/useAuthenticateRequests.js +52 -0
- package/lib/commonjs/auth/hooks/useAuthenticateRequests.js.map +1 -0
- package/lib/commonjs/auth/hooks/useAuthentication.js +89 -0
- package/lib/commonjs/auth/hooks/useAuthentication.js.map +1 -0
- package/lib/commonjs/auth/index.js +33 -0
- package/lib/commonjs/auth/index.js.map +1 -0
- package/lib/commonjs/auth/providers/authentication/AuthenticationProvider.js +57 -0
- package/lib/commonjs/auth/providers/authentication/AuthenticationProvider.js.map +1 -0
- package/lib/commonjs/auth/providers/authentication/actions/authentication.actions.js +13 -0
- package/lib/commonjs/auth/providers/authentication/actions/authentication.actions.js.map +1 -0
- package/lib/commonjs/auth/providers/authentication/index.js +50 -0
- package/lib/commonjs/auth/providers/authentication/index.js.map +1 -0
- package/lib/commonjs/auth/providers/authentication/reducer/authentication.reducer.js +21 -0
- package/lib/commonjs/auth/providers/authentication/reducer/authentication.reducer.js.map +1 -0
- package/lib/commonjs/auth/providers/authentication/types/authentication.types.js +11 -0
- package/lib/commonjs/auth/providers/authentication/types/authentication.types.js.map +1 -0
- package/lib/commonjs/auth/screens/LoginScreen.js +131 -0
- package/lib/commonjs/auth/screens/LoginScreen.js.map +1 -0
- package/lib/commonjs/auth/screens/ResetPassword.js +90 -0
- package/lib/commonjs/auth/screens/ResetPassword.js.map +1 -0
- package/lib/commonjs/auth/screens/ResetPasswordInstructionsSent.js +34 -0
- package/lib/commonjs/auth/screens/ResetPasswordInstructionsSent.js.map +1 -0
- package/lib/commonjs/auth/screens/SignUp.js +176 -0
- package/lib/commonjs/auth/screens/SignUp.js.map +1 -0
- package/lib/commonjs/auth/screens/SignUpPassword.js +103 -0
- package/lib/commonjs/auth/screens/SignUpPassword.js.map +1 -0
- package/lib/commonjs/auth/screens/VerifyPhoneNumber.js +95 -0
- package/lib/commonjs/auth/screens/VerifyPhoneNumber.js.map +1 -0
- package/lib/commonjs/auth/screens/index.js +37 -0
- package/lib/commonjs/auth/screens/index.js.map +1 -0
- package/lib/commonjs/auth/screens/validators.js +39 -0
- package/lib/commonjs/auth/screens/validators.js.map +1 -0
- package/lib/commonjs/components/Alert.js +109 -0
- package/lib/commonjs/components/Alert.js.map +1 -0
- package/lib/commonjs/components/Badge.js +20 -0
- package/lib/commonjs/components/Badge.js.map +1 -0
- package/lib/commonjs/components/BottomSheet.js +60 -0
- package/lib/commonjs/components/BottomSheet.js.map +1 -0
- package/lib/commonjs/components/Button.js +20 -0
- package/lib/commonjs/components/Button.js.map +1 -0
- package/lib/commonjs/components/Card.js +19 -0
- package/lib/commonjs/components/Card.js.map +1 -0
- package/lib/commonjs/components/Divider.js +19 -0
- package/lib/commonjs/components/Divider.js.map +1 -0
- package/lib/commonjs/components/FAB.js +19 -0
- package/lib/commonjs/components/FAB.js.map +1 -0
- package/lib/commonjs/components/Header.js +73 -0
- package/lib/commonjs/components/Header.js.map +1 -0
- package/lib/commonjs/components/IconButton.js +19 -0
- package/lib/commonjs/components/IconButton.js.map +1 -0
- package/lib/commonjs/components/Image.js +45 -0
- package/lib/commonjs/components/Image.js.map +1 -0
- package/lib/commonjs/components/KeyboardAvoidingView.js +23 -0
- package/lib/commonjs/components/KeyboardAvoidingView.js.map +1 -0
- package/lib/commonjs/components/LineLoader.js +61 -0
- package/lib/commonjs/components/LineLoader.js.map +1 -0
- package/lib/commonjs/components/LinkButton.js +32 -0
- package/lib/commonjs/components/LinkButton.js.map +1 -0
- package/lib/commonjs/components/OtpInputs.js +97 -0
- package/lib/commonjs/components/OtpInputs.js.map +1 -0
- package/lib/commonjs/components/ParentView.js +81 -0
- package/lib/commonjs/components/ParentView.js.map +1 -0
- package/lib/commonjs/components/Searchbar.js +22 -0
- package/lib/commonjs/components/Searchbar.js.map +1 -0
- package/lib/commonjs/components/SelectionDialog.js +130 -0
- package/lib/commonjs/components/SelectionDialog.js.map +1 -0
- package/lib/commonjs/components/Snackbar.js +69 -0
- package/lib/commonjs/components/Snackbar.js.map +1 -0
- package/lib/commonjs/components/Surface.js +19 -0
- package/lib/commonjs/components/Surface.js.map +1 -0
- package/lib/commonjs/components/Text.js +20 -0
- package/lib/commonjs/components/Text.js.map +1 -0
- package/lib/commonjs/components/TextInput.js +65 -0
- package/lib/commonjs/components/TextInput.js.map +1 -0
- package/lib/commonjs/components/ToggleButton.js +19 -0
- package/lib/commonjs/components/ToggleButton.js.map +1 -0
- package/lib/commonjs/components/Video.js +42 -0
- package/lib/commonjs/components/Video.js.map +1 -0
- package/lib/commonjs/components/View.js +20 -0
- package/lib/commonjs/components/View.js.map +1 -0
- package/lib/commonjs/components/index.js +174 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/index.js +37 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/theme/index.js +43 -0
- package/lib/commonjs/theme/index.js.map +1 -0
- package/lib/commonjs/theme/theme.js +126 -0
- package/lib/commonjs/theme/theme.js.map +1 -0
- package/lib/commonjs/theme/tokens.js +204 -0
- package/lib/commonjs/theme/tokens.js.map +1 -0
- package/lib/commonjs/types/index.d.js +2 -0
- package/lib/commonjs/types/index.d.js.map +1 -0
- package/lib/commonjs/types/svg.d.js +2 -0
- package/lib/commonjs/types/svg.d.js.map +1 -0
- package/lib/module/auth/api/authentication.js +11 -0
- package/lib/module/auth/api/authentication.js.map +1 -0
- package/lib/module/auth/appLogo.svg +9 -0
- package/lib/module/auth/hooks/useAuthenticateRequests.js +44 -0
- package/lib/module/auth/hooks/useAuthenticateRequests.js.map +1 -0
- package/lib/module/auth/hooks/useAuthentication.js +81 -0
- package/lib/module/auth/hooks/useAuthentication.js.map +1 -0
- package/lib/module/auth/index.js +5 -0
- package/lib/module/auth/index.js.map +1 -0
- package/lib/module/auth/providers/authentication/AuthenticationProvider.js +45 -0
- package/lib/module/auth/providers/authentication/AuthenticationProvider.js.map +1 -0
- package/lib/module/auth/providers/authentication/actions/authentication.actions.js +6 -0
- package/lib/module/auth/providers/authentication/actions/authentication.actions.js.map +1 -0
- package/lib/module/auth/providers/authentication/index.js +5 -0
- package/lib/module/auth/providers/authentication/index.js.map +1 -0
- package/lib/module/auth/providers/authentication/reducer/authentication.reducer.js +14 -0
- package/lib/module/auth/providers/authentication/reducer/authentication.reducer.js.map +1 -0
- package/lib/module/auth/providers/authentication/types/authentication.types.js +5 -0
- package/lib/module/auth/providers/authentication/types/authentication.types.js.map +1 -0
- package/lib/module/auth/screens/LoginScreen.js +121 -0
- package/lib/module/auth/screens/LoginScreen.js.map +1 -0
- package/lib/module/auth/screens/ResetPassword.js +82 -0
- package/lib/module/auth/screens/ResetPassword.js.map +1 -0
- package/lib/module/auth/screens/ResetPasswordInstructionsSent.js +26 -0
- package/lib/module/auth/screens/ResetPasswordInstructionsSent.js.map +1 -0
- package/lib/module/auth/screens/SignUp.js +168 -0
- package/lib/module/auth/screens/SignUp.js.map +1 -0
- package/lib/module/auth/screens/SignUpPassword.js +95 -0
- package/lib/module/auth/screens/SignUpPassword.js.map +1 -0
- package/lib/module/auth/screens/VerifyPhoneNumber.js +87 -0
- package/lib/module/auth/screens/VerifyPhoneNumber.js.map +1 -0
- package/lib/module/auth/screens/index.js +29 -0
- package/lib/module/auth/screens/index.js.map +1 -0
- package/lib/module/auth/screens/validators.js +31 -0
- package/lib/module/auth/screens/validators.js.map +1 -0
- package/lib/module/components/Alert.js +100 -0
- package/lib/module/components/Alert.js.map +1 -0
- package/lib/module/components/Badge.js +12 -0
- package/lib/module/components/Badge.js.map +1 -0
- package/lib/module/components/BottomSheet.js +52 -0
- package/lib/module/components/BottomSheet.js.map +1 -0
- package/lib/module/components/Button.js +12 -0
- package/lib/module/components/Button.js.map +1 -0
- package/lib/module/components/Card.js +11 -0
- package/lib/module/components/Card.js.map +1 -0
- package/lib/module/components/Divider.js +11 -0
- package/lib/module/components/Divider.js.map +1 -0
- package/lib/module/components/FAB.js +11 -0
- package/lib/module/components/FAB.js.map +1 -0
- package/lib/module/components/Header.js +66 -0
- package/lib/module/components/Header.js.map +1 -0
- package/lib/module/components/IconButton.js +11 -0
- package/lib/module/components/IconButton.js.map +1 -0
- package/lib/module/components/Image.js +35 -0
- package/lib/module/components/Image.js.map +1 -0
- package/lib/module/components/KeyboardAvoidingView.js +15 -0
- package/lib/module/components/KeyboardAvoidingView.js.map +1 -0
- package/lib/module/components/LineLoader.js +52 -0
- package/lib/module/components/LineLoader.js.map +1 -0
- package/lib/module/components/LinkButton.js +24 -0
- package/lib/module/components/LinkButton.js.map +1 -0
- package/lib/module/components/OtpInputs.js +87 -0
- package/lib/module/components/OtpInputs.js.map +1 -0
- package/lib/module/components/ParentView.js +72 -0
- package/lib/module/components/ParentView.js.map +1 -0
- package/lib/module/components/Searchbar.js +14 -0
- package/lib/module/components/Searchbar.js.map +1 -0
- package/lib/module/components/SelectionDialog.js +121 -0
- package/lib/module/components/SelectionDialog.js.map +1 -0
- package/lib/module/components/Snackbar.js +60 -0
- package/lib/module/components/Snackbar.js.map +1 -0
- package/lib/module/components/Surface.js +11 -0
- package/lib/module/components/Surface.js.map +1 -0
- package/lib/module/components/Text.js +12 -0
- package/lib/module/components/Text.js.map +1 -0
- package/lib/module/components/TextInput.js +56 -0
- package/lib/module/components/TextInput.js.map +1 -0
- package/lib/module/components/ToggleButton.js +11 -0
- package/lib/module/components/ToggleButton.js.map +1 -0
- package/lib/module/components/Video.js +32 -0
- package/lib/module/components/Video.js.map +1 -0
- package/lib/module/components/View.js +12 -0
- package/lib/module/components/View.js.map +1 -0
- package/lib/module/components/index.js +25 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/theme/index.js +36 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/theme/theme.js +119 -0
- package/lib/module/theme/theme.js.map +1 -0
- package/lib/module/theme/tokens.js +198 -0
- package/lib/module/theme/tokens.js.map +1 -0
- package/lib/module/types/index.d.js +2 -0
- package/lib/module/types/index.d.js.map +1 -0
- package/lib/module/types/svg.d.js +2 -0
- package/lib/module/types/svg.d.js.map +1 -0
- package/lib/typescript/src/auth/api/authentication.d.ts +4 -0
- package/lib/typescript/src/auth/api/authentication.d.ts.map +1 -0
- package/lib/typescript/src/auth/hooks/useAuthenticateRequests.d.ts +2 -0
- package/lib/typescript/src/auth/hooks/useAuthenticateRequests.d.ts.map +1 -0
- package/lib/typescript/src/auth/hooks/useAuthentication.d.ts +19 -0
- package/lib/typescript/src/auth/hooks/useAuthentication.d.ts.map +1 -0
- package/lib/typescript/src/auth/index.d.ts +5 -0
- package/lib/typescript/src/auth/index.d.ts.map +1 -0
- package/lib/typescript/src/auth/providers/authentication/AuthenticationProvider.d.ts +8 -0
- package/lib/typescript/src/auth/providers/authentication/AuthenticationProvider.d.ts.map +1 -0
- package/lib/typescript/src/auth/providers/authentication/actions/authentication.actions.d.ts +3 -0
- package/lib/typescript/src/auth/providers/authentication/actions/authentication.actions.d.ts.map +1 -0
- package/lib/typescript/src/auth/providers/authentication/index.d.ts +5 -0
- package/lib/typescript/src/auth/providers/authentication/index.d.ts.map +1 -0
- package/lib/typescript/src/auth/providers/authentication/reducer/authentication.reducer.d.ts +3 -0
- package/lib/typescript/src/auth/providers/authentication/reducer/authentication.reducer.d.ts.map +1 -0
- package/lib/typescript/src/auth/providers/authentication/types/authentication.types.d.ts +15 -0
- package/lib/typescript/src/auth/providers/authentication/types/authentication.types.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/LoginScreen.d.ts +3 -0
- package/lib/typescript/src/auth/screens/LoginScreen.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/ResetPassword.d.ts +3 -0
- package/lib/typescript/src/auth/screens/ResetPassword.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/ResetPasswordInstructionsSent.d.ts +8 -0
- package/lib/typescript/src/auth/screens/ResetPasswordInstructionsSent.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/SignUp.d.ts +9 -0
- package/lib/typescript/src/auth/screens/SignUp.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/SignUpPassword.d.ts +8 -0
- package/lib/typescript/src/auth/screens/SignUpPassword.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/VerifyPhoneNumber.d.ts +8 -0
- package/lib/typescript/src/auth/screens/VerifyPhoneNumber.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/index.d.ts +3 -0
- package/lib/typescript/src/auth/screens/index.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/validators.d.ts +36 -0
- package/lib/typescript/src/auth/screens/validators.d.ts.map +1 -0
- package/lib/typescript/src/components/Alert.d.ts +19 -0
- package/lib/typescript/src/components/Alert.d.ts.map +1 -0
- package/lib/typescript/src/components/Badge.d.ts +9 -0
- package/lib/typescript/src/components/Badge.d.ts.map +1 -0
- package/lib/typescript/src/components/BottomSheet.d.ts +7 -0
- package/lib/typescript/src/components/BottomSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/Button.d.ts +9 -0
- package/lib/typescript/src/components/Button.d.ts.map +1 -0
- package/lib/typescript/src/components/Card.d.ts +9 -0
- package/lib/typescript/src/components/Card.d.ts.map +1 -0
- package/lib/typescript/src/components/Divider.d.ts +9 -0
- package/lib/typescript/src/components/Divider.d.ts.map +1 -0
- package/lib/typescript/src/components/FAB.d.ts +9 -0
- package/lib/typescript/src/components/FAB.d.ts.map +1 -0
- package/lib/typescript/src/components/Header.d.ts +18 -0
- package/lib/typescript/src/components/Header.d.ts.map +1 -0
- package/lib/typescript/src/components/IconButton.d.ts +9 -0
- package/lib/typescript/src/components/IconButton.d.ts.map +1 -0
- package/lib/typescript/src/components/Image.d.ts +9 -0
- package/lib/typescript/src/components/Image.d.ts.map +1 -0
- package/lib/typescript/src/components/KeyboardAvoidingView.d.ts +9 -0
- package/lib/typescript/src/components/KeyboardAvoidingView.d.ts.map +1 -0
- package/lib/typescript/src/components/LineLoader.d.ts +10 -0
- package/lib/typescript/src/components/LineLoader.d.ts.map +1 -0
- package/lib/typescript/src/components/LinkButton.d.ts +9 -0
- package/lib/typescript/src/components/LinkButton.d.ts.map +1 -0
- package/lib/typescript/src/components/OtpInputs.d.ts +18 -0
- package/lib/typescript/src/components/OtpInputs.d.ts.map +1 -0
- package/lib/typescript/src/components/ParentView.d.ts +19 -0
- package/lib/typescript/src/components/ParentView.d.ts.map +1 -0
- package/lib/typescript/src/components/Searchbar.d.ts +9 -0
- package/lib/typescript/src/components/Searchbar.d.ts.map +1 -0
- package/lib/typescript/src/components/SelectionDialog.d.ts +20 -0
- package/lib/typescript/src/components/SelectionDialog.d.ts.map +1 -0
- package/lib/typescript/src/components/Snackbar.d.ts +15 -0
- package/lib/typescript/src/components/Snackbar.d.ts.map +1 -0
- package/lib/typescript/src/components/Surface.d.ts +9 -0
- package/lib/typescript/src/components/Surface.d.ts.map +1 -0
- package/lib/typescript/src/components/Text.d.ts +13 -0
- package/lib/typescript/src/components/Text.d.ts.map +1 -0
- package/lib/typescript/src/components/TextInput.d.ts +12 -0
- package/lib/typescript/src/components/TextInput.d.ts.map +1 -0
- package/lib/typescript/src/components/ToggleButton.d.ts +9 -0
- package/lib/typescript/src/components/ToggleButton.d.ts.map +1 -0
- package/lib/typescript/src/components/Video.d.ts +4 -0
- package/lib/typescript/src/components/Video.d.ts.map +1 -0
- package/lib/typescript/src/components/View.d.ts +9 -0
- package/lib/typescript/src/components/View.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +25 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/index.d.ts +284 -0
- package/lib/typescript/src/theme/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/theme.d.ts +4 -0
- package/lib/typescript/src/theme/theme.d.ts.map +1 -0
- package/lib/typescript/src/theme/tokens.d.ts +371 -0
- package/lib/typescript/src/theme/tokens.d.ts.map +1 -0
- package/package.json +191 -0
- package/src/auth/api/authentication.ts +13 -0
- package/src/auth/appLogo.svg +9 -0
- package/src/auth/hooks/useAuthenticateRequests.ts +56 -0
- package/src/auth/hooks/useAuthentication.ts +106 -0
- package/src/auth/index.ts +4 -0
- package/src/auth/providers/authentication/AuthenticationProvider.tsx +68 -0
- package/src/auth/providers/authentication/actions/authentication.actions.ts +10 -0
- package/src/auth/providers/authentication/index.ts +4 -0
- package/src/auth/providers/authentication/reducer/authentication.reducer.ts +21 -0
- package/src/auth/providers/authentication/types/authentication.types.ts +17 -0
- package/src/auth/screens/LoginScreen.tsx +140 -0
- package/src/auth/screens/ResetPassword.tsx +85 -0
- package/src/auth/screens/ResetPasswordInstructionsSent.tsx +32 -0
- package/src/auth/screens/SignUp.tsx +176 -0
- package/src/auth/screens/SignUpPassword.tsx +124 -0
- package/src/auth/screens/VerifyPhoneNumber.tsx +100 -0
- package/src/auth/screens/index.tsx +26 -0
- package/src/auth/screens/validators.ts +73 -0
- package/src/components/Alert.tsx +157 -0
- package/src/components/Badge.tsx +50 -0
- package/src/components/BottomSheet.tsx +72 -0
- package/src/components/Button.tsx +47 -0
- package/src/components/Card.tsx +47 -0
- package/src/components/Divider.tsx +47 -0
- package/src/components/FAB.tsx +47 -0
- package/src/components/Header.tsx +123 -0
- package/src/components/IconButton.tsx +47 -0
- package/src/components/Image.tsx +78 -0
- package/src/components/KeyboardAvoidingView.tsx +55 -0
- package/src/components/LineLoader.tsx +70 -0
- package/src/components/LinkButton.tsx +64 -0
- package/src/components/OtpInputs.tsx +149 -0
- package/src/components/ParentView.tsx +164 -0
- package/src/components/Searchbar.tsx +47 -0
- package/src/components/SelectionDialog.tsx +191 -0
- package/src/components/Snackbar.tsx +83 -0
- package/src/components/Surface.tsx +47 -0
- package/src/components/Text.tsx +70 -0
- package/src/components/TextInput.tsx +116 -0
- package/src/components/ToggleButton.tsx +47 -0
- package/src/components/Video.tsx +37 -0
- package/src/components/View.tsx +55 -0
- package/src/components/index.ts +24 -0
- package/src/index.tsx +5 -0
- package/src/theme/index.ts +37 -0
- package/src/theme/theme.ts +125 -0
- package/src/theme/tokens.ts +209 -0
- package/src/types/index.d.ts +1 -0
- package/src/types/svg.d.ts +4 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ParentView,
|
|
3
|
+
Text,
|
|
4
|
+
View,
|
|
5
|
+
TextInput,
|
|
6
|
+
Button,
|
|
7
|
+
LinkButton,
|
|
8
|
+
KeyboardAvoidingView,
|
|
9
|
+
Snackbar,
|
|
10
|
+
} from '../../components';
|
|
11
|
+
import { type NavigationProp, useNavigation } from '@react-navigation/native';
|
|
12
|
+
import React, { useState } from 'react';
|
|
13
|
+
import { useTranslation } from 'react-i18next';
|
|
14
|
+
import AppLogo from '../appLogo.svg';
|
|
15
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
16
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
17
|
+
import { loginValidationSchema } from './validators';
|
|
18
|
+
import auth from '@react-native-firebase/auth';
|
|
19
|
+
|
|
20
|
+
type FormData = {
|
|
21
|
+
email: string;
|
|
22
|
+
password: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const LoginScreen = () => {
|
|
26
|
+
const { t } = useTranslation();
|
|
27
|
+
const navigation = useNavigation<NavigationProp<RootStackType>>();
|
|
28
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
handleSubmit,
|
|
32
|
+
control,
|
|
33
|
+
formState: { errors },
|
|
34
|
+
} = useForm<FormData>({
|
|
35
|
+
resolver: yupResolver(loginValidationSchema),
|
|
36
|
+
defaultValues: {
|
|
37
|
+
email: '',
|
|
38
|
+
password: '',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const onSubmit = (data: FormData) => {
|
|
43
|
+
setIsLoading(true);
|
|
44
|
+
auth()
|
|
45
|
+
.signInWithEmailAndPassword(data.email, data.password)
|
|
46
|
+
.catch(() => {
|
|
47
|
+
Snackbar.show({ title: t('authentication.wrongCredentials') });
|
|
48
|
+
})
|
|
49
|
+
.finally(() => {
|
|
50
|
+
setIsLoading(false);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<ParentView px="16">
|
|
56
|
+
<KeyboardAvoidingView flex={1} justifyContent="center">
|
|
57
|
+
<View alignItems="center">
|
|
58
|
+
<AppLogo />
|
|
59
|
+
<Text py="48" variant="titleLarge">
|
|
60
|
+
{t('authentication.logIn')}
|
|
61
|
+
</Text>
|
|
62
|
+
</View>
|
|
63
|
+
<Controller
|
|
64
|
+
control={control}
|
|
65
|
+
render={({ field: { onChange, onBlur, value } }) => {
|
|
66
|
+
return (
|
|
67
|
+
<TextInput
|
|
68
|
+
my="5"
|
|
69
|
+
keyboardType="email-address"
|
|
70
|
+
autoCapitalize="none"
|
|
71
|
+
mode="outlined"
|
|
72
|
+
autoComplete="email"
|
|
73
|
+
error={!!errors.email?.message}
|
|
74
|
+
errorMessage={errors.email?.message}
|
|
75
|
+
onBlur={onBlur}
|
|
76
|
+
onChangeText={onChange}
|
|
77
|
+
value={value}
|
|
78
|
+
label={t('authentication.email')}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
}}
|
|
82
|
+
name="email"
|
|
83
|
+
/>
|
|
84
|
+
<Controller
|
|
85
|
+
control={control}
|
|
86
|
+
render={({ field: { onChange, onBlur, value } }) => {
|
|
87
|
+
return (
|
|
88
|
+
<TextInput
|
|
89
|
+
my="5"
|
|
90
|
+
secureTextEntry={true}
|
|
91
|
+
mode="outlined"
|
|
92
|
+
autoComplete="current-password"
|
|
93
|
+
error={!!errors.password?.message}
|
|
94
|
+
errorMessage={errors.password?.message}
|
|
95
|
+
onBlur={onBlur}
|
|
96
|
+
onChangeText={onChange}
|
|
97
|
+
value={value}
|
|
98
|
+
label={t('authentication.password')}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
}}
|
|
102
|
+
name="password"
|
|
103
|
+
/>
|
|
104
|
+
<LinkButton
|
|
105
|
+
alignSelf="flex-end"
|
|
106
|
+
mode="text"
|
|
107
|
+
onPress={() => {
|
|
108
|
+
navigation.navigate('ResetPassword');
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
111
|
+
{t('authentication.forgotPassword')}
|
|
112
|
+
</LinkButton>
|
|
113
|
+
<Button
|
|
114
|
+
loading={isLoading}
|
|
115
|
+
mt="38"
|
|
116
|
+
mode="contained"
|
|
117
|
+
onPress={handleSubmit(onSubmit)}
|
|
118
|
+
>
|
|
119
|
+
{t('authentication.logIn')}
|
|
120
|
+
</Button>
|
|
121
|
+
<View
|
|
122
|
+
alignItems="center"
|
|
123
|
+
justifyContent="center"
|
|
124
|
+
pt="8"
|
|
125
|
+
flexDirection="row"
|
|
126
|
+
>
|
|
127
|
+
<Text variant="labelLarge">{t('authentication.newToApp')}</Text>
|
|
128
|
+
<LinkButton
|
|
129
|
+
mode="text"
|
|
130
|
+
onPress={() => {
|
|
131
|
+
navigation.navigate('SignUp');
|
|
132
|
+
}}
|
|
133
|
+
>
|
|
134
|
+
{t('authentication.signUp')}
|
|
135
|
+
</LinkButton>
|
|
136
|
+
</View>
|
|
137
|
+
</KeyboardAvoidingView>
|
|
138
|
+
</ParentView>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ParentView,
|
|
3
|
+
Text,
|
|
4
|
+
View,
|
|
5
|
+
TextInput,
|
|
6
|
+
Button,
|
|
7
|
+
KeyboardAvoidingView,
|
|
8
|
+
} from '../../components';
|
|
9
|
+
import { type NavigationProp, useNavigation } from '@react-navigation/native';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
13
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
14
|
+
import { resetPasswordValidationSchema } from './validators';
|
|
15
|
+
import { useAuthentication } from '../hooks/useAuthentication';
|
|
16
|
+
|
|
17
|
+
type FormData = {
|
|
18
|
+
email: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const ResetPasswordScreen = () => {
|
|
22
|
+
const { t } = useTranslation();
|
|
23
|
+
const navigation = useNavigation<NavigationProp<RootStackType>>();
|
|
24
|
+
const { useResetPassword } = useAuthentication();
|
|
25
|
+
const { mutate: resetPassword, isLoading } = useResetPassword();
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
handleSubmit,
|
|
29
|
+
control,
|
|
30
|
+
formState: { errors },
|
|
31
|
+
} = useForm<FormData>({
|
|
32
|
+
resolver: yupResolver(resetPasswordValidationSchema),
|
|
33
|
+
defaultValues: {
|
|
34
|
+
email: '',
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const onSubmit = async (data: FormData) => {
|
|
39
|
+
resetPassword({ email: data.email });
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<ParentView justifyContent="center" px="16">
|
|
44
|
+
<KeyboardAvoidingView>
|
|
45
|
+
<View alignItems="center">
|
|
46
|
+
<Text py="48" textAlign="center" variant="titleLarge">
|
|
47
|
+
{t('authentication.enterYour')}
|
|
48
|
+
</Text>
|
|
49
|
+
</View>
|
|
50
|
+
<Controller
|
|
51
|
+
control={control}
|
|
52
|
+
render={({ field: { onChange, onBlur, value } }) => {
|
|
53
|
+
return (
|
|
54
|
+
<TextInput
|
|
55
|
+
keyboardType="email-address"
|
|
56
|
+
autoCapitalize="none"
|
|
57
|
+
mode="outlined"
|
|
58
|
+
autoComplete="email"
|
|
59
|
+
error={!!errors.email?.message}
|
|
60
|
+
errorMessage={errors.email?.message}
|
|
61
|
+
onBlur={onBlur}
|
|
62
|
+
onChangeText={onChange}
|
|
63
|
+
value={value}
|
|
64
|
+
label={t('authentication.email')}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
}}
|
|
68
|
+
name="email"
|
|
69
|
+
/>
|
|
70
|
+
<Button
|
|
71
|
+
loading={isLoading}
|
|
72
|
+
disabled={isLoading}
|
|
73
|
+
mt="16"
|
|
74
|
+
mode="contained"
|
|
75
|
+
onPress={handleSubmit(onSubmit)}
|
|
76
|
+
>
|
|
77
|
+
{t('authentication.resetPassword')}
|
|
78
|
+
</Button>
|
|
79
|
+
<Button mt="48" mode="outlined" onPress={navigation.goBack}>
|
|
80
|
+
{t('cancel')}
|
|
81
|
+
</Button>
|
|
82
|
+
</KeyboardAvoidingView>
|
|
83
|
+
</ParentView>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ParentView, Text, Button } from '../../components';
|
|
2
|
+
import {
|
|
3
|
+
type NavigationProp,
|
|
4
|
+
type RouteProp,
|
|
5
|
+
useNavigation,
|
|
6
|
+
} from '@react-navigation/native';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { useTranslation } from 'react-i18next';
|
|
9
|
+
|
|
10
|
+
type ResetPasswordInstructionSentProps = {
|
|
11
|
+
route: RouteProp<RootStackType, 'ResetPasswordInstructionSent'>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const ResetPasswordInstructionSent: React.FC<
|
|
15
|
+
ResetPasswordInstructionSentProps
|
|
16
|
+
> = ({ route }) => {
|
|
17
|
+
const { t } = useTranslation();
|
|
18
|
+
const navigation = useNavigation<NavigationProp<RootStackType>>();
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<ParentView justifyContent="center" px="16">
|
|
22
|
+
<Text py="48" textAlign="center" variant="titleLarge">
|
|
23
|
+
{t('authentication.resetPasswordInstructionSent', {
|
|
24
|
+
email: route.params?.email,
|
|
25
|
+
})}
|
|
26
|
+
</Text>
|
|
27
|
+
<Button mode="outlined" onPress={() => navigation.navigate('Login')}>
|
|
28
|
+
{t('authentication.backToLogin')}
|
|
29
|
+
</Button>
|
|
30
|
+
</ParentView>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ParentView,
|
|
3
|
+
Text,
|
|
4
|
+
View,
|
|
5
|
+
TextInput,
|
|
6
|
+
Button,
|
|
7
|
+
LinkButton,
|
|
8
|
+
KeyboardAvoidingView,
|
|
9
|
+
} from '../../components';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
import { StyleSheet } from 'react-native';
|
|
13
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
14
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
15
|
+
import { signUpValidationSchema } from './validators';
|
|
16
|
+
import { useAuthentication } from '../hooks/useAuthentication';
|
|
17
|
+
|
|
18
|
+
export type TUserForm = {
|
|
19
|
+
displayName: string;
|
|
20
|
+
email: string;
|
|
21
|
+
phoneNumber: string;
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const SignUpScreen = () => {
|
|
26
|
+
const { t } = useTranslation();
|
|
27
|
+
const { useIsCheckRegistered } = useAuthentication();
|
|
28
|
+
const { mutate: checkRegistration, isLoading: isCheckingIsRegistered } =
|
|
29
|
+
useIsCheckRegistered();
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
handleSubmit,
|
|
33
|
+
control,
|
|
34
|
+
formState: { errors },
|
|
35
|
+
} = useForm<TUserForm>({
|
|
36
|
+
criteriaMode: 'all',
|
|
37
|
+
resolver: yupResolver(signUpValidationSchema),
|
|
38
|
+
defaultValues: {
|
|
39
|
+
email: '',
|
|
40
|
+
name: '',
|
|
41
|
+
displayName: '',
|
|
42
|
+
phoneNumber: '',
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const onSubmit = (data: TUserForm) => {
|
|
47
|
+
checkRegistration(data);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<ParentView px="16">
|
|
52
|
+
<KeyboardAvoidingView flex={1} justifyContent="center">
|
|
53
|
+
<View alignItems="center">
|
|
54
|
+
<Text pb="40" variant="titleLarge">
|
|
55
|
+
{t('authentication.createAccountTitle')}
|
|
56
|
+
</Text>
|
|
57
|
+
</View>
|
|
58
|
+
<View justifyContent="center">
|
|
59
|
+
<Controller
|
|
60
|
+
control={control}
|
|
61
|
+
render={({ field: { onChange, onBlur, value } }) => {
|
|
62
|
+
return (
|
|
63
|
+
<TextInput
|
|
64
|
+
my="5"
|
|
65
|
+
mode="outlined"
|
|
66
|
+
error={!!errors.displayName?.message}
|
|
67
|
+
errorMessage={errors.displayName?.message}
|
|
68
|
+
onBlur={onBlur}
|
|
69
|
+
onChangeText={onChange}
|
|
70
|
+
value={value}
|
|
71
|
+
label={t('authentication.displayName')}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}}
|
|
75
|
+
name="displayName"
|
|
76
|
+
/>
|
|
77
|
+
<Controller
|
|
78
|
+
control={control}
|
|
79
|
+
render={({ field: { onChange, onBlur, value } }) => {
|
|
80
|
+
return (
|
|
81
|
+
<TextInput
|
|
82
|
+
my="5"
|
|
83
|
+
mode="outlined"
|
|
84
|
+
error={!!errors.name?.message}
|
|
85
|
+
errorMessage={errors.name?.message}
|
|
86
|
+
onBlur={onBlur}
|
|
87
|
+
onChangeText={onChange}
|
|
88
|
+
value={value}
|
|
89
|
+
label={t('authentication.businessName')}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
}}
|
|
93
|
+
name="name"
|
|
94
|
+
/>
|
|
95
|
+
<Controller
|
|
96
|
+
control={control}
|
|
97
|
+
render={({ field: { onChange, onBlur, value } }) => {
|
|
98
|
+
return (
|
|
99
|
+
<TextInput
|
|
100
|
+
my="5"
|
|
101
|
+
autoCapitalize="none"
|
|
102
|
+
keyboardType="email-address"
|
|
103
|
+
mode="outlined"
|
|
104
|
+
autoComplete="email"
|
|
105
|
+
error={!!errors.email?.message}
|
|
106
|
+
errorMessage={errors.email?.message}
|
|
107
|
+
onBlur={onBlur}
|
|
108
|
+
onChangeText={onChange}
|
|
109
|
+
value={value}
|
|
110
|
+
label={t('authentication.email')}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
}}
|
|
114
|
+
name="email"
|
|
115
|
+
/>
|
|
116
|
+
<Controller
|
|
117
|
+
control={control}
|
|
118
|
+
render={({ field: { onChange, onBlur, value } }) => {
|
|
119
|
+
return (
|
|
120
|
+
<TextInput
|
|
121
|
+
my="5"
|
|
122
|
+
mode="outlined"
|
|
123
|
+
error={!!errors.phoneNumber?.message}
|
|
124
|
+
errorMessage={errors.phoneNumber?.message}
|
|
125
|
+
onBlur={onBlur}
|
|
126
|
+
onChangeText={onChange}
|
|
127
|
+
value={value}
|
|
128
|
+
label={t('authentication.phoneNumber')}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
131
|
+
}}
|
|
132
|
+
name="phoneNumber"
|
|
133
|
+
/>
|
|
134
|
+
</View>
|
|
135
|
+
<Button
|
|
136
|
+
loading={isCheckingIsRegistered}
|
|
137
|
+
mt="48"
|
|
138
|
+
onPress={handleSubmit(onSubmit)}
|
|
139
|
+
mode="contained"
|
|
140
|
+
>
|
|
141
|
+
{t('authentication.createAccount')}
|
|
142
|
+
</Button>
|
|
143
|
+
<View flexDirection="row" flexWrap="wrap" pt="10">
|
|
144
|
+
<Text>{t('authentication.byContinue')}</Text>
|
|
145
|
+
<LinkButton
|
|
146
|
+
labelStyle={style.termsAndConditions}
|
|
147
|
+
mode="text"
|
|
148
|
+
onPress={() => {}}
|
|
149
|
+
>
|
|
150
|
+
{t('authentication.termsAndConditions')}
|
|
151
|
+
</LinkButton>
|
|
152
|
+
<Text>{t('authentication.and')}</Text>
|
|
153
|
+
<LinkButton
|
|
154
|
+
labelStyle={style.privacyPolicy}
|
|
155
|
+
mode="text"
|
|
156
|
+
onPress={() => {}}
|
|
157
|
+
>
|
|
158
|
+
{t('authentication.privacyPolicy')}
|
|
159
|
+
</LinkButton>
|
|
160
|
+
</View>
|
|
161
|
+
</KeyboardAvoidingView>
|
|
162
|
+
</ParentView>
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const style = StyleSheet.create({
|
|
167
|
+
termsAndConditions: {
|
|
168
|
+
marginHorizontal: 0,
|
|
169
|
+
marginRight: 10,
|
|
170
|
+
marginVertical: 0,
|
|
171
|
+
},
|
|
172
|
+
privacyPolicy: {
|
|
173
|
+
marginHorizontal: 10,
|
|
174
|
+
marginVertical: 0,
|
|
175
|
+
},
|
|
176
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ParentView,
|
|
3
|
+
Text,
|
|
4
|
+
View,
|
|
5
|
+
Button,
|
|
6
|
+
KeyboardAvoidingView,
|
|
7
|
+
TextInput,
|
|
8
|
+
} from '../../components';
|
|
9
|
+
import type { RouteProp } from '@react-navigation/native';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
13
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
14
|
+
import { passwordVerificationSchema } from './validators';
|
|
15
|
+
import { useAuthentication } from '../hooks/useAuthentication';
|
|
16
|
+
|
|
17
|
+
type FormData = {
|
|
18
|
+
password: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type SignUpPasswordProps = {
|
|
22
|
+
route: RouteProp<RootStackType, 'SignUpPassword'>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const SignUpPassword: React.FC<SignUpPasswordProps> = ({ route }) => {
|
|
26
|
+
const params = route.params;
|
|
27
|
+
const { t } = useTranslation();
|
|
28
|
+
const { useVerifyPhoneNumber } = useAuthentication();
|
|
29
|
+
const { mutate: verifyPhoneNumber, isLoading: isVerifyingPhoneNumber } =
|
|
30
|
+
useVerifyPhoneNumber();
|
|
31
|
+
const passwordExpectations = [
|
|
32
|
+
t('authentication.minLength'),
|
|
33
|
+
t('authentication.1lowerChar'),
|
|
34
|
+
t('authentication.1upperChar'),
|
|
35
|
+
t('authentication.1number'),
|
|
36
|
+
t('authentication.1special'),
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
handleSubmit,
|
|
41
|
+
control,
|
|
42
|
+
formState: { errors, isSubmitted },
|
|
43
|
+
} = useForm<FormData>({
|
|
44
|
+
criteriaMode: 'all',
|
|
45
|
+
resolver: yupResolver(passwordVerificationSchema),
|
|
46
|
+
defaultValues: {
|
|
47
|
+
password: '',
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const onSubmit = (data: FormData) => {
|
|
52
|
+
verifyPhoneNumber({
|
|
53
|
+
...params,
|
|
54
|
+
password: data.password,
|
|
55
|
+
} as any);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<ParentView justifyContent="center" px="16">
|
|
60
|
+
<KeyboardAvoidingView>
|
|
61
|
+
<View alignItems="center">
|
|
62
|
+
<Text textAlign="center" variant="titleLarge">
|
|
63
|
+
{t('authentication.createPassword')}
|
|
64
|
+
</Text>
|
|
65
|
+
</View>
|
|
66
|
+
<Controller
|
|
67
|
+
control={control}
|
|
68
|
+
render={({ field: { onChange, onBlur, value } }) => {
|
|
69
|
+
const passwordErrors = Object.values(
|
|
70
|
+
errors.password?.types ?? []
|
|
71
|
+
).flat();
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<View mt="48">
|
|
75
|
+
<TextInput
|
|
76
|
+
error={!!errors.password?.message}
|
|
77
|
+
my="5"
|
|
78
|
+
secureTextEntry={true}
|
|
79
|
+
mode="outlined"
|
|
80
|
+
autoComplete="new-password"
|
|
81
|
+
onBlur={onBlur}
|
|
82
|
+
onChangeText={onChange}
|
|
83
|
+
value={value}
|
|
84
|
+
label={t('authentication.password')}
|
|
85
|
+
/>
|
|
86
|
+
<Text pt="4">{t('authentication.passwordMustContain')}</Text>
|
|
87
|
+
{passwordExpectations.map((expectation, index) => {
|
|
88
|
+
const didExpectationFoundInErrors =
|
|
89
|
+
passwordErrors?.includes(expectation) ?? false;
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<View flexDirection="row" alignItems="center" key={index}>
|
|
93
|
+
<Text
|
|
94
|
+
variant="bodySmall"
|
|
95
|
+
color={
|
|
96
|
+
isSubmitted
|
|
97
|
+
? didExpectationFoundInErrors
|
|
98
|
+
? 'error'
|
|
99
|
+
: 'primary'
|
|
100
|
+
: 'onBackground'
|
|
101
|
+
}
|
|
102
|
+
>
|
|
103
|
+
{'• ' + expectation}
|
|
104
|
+
</Text>
|
|
105
|
+
</View>
|
|
106
|
+
);
|
|
107
|
+
})}
|
|
108
|
+
</View>
|
|
109
|
+
);
|
|
110
|
+
}}
|
|
111
|
+
name="password"
|
|
112
|
+
/>
|
|
113
|
+
<Button
|
|
114
|
+
mt="48"
|
|
115
|
+
loading={isVerifyingPhoneNumber}
|
|
116
|
+
mode="contained"
|
|
117
|
+
onPress={handleSubmit(onSubmit)}
|
|
118
|
+
>
|
|
119
|
+
{t('continue')}
|
|
120
|
+
</Button>
|
|
121
|
+
</KeyboardAvoidingView>
|
|
122
|
+
</ParentView>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ParentView,
|
|
3
|
+
Text,
|
|
4
|
+
View,
|
|
5
|
+
Button,
|
|
6
|
+
LinkButton,
|
|
7
|
+
OtpInputs,
|
|
8
|
+
KeyboardAvoidingView,
|
|
9
|
+
} from '../../components';
|
|
10
|
+
import type { RouteProp } from '@react-navigation/native';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { useTranslation } from 'react-i18next';
|
|
13
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
14
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
15
|
+
import { verificationValidationSchema } from './validators';
|
|
16
|
+
import { useAuthentication } from '../hooks/useAuthentication';
|
|
17
|
+
|
|
18
|
+
type FormData = {
|
|
19
|
+
code: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type VerifyPhoneNumberScreenProps = {
|
|
23
|
+
route: RouteProp<RootStackType, 'VerifyPhoneNumber'>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const VerifyPhoneNumberScreen: React.FC<
|
|
27
|
+
VerifyPhoneNumberScreenProps
|
|
28
|
+
> = ({ route }) => {
|
|
29
|
+
const params = route.params;
|
|
30
|
+
const { t } = useTranslation();
|
|
31
|
+
const { useSignUp, useVerifyPhoneNumber } = useAuthentication();
|
|
32
|
+
|
|
33
|
+
const { mutate: signUp, isLoading: isSigningUp } = useSignUp();
|
|
34
|
+
const { mutate: resendCode, isLoading: isResendingCode } =
|
|
35
|
+
useVerifyPhoneNumber();
|
|
36
|
+
|
|
37
|
+
const { handleSubmit, control } = useForm<FormData>({
|
|
38
|
+
resolver: yupResolver(verificationValidationSchema),
|
|
39
|
+
defaultValues: {
|
|
40
|
+
code: '',
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const onSubmit = (data: FormData) => {
|
|
45
|
+
signUp({ params, code: data.code } as any);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<ParentView justifyContent="center" px="16">
|
|
50
|
+
<KeyboardAvoidingView>
|
|
51
|
+
<View alignItems="center">
|
|
52
|
+
<Text pb="8" textAlign="center" variant="titleLarge">
|
|
53
|
+
{t('authentication.verifyYourNumber')}
|
|
54
|
+
</Text>
|
|
55
|
+
<Text
|
|
56
|
+
color="onSurfaceVariant"
|
|
57
|
+
pb="48"
|
|
58
|
+
textAlign="center"
|
|
59
|
+
variant="bodyLarge"
|
|
60
|
+
>
|
|
61
|
+
{t('authentication.codeSent')}
|
|
62
|
+
</Text>
|
|
63
|
+
</View>
|
|
64
|
+
<Controller
|
|
65
|
+
control={control}
|
|
66
|
+
render={({ field: { onChange, value } }) => {
|
|
67
|
+
return (
|
|
68
|
+
<OtpInputs
|
|
69
|
+
handleChange={onChange}
|
|
70
|
+
code={value}
|
|
71
|
+
numberOfInputs={6}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}}
|
|
75
|
+
name="code"
|
|
76
|
+
/>
|
|
77
|
+
<Button
|
|
78
|
+
mt="48"
|
|
79
|
+
disabled={isResendingCode}
|
|
80
|
+
loading={isSigningUp}
|
|
81
|
+
mode="contained"
|
|
82
|
+
onPress={handleSubmit(onSubmit)}
|
|
83
|
+
>
|
|
84
|
+
{t('continue')}
|
|
85
|
+
</Button>
|
|
86
|
+
<LinkButton
|
|
87
|
+
disabled={isSigningUp}
|
|
88
|
+
loading={isResendingCode}
|
|
89
|
+
mt="48"
|
|
90
|
+
mode="text"
|
|
91
|
+
onPress={() => {
|
|
92
|
+
resendCode(params as any);
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
{t('authentication.resendCode')}
|
|
96
|
+
</LinkButton>
|
|
97
|
+
</KeyboardAvoidingView>
|
|
98
|
+
</ParentView>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LoginScreen } from './LoginScreen';
|
|
3
|
+
import { ResetPasswordScreen } from './ResetPassword';
|
|
4
|
+
import { ResetPasswordInstructionSent } from './ResetPasswordInstructionsSent';
|
|
5
|
+
import { SignUpScreen } from './SignUp';
|
|
6
|
+
import { VerifyPhoneNumberScreen } from './VerifyPhoneNumber';
|
|
7
|
+
import { SignUpPassword } from './SignUpPassword';
|
|
8
|
+
|
|
9
|
+
export const renderAuthNavigator = (RootStack: any) => {
|
|
10
|
+
return (
|
|
11
|
+
<RootStack.Group>
|
|
12
|
+
<RootStack.Screen name="Login" component={LoginScreen} />
|
|
13
|
+
<RootStack.Screen name="ResetPassword" component={ResetPasswordScreen} />
|
|
14
|
+
<RootStack.Screen
|
|
15
|
+
name="ResetPasswordInstructionSent"
|
|
16
|
+
component={ResetPasswordInstructionSent}
|
|
17
|
+
/>
|
|
18
|
+
<RootStack.Screen name="SignUp" component={SignUpScreen} />
|
|
19
|
+
<RootStack.Screen
|
|
20
|
+
name="VerifyPhoneNumber"
|
|
21
|
+
component={VerifyPhoneNumberScreen}
|
|
22
|
+
/>
|
|
23
|
+
<RootStack.Screen name="SignUpPassword" component={SignUpPassword} />
|
|
24
|
+
</RootStack.Group>
|
|
25
|
+
);
|
|
26
|
+
};
|