diff --git a/src/App.js b/src/App.js
index 9930120..a0099de 100644
--- a/src/App.js
+++ b/src/App.js
@@ -18,6 +18,7 @@ import { Signout } from "./pages/Signout"
import { Signin } from "./pages/Signin"
+
function App() {
const FBapp = initializeApp(FirebaseConfig)
const FBauth = getAuth()
@@ -42,6 +43,7 @@ function App() {
/// application states
const [nav, setNav] = useState(navItems)
+
// authentication observer
onAuthStateChanged(FBauth, (user) => {
if( user ) {
@@ -93,7 +95,7 @@ const signIn = ( email, password ) => {
} />
} />
} />
- } />
+ } />
);
diff --git a/src/pages/Signin.js b/src/pages/Signin.js
index cba0b36..0a23401 100644
--- a/src/pages/Signin.js
+++ b/src/pages/Signin.js
@@ -2,14 +2,16 @@ import Form from 'react-bootstrap/Form';
import Container from 'react-bootstrap/Container';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
-import Button from "react-bootstrap/Button"
+import Button from "react-bootstrap/Button";
import {useState, useEffect} from 'react';
+import {useNavigate} from 'react-router-dom';
export function Signin ( props ) {
const [email, setEmail] = useState('')
const [validemail, setValidemail] = useState(false)
const [password, setPassword] = useState('')
const [validpassword, setValidpassword] = useState(false)
+ const navigate = useNavigate()
useEffect( () => {
if(email.indexOf('@') > 0) {
@@ -28,12 +30,23 @@ export function Signin ( props ) {
setValidpassword( false )
}
}, [password])
+
+ useEffect( () => {
+ if( props.authstate ) {
+ navigate('/')
+ }
+ }, [props.authstate])
+
+ const submitHandler = (evt) => {
+ evt.preventDefault()
+ props.handler( email, password )
+ }
return (
-
Email
@@ -44,7 +57,10 @@ export function Signin ( props ) {
name="email"
placeholder="you@example.com"
-
+
+ value={email}
+
+ onChange={ (evt) => setEmail(evt.target.value)}
/>
@@ -62,6 +78,10 @@ export function Signin ( props ) {
name="password"
placeholder="minimum 8 characters"
+
+ value={ password }
+
+ onChange={ (evt) => setPassword(evt.target.value)}
@@ -71,7 +91,10 @@ export function Signin ( props ) {