Linking Firebase Databse with Signup

This commit is contained in:
Ray 2023-09-12 09:28:56 +00:00 committed by GitHub
parent 1e968638ab
commit ea64819d91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 21 deletions

View File

@ -14,6 +14,7 @@ import { Signup } from "./pages/Signup"
function App() {
const FBapp = initializeApp(FirebaseConfig)
const FBauth = getAuth(FBapp)
// navigation array
const navItems = [
{ label: "Home", link: "/" },
@ -22,31 +23,41 @@ function App() {
{ label: "Create Account", link: "/signup" },
{ label: "Log in", link: "/signin" },
]
// navigation for authenticated user
const AuthnavItems = [
// navigation for authenticated user
const AuthnavItems = [
{ label: "Home", link: "/" },
{ label: "About", link: "/about" },
{ label: "Contact", link: "/contact" },
{ label: "Log out", link: "/signout"}
]
{ label: "Log out", link: "/signout" }
]
/// application states
const [nav, setNav ] = useState( navItems )
/// application states
const [nav, setNav] = useState(navItems)
const saySomething = ( word ) => {
alert( word )
const saySomething = (word) => {
alert(word)
}
return (
<div className="App">
<Header items={nav}/>
<Routes>
<Route path="/" element={ <Home greeting="Hey you're at home!" /> } />
<Route path="/about" element={ <About greeting="Hey you, this is about page!" handler={saySomething} /> } />
<Route path="/contact" element={ <Contact greeting="Hey you, this is contact page!" /> } />
<Route path="/signup" element={ <Signup/> } />
</Routes>
</div>
);
}
export default App;
// signing up a user
const signUp = (email, password) => {
createUserWithEmailAndPassword(FBauth, email, password)
.then((userCredential) => {
// do something
})
.catch((error) => console.log(error.message))
}
return (
<div className="App">
<Header items={nav} />
<Routes>
<Route path="/" element={<Home greeting="Hey you're at home!" />} />
<Route path="/about" element={<About greeting="Hey you, this is about page!" handler={saySomething} />} />
<Route path="/contact" element={<Contact greeting="Hey you, this is contact page!" />} />
<Route path="/signup" element={<Signup />} />
</Routes>
</div>
);
}
export default App;