-
Notifications
You must be signed in to change notification settings - Fork 15
Added Toast for Login and signup #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: workspace
Are you sure you want to change the base?
Changes from 3 commits
251725a
7cfd8eb
d70263c
ce18863
32b6ce5
82e0f94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,31 +7,33 @@ import { | |||||||||||||||||||||||||||||||||||||||||||
| import { auth } from "../firebase"; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| import { useEffect } from "react"; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| import { useNavigate } from "react-router-dom"; | ||||||||||||||||||||||||||||||||||||||||||||
| import FormContainer from "../components/Form/FormContainer"; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| import { Button, VStack, HStack, useColorMode } from "@chakra-ui/react"; | ||||||||||||||||||||||||||||||||||||||||||||
| import { ToastContainer, toast } from 'react-toastify'; | ||||||||||||||||||||||||||||||||||||||||||||
| import 'react-toastify/dist/ReactToastify.css'; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| import FormContainer from "../components/Form/FormContainer"; | ||||||||||||||||||||||||||||||||||||||||||||
| import { Button, VStack, HStack, useColorMode } from "@chakra-ui/react"; | ||||||||||||||||||||||||||||||||||||||||||||
| import YupValidation, { initialValues } from "../components/Form/YupSignIn"; | ||||||||||||||||||||||||||||||||||||||||||||
| import TextField from "../components/Form/TextField"; | ||||||||||||||||||||||||||||||||||||||||||||
| import { Formik, Form } from "formik"; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| import { IconContext } from "react-icons"; | ||||||||||||||||||||||||||||||||||||||||||||
| import { FiLogIn } from "react-icons/fi"; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| export default function Signin() { | ||||||||||||||||||||||||||||||||||||||||||||
| const Navigate = useNavigate(); | ||||||||||||||||||||||||||||||||||||||||||||
| const { colorMode } = useColorMode(); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||
| onAuthStateChanged(auth, (user) => { | ||||||||||||||||||||||||||||||||||||||||||||
| const unsubscribe = onAuthStateChanged(auth, (user) => { | ||||||||||||||||||||||||||||||||||||||||||||
| if (user) { | ||||||||||||||||||||||||||||||||||||||||||||
| Navigate("/main"); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
| // eslint-disable-next-line | ||||||||||||||||||||||||||||||||||||||||||||
| }, [auth]); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| return () => unsubscribe(); | ||||||||||||||||||||||||||||||||||||||||||||
| }, [Navigate]); | ||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Use empty dependency array for mount-only effect. The Apply this diff: useEffect(() => {
const unsubscribe = onAuthStateChanged(auth, (user) => {
if (user) {
Navigate("/main");
}
});
return () => unsubscribe();
- }, [Navigate]);
+ }, []); 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const NavToSignUp = () => { | ||||||||||||||||||||||||||||||||||||||||||||
| Navigate("/signup"); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -40,28 +42,28 @@ export default function Signin() { | |||||||||||||||||||||||||||||||||||||||||||
| const SignInWithGoogle = () => { | ||||||||||||||||||||||||||||||||||||||||||||
| const provider = new GoogleAuthProvider(); | ||||||||||||||||||||||||||||||||||||||||||||
| signInWithPopup(auth, provider) | ||||||||||||||||||||||||||||||||||||||||||||
| .then((cred) => { | ||||||||||||||||||||||||||||||||||||||||||||
| console.log("Log in successfully"); | ||||||||||||||||||||||||||||||||||||||||||||
| .then(() => { | ||||||||||||||||||||||||||||||||||||||||||||
| toast.success("Successfully logged in!"); | ||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||
| .catch((err) => { | ||||||||||||||||||||||||||||||||||||||||||||
| console.log(err); | ||||||||||||||||||||||||||||||||||||||||||||
| toast.error(err.message); | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const SignInWithEmailPassword = (values, actions) => { | ||||||||||||||||||||||||||||||||||||||||||||
| signInWithEmailAndPassword(auth, values.email, values.password) | ||||||||||||||||||||||||||||||||||||||||||||
| .then(() => { | ||||||||||||||||||||||||||||||||||||||||||||
| toast.success("Successfully logged in!"); | ||||||||||||||||||||||||||||||||||||||||||||
| actions.setSubmitting(false); | ||||||||||||||||||||||||||||||||||||||||||||
| console.log("Sign in Successfully"); | ||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||
| .catch((err) => { | ||||||||||||||||||||||||||||||||||||||||||||
| toast.error(err.message); | ||||||||||||||||||||||||||||||||||||||||||||
| actions.setSubmitting(false); | ||||||||||||||||||||||||||||||||||||||||||||
| console.error("Something went wrong", err); | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||
| <FormContainer Icon={LoginIcon} title="Sign in for an account!"> | ||||||||||||||||||||||||||||||||||||||||||||
| <FormContainer Icon={LoginIcon} title="Sign in to your account!"> | ||||||||||||||||||||||||||||||||||||||||||||
| <Formik | ||||||||||||||||||||||||||||||||||||||||||||
| initialValues={initialValues} | ||||||||||||||||||||||||||||||||||||||||||||
| validationSchema={YupValidation} | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.