From b84fe9a9c4c18a3f4e957f76ead34403c4316f76 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Wed, 20 Dec 2023 19:40:11 +0200 Subject: Added a simple Login and SignUp page for the web driver app --- driver/src/pages/Login.tsx | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 driver/src/pages/Login.tsx (limited to 'driver/src/pages/Login.tsx') diff --git a/driver/src/pages/Login.tsx b/driver/src/pages/Login.tsx new file mode 100644 index 0000000..0605dc8 --- /dev/null +++ b/driver/src/pages/Login.tsx @@ -0,0 +1,66 @@ +import { useState } from 'react'; +import { auth } from '../firebase/firebase_config'; +import { signInWithEmailAndPassword } from 'firebase/auth'; + +const Login = () => { + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + + const handleLogin = async () => { + try { + const userCredential = await signInWithEmailAndPassword(auth, email, password); + console.log('User logged in:', userCredential.user); + // TODO: redirect the user to another page or perform some other action + } catch (error) { + console.error('Error logging in:', error); + // TODO: Handle error messages or display them to the user. + } + }; + + return ( +
+
+

Login

+
+
+ + setEmail(e.target.value)} + /> +
+
+ + setPassword(e.target.value)} + /> +
+
+ +
+
+
+
+ ); +}; + +export default Login; -- cgit v1.2.3