@kiosinc/commons-rn 0.1.42 → 0.1.44
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/lib/commonjs/auth/api/authentication.js.map +1 -1
- package/lib/commonjs/auth/hooks/useAuthentication.js +26 -1
- package/lib/commonjs/auth/hooks/useAuthentication.js.map +1 -1
- package/lib/commonjs/auth/index.js +6 -0
- package/lib/commonjs/auth/index.js.map +1 -1
- package/lib/commonjs/auth/screens/ChangePassword.js +134 -0
- package/lib/commonjs/auth/screens/ChangePassword.js.map +1 -0
- package/lib/commonjs/auth/screens/Login.js +130 -0
- package/lib/commonjs/auth/screens/Login.js.map +1 -0
- package/lib/commonjs/auth/screens/{LoginScreen.js → LoginWithEmail.js} +12 -57
- package/lib/commonjs/auth/screens/LoginWithEmail.js.map +1 -0
- package/lib/commonjs/auth/screens/LoginWithPhoneNumber.js +87 -0
- package/lib/commonjs/auth/screens/LoginWithPhoneNumber.js.map +1 -0
- package/lib/commonjs/auth/screens/ResetPassword.js +3 -3
- package/lib/commonjs/auth/screens/ResetPassword.js.map +1 -1
- package/lib/commonjs/auth/screens/SignUp.js +3 -3
- package/lib/commonjs/auth/screens/SignUp.js.map +1 -1
- package/lib/commonjs/auth/screens/VerifyPhoneNumber.js +6 -4
- package/lib/commonjs/auth/screens/VerifyPhoneNumber.js.map +1 -1
- package/lib/commonjs/auth/screens/VerifyPhoneNumberForLogin.js +109 -0
- package/lib/commonjs/auth/screens/VerifyPhoneNumberForLogin.js.map +1 -0
- package/lib/commonjs/auth/screens/index.js +19 -7
- package/lib/commonjs/auth/screens/index.js.map +1 -1
- package/lib/commonjs/auth/screens/validators.js +10 -1
- package/lib/commonjs/auth/screens/validators.js.map +1 -1
- package/lib/module/auth/api/authentication.js.map +1 -1
- package/lib/module/auth/hooks/useAuthentication.js +26 -1
- package/lib/module/auth/hooks/useAuthentication.js.map +1 -1
- package/lib/module/auth/index.js +1 -1
- package/lib/module/auth/index.js.map +1 -1
- package/lib/module/auth/screens/ChangePassword.js +124 -0
- package/lib/module/auth/screens/ChangePassword.js.map +1 -0
- package/lib/module/auth/screens/Login.js +120 -0
- package/lib/module/auth/screens/Login.js.map +1 -0
- package/lib/module/auth/screens/{LoginScreen.js → LoginWithEmail.js} +12 -57
- package/lib/module/auth/screens/LoginWithEmail.js.map +1 -0
- package/lib/module/auth/screens/LoginWithPhoneNumber.js +78 -0
- package/lib/module/auth/screens/LoginWithPhoneNumber.js.map +1 -0
- package/lib/module/auth/screens/ResetPassword.js +1 -1
- package/lib/module/auth/screens/ResetPassword.js.map +1 -1
- package/lib/module/auth/screens/SignUp.js +1 -1
- package/lib/module/auth/screens/SignUp.js.map +1 -1
- package/lib/module/auth/screens/VerifyPhoneNumber.js +4 -2
- package/lib/module/auth/screens/VerifyPhoneNumber.js.map +1 -1
- package/lib/module/auth/screens/VerifyPhoneNumberForLogin.js +101 -0
- package/lib/module/auth/screens/VerifyPhoneNumberForLogin.js.map +1 -0
- package/lib/module/auth/screens/index.js +19 -8
- package/lib/module/auth/screens/index.js.map +1 -1
- package/lib/module/auth/screens/validators.js +7 -0
- package/lib/module/auth/screens/validators.js.map +1 -1
- package/lib/typescript/src/auth/api/authentication.d.ts +6 -1
- package/lib/typescript/src/auth/api/authentication.d.ts.map +1 -1
- package/lib/typescript/src/auth/hooks/useAuthentication.d.ts +12 -1
- package/lib/typescript/src/auth/hooks/useAuthentication.d.ts.map +1 -1
- package/lib/typescript/src/auth/index.d.ts +1 -1
- package/lib/typescript/src/auth/index.d.ts.map +1 -1
- package/lib/typescript/src/auth/screens/ChangePassword.d.ts +12 -0
- package/lib/typescript/src/auth/screens/ChangePassword.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/Login.d.ts +3 -0
- package/lib/typescript/src/auth/screens/Login.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/LoginWithEmail.d.ts +3 -0
- package/lib/typescript/src/auth/screens/LoginWithEmail.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/LoginWithPhoneNumber.d.ts +3 -0
- package/lib/typescript/src/auth/screens/LoginWithPhoneNumber.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/ResetPassword.d.ts +1 -1
- package/lib/typescript/src/auth/screens/ResetPassword.d.ts.map +1 -1
- package/lib/typescript/src/auth/screens/SignUp.d.ts +1 -1
- package/lib/typescript/src/auth/screens/SignUp.d.ts.map +1 -1
- package/lib/typescript/src/auth/screens/VerifyPhoneNumber.d.ts +2 -2
- package/lib/typescript/src/auth/screens/VerifyPhoneNumber.d.ts.map +1 -1
- package/lib/typescript/src/auth/screens/VerifyPhoneNumberForLogin.d.ts +8 -0
- package/lib/typescript/src/auth/screens/VerifyPhoneNumberForLogin.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/index.d.ts +1 -0
- package/lib/typescript/src/auth/screens/index.d.ts.map +1 -1
- package/lib/typescript/src/auth/screens/validators.d.ts +12 -0
- package/lib/typescript/src/auth/screens/validators.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/auth/api/authentication.ts +6 -1
- package/src/auth/hooks/useAuthentication.ts +20 -1
- package/src/auth/index.ts +1 -1
- package/src/auth/screens/ChangePassword.tsx +138 -0
- package/src/auth/screens/Login.tsx +140 -0
- package/src/auth/screens/LoginWithEmail.tsx +120 -0
- package/src/auth/screens/LoginWithPhoneNumber.tsx +78 -0
- package/src/auth/screens/ResetPassword.tsx +1 -1
- package/src/auth/screens/SignUp.tsx +1 -1
- package/src/auth/screens/VerifyPhoneNumber.tsx +8 -6
- package/src/auth/screens/VerifyPhoneNumberForLogin.tsx +112 -0
- package/src/auth/screens/index.tsx +22 -8
- package/src/auth/screens/validators.ts +11 -0
- package/lib/commonjs/auth/screens/LoginScreen.js.map +0 -1
- package/lib/module/auth/screens/LoginScreen.js.map +0 -1
- package/lib/typescript/src/auth/screens/LoginScreen.d.ts +0 -3
- package/lib/typescript/src/auth/screens/LoginScreen.d.ts.map +0 -1
- package/src/auth/screens/LoginScreen.tsx +0 -172
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ParentView,
|
|
3
|
-
Text,
|
|
4
|
-
View,
|
|
5
|
-
TextInput,
|
|
6
|
-
Button,
|
|
7
|
-
LinkButton,
|
|
8
|
-
KeyboardAvoidingView,
|
|
9
|
-
Snackbar,
|
|
10
|
-
Header,
|
|
11
|
-
} from '../../components';
|
|
12
|
-
import { type NavigationProp, useNavigation } from '@react-navigation/native';
|
|
13
|
-
import React, { useEffect, useState } from 'react';
|
|
14
|
-
import { useTranslation } from 'react-i18next';
|
|
15
|
-
import AppLogo from '../../assets/icons/appLogo.svg';
|
|
16
|
-
import { Controller, useForm } from 'react-hook-form';
|
|
17
|
-
import { yupResolver } from '@hookform/resolvers/yup';
|
|
18
|
-
import { loginValidationSchema } from './validators';
|
|
19
|
-
import auth from '@react-native-firebase/auth';
|
|
20
|
-
import { useMMKVString } from 'react-native-mmkv';
|
|
21
|
-
import { MMKV_KEYS } from '../../constants';
|
|
22
|
-
import FastImage from 'react-native-fast-image';
|
|
23
|
-
import Config from 'react-native-config';
|
|
24
|
-
import { useQueryClient } from '@tanstack/react-query';
|
|
25
|
-
import { StyleSheet } from 'react-native';
|
|
26
|
-
|
|
27
|
-
type FormData = {
|
|
28
|
-
email: string;
|
|
29
|
-
password: string;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const LoginScreen = () => {
|
|
33
|
-
const { t } = useTranslation();
|
|
34
|
-
const navigation = useNavigation<NavigationProp<RootStackType>>();
|
|
35
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
36
|
-
|
|
37
|
-
const [_, setBusinessId] = useMMKVString(MMKV_KEYS.BUSINESS_ID);
|
|
38
|
-
const queryClient = useQueryClient();
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
queryClient.invalidateQueries();
|
|
41
|
-
setBusinessId(undefined);
|
|
42
|
-
FastImage.clearMemoryCache();
|
|
43
|
-
FastImage.clearDiskCache();
|
|
44
|
-
}, [queryClient, setBusinessId]);
|
|
45
|
-
|
|
46
|
-
const {
|
|
47
|
-
handleSubmit,
|
|
48
|
-
control,
|
|
49
|
-
formState: { errors },
|
|
50
|
-
} = useForm<FormData>({
|
|
51
|
-
resolver: yupResolver(loginValidationSchema(t)),
|
|
52
|
-
defaultValues: {
|
|
53
|
-
email: '',
|
|
54
|
-
password: '',
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const onSubmit = (data: FormData) => {
|
|
59
|
-
setIsLoading(true);
|
|
60
|
-
auth()
|
|
61
|
-
.signInWithEmailAndPassword(data.email, data.password)
|
|
62
|
-
.catch(() => {
|
|
63
|
-
Snackbar.show({ title: t('authentication.wrongCredentials') });
|
|
64
|
-
})
|
|
65
|
-
.finally(() => {
|
|
66
|
-
setIsLoading(false);
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<ParentView px="16">
|
|
72
|
-
<Header left={10} position={'absolute'} zIndex={'100'} />
|
|
73
|
-
<View flex={1} justifyContent={'center'}>
|
|
74
|
-
<KeyboardAvoidingView
|
|
75
|
-
flex={1}
|
|
76
|
-
behavior="padding"
|
|
77
|
-
alignSelf="center"
|
|
78
|
-
justifyContent={'center'}
|
|
79
|
-
width={{ phone: '100%', tablet: 372 }}
|
|
80
|
-
>
|
|
81
|
-
<View alignItems="center">
|
|
82
|
-
<AppLogo />
|
|
83
|
-
<Text style={styles.text} variant="titleLarge">
|
|
84
|
-
{t('authentication.logIn')}
|
|
85
|
-
</Text>
|
|
86
|
-
</View>
|
|
87
|
-
<Controller
|
|
88
|
-
control={control}
|
|
89
|
-
render={({ field: { onChange, onBlur, value } }) => {
|
|
90
|
-
return (
|
|
91
|
-
<TextInput
|
|
92
|
-
my="5"
|
|
93
|
-
keyboardType="email-address"
|
|
94
|
-
autoCapitalize="none"
|
|
95
|
-
mode="outlined"
|
|
96
|
-
autoComplete="email"
|
|
97
|
-
error={!!errors.email?.message}
|
|
98
|
-
errorMessage={errors.email?.message}
|
|
99
|
-
onBlur={onBlur}
|
|
100
|
-
onChangeText={onChange}
|
|
101
|
-
value={value}
|
|
102
|
-
label={t('authentication.email')}
|
|
103
|
-
/>
|
|
104
|
-
);
|
|
105
|
-
}}
|
|
106
|
-
name="email"
|
|
107
|
-
/>
|
|
108
|
-
<Controller
|
|
109
|
-
control={control}
|
|
110
|
-
render={({ field: { onChange, onBlur, value } }) => {
|
|
111
|
-
return (
|
|
112
|
-
<TextInput
|
|
113
|
-
my="5"
|
|
114
|
-
secureTextEntry={true}
|
|
115
|
-
mode="outlined"
|
|
116
|
-
autoComplete="current-password"
|
|
117
|
-
error={!!errors.password?.message}
|
|
118
|
-
errorMessage={errors.password?.message}
|
|
119
|
-
onBlur={onBlur}
|
|
120
|
-
onChangeText={onChange}
|
|
121
|
-
value={value}
|
|
122
|
-
label={t('authentication.password')}
|
|
123
|
-
/>
|
|
124
|
-
);
|
|
125
|
-
}}
|
|
126
|
-
name="password"
|
|
127
|
-
/>
|
|
128
|
-
<LinkButton
|
|
129
|
-
alignSelf="flex-end"
|
|
130
|
-
mode="text"
|
|
131
|
-
onPress={() => {
|
|
132
|
-
navigation.navigate('ResetPassword');
|
|
133
|
-
}}
|
|
134
|
-
>
|
|
135
|
-
{t('authentication.forgotPassword')}
|
|
136
|
-
</LinkButton>
|
|
137
|
-
<Button
|
|
138
|
-
loading={isLoading}
|
|
139
|
-
style={styles.button}
|
|
140
|
-
mode="contained"
|
|
141
|
-
onPress={handleSubmit(onSubmit)}
|
|
142
|
-
>
|
|
143
|
-
{t('authentication.logIn')}
|
|
144
|
-
</Button>
|
|
145
|
-
{Config.APP_NAME !== 'git' && (
|
|
146
|
-
<View
|
|
147
|
-
alignItems="center"
|
|
148
|
-
justifyContent="center"
|
|
149
|
-
pt="8"
|
|
150
|
-
flexDirection="row"
|
|
151
|
-
>
|
|
152
|
-
<Text variant="labelLarge">{t('authentication.newToApp')}</Text>
|
|
153
|
-
<LinkButton
|
|
154
|
-
mode="text"
|
|
155
|
-
onPress={() => {
|
|
156
|
-
navigation.navigate('SignUp');
|
|
157
|
-
}}
|
|
158
|
-
>
|
|
159
|
-
{t('authentication.signUp')}
|
|
160
|
-
</LinkButton>
|
|
161
|
-
</View>
|
|
162
|
-
)}
|
|
163
|
-
</KeyboardAvoidingView>
|
|
164
|
-
</View>
|
|
165
|
-
</ParentView>
|
|
166
|
-
);
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const styles = StyleSheet.create({
|
|
170
|
-
button: { marginVertical: '5%' },
|
|
171
|
-
text: { paddingVertical: '5%' },
|
|
172
|
-
});
|