hey all! apologies if this is gonna be a bit of a code dump but i was hoping that this could be the right place for help, basically im trying to make an email and pwd login page using Next JS and Firebase but im not sure if i am able to conditionally route my my dashboard page based on if the log in details are correct using Next/Link, this is what i have so far!
const LoginMobile = () => {
initFirebase()
const [data, setData] = useState({
email: '',
pwd: ''
});
const auth = getAuth();
const handleLogin = () => {
signInWithEmailAndPassword(auth, data.email, data.pwd)
.then((userCredential) => {
// Signed in
const user = userCredential.user;
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
alert("Incorrect Details! ")
});
}
return(
<div className="[tons of styling]">
<form className="[tons of styling]">
<label className="[tons of styling]>
LOGIN
</label>
<LoginInput
placeholder="Email address"
type="text"
value={data.email}
onChange={(e: any) => setData({...data, email: e.target.value})} />
<LoginInput
placeholder="Password"
type="password"
value={data.pwd}
onChange={(e: any) => setData({...data, pwd: e.target.value})} />
//this button is custom with styles
<Button>
Sign In
</Button>
<Link href={"/dashboard"}>
Link
</Link>
</form>
</div>
)
}