From 774113edda1b9219001ef4adab3f4e19c46bcecc Mon Sep 17 00:00:00 2001
From: piotrruss <mail@pruss.it>
Date: Sat, 21 May 2022 18:42:30 +0100
Subject: refactor

---
 components/Login.jsx | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

(limited to 'components/Login.jsx')

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>
-- 
cgit v1.2.3

