aboutsummaryrefslogtreecommitdiffstats
path: root/components/Login.jsx
diff options
context:
space:
mode:
authorGravatar piotrruss <mail@pruss.it> 2022-05-21 18:42:30 +0100
committerGravatar piotrruss <mail@pruss.it> 2022-05-21 20:04:22 +0100
commit774113edda1b9219001ef4adab3f4e19c46bcecc (patch)
tree6cbf37abb72e688e5a01f2ceebe56c97874d65d7 /components/Login.jsx
parentbbdf817bc139f5d647a6508802e90370267d2af7 (diff)
downloadnotes_mobile-774113edda1b9219001ef4adab3f4e19c46bcecc.tar.gz
notes_mobile-774113edda1b9219001ef4adab3f4e19c46bcecc.tar.bz2
notes_mobile-774113edda1b9219001ef4adab3f4e19c46bcecc.zip
refactor
Diffstat (limited to 'components/Login.jsx')
-rw-r--r--components/Login.jsx19
1 files changed, 10 insertions, 9 deletions
diff --git a/components/Login.jsx b/components/Login.jsx
index 4c6ffb0..8b42913 100644
--- a/components/Login.jsx
+++ b/components/Login.jsx
@@ -1,9 +1,10 @@
-import { StyleSheet, Text, TextInput, Pressable, View } from 'react-native';
-import { useState } from 'react';
+import { StyleSheet, Text, TextInput, Pressable, View } from 'react-native'
+import { useState } from 'react'
+import { handleLogin } from '../helpers'
-const Login = ({ login }) => {
+const Login = ({ setSession, showError }) => {
const [email, setEmail] = useState('');
- const [pass, setPass] = useState('');
+ const [password, setPassword] = useState('');
const disabled = (e, p) => !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e) || p.length < 6;
return (
@@ -31,13 +32,13 @@ const Login = ({ login }) => {
autoComplete="password-new"
secureTextEntry={true}
textContentType="newPassword"
- value={pass}
- onChange={e => setPass(e.nativeEvent.text)}
+ value={password}
+ onChange={e => setPassword(e.nativeEvent.text)}
/>
<Pressable
- onPress={() => login(email, pass)}
- style={{...styles.button, opacity: disabled(email, pass) ? .3 : 1}}
- disabled={disabled(email, pass)}
+ onPress={() => handleLogin({ email, password, setSession, showError })}
+ style={{...styles.button, opacity: disabled(email, password) ? .3 : 1}}
+ disabled={disabled(email, password)}
>
<Text style={styles.buttonText}>Login</Text>
</Pressable>