-
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 1 commit
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,16 +7,17 @@ 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"; | ||
| // 1. Import from react-toastify | ||
| import { ToastContainer, toast } from 'react-toastify'; | ||
| import 'react-toastify/dist/ReactToastify.css'; // Import the 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"; | ||
|
|
||
|
|
@@ -27,11 +28,12 @@ export default function Signin() { | |
| useEffect(() => { | ||
| onAuthStateChanged(auth, (user) => { | ||
| if (user) { | ||
| // This will navigate the user to the main page after a successful login | ||
| Navigate("/main"); | ||
| } | ||
| }); | ||
| // eslint-disable-next-line | ||
| }, [auth]); | ||
| }, []); // Note: The dependency array should likely be empty here | ||
|
|
||
| const NavToSignUp = () => { | ||
| Navigate("/signup"); | ||
|
|
@@ -40,28 +42,34 @@ export default function Signin() { | |
| const SignInWithGoogle = () => { | ||
| const provider = new GoogleAuthProvider(); | ||
| signInWithPopup(auth, provider) | ||
| .then((cred) => { | ||
| console.log("Log in successfully"); | ||
| .then(() => { | ||
| // 3. Add success toast for Google Sign-In | ||
| toast.success("Successfully logged in!"); | ||
| }) | ||
| .catch((err) => { | ||
| console.log(err); | ||
| // 4. Add error toast for Google Sign-In | ||
| toast.error(err.message); | ||
| }); | ||
| }; | ||
|
|
||
| const SignInWithEmailPassword = (values, actions) => { | ||
| signInWithEmailAndPassword(auth, values.email, values.password) | ||
| .then(() => { | ||
| // 3. Add success toast for Email/Password Sign-In | ||
| toast.success("Successfully logged in!"); | ||
| actions.setSubmitting(false); | ||
| console.log("Sign in Successfully"); | ||
| }) | ||
| .catch((err) => { | ||
| // 4. Add error toast for Email/Password Sign-In | ||
| 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!"> | ||
| {/* 2. Add the ToastContainer component */} | ||
| <ToastContainer position="top-right" autoClose={5000} hideProgressBar={false} /> | ||
|
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 Move ToastContainer to app root level. Rendering Recommended approach:
Example in import { ToastContainer } from 'react-toastify';
function App() {
return (
<>
<ToastContainer
position="top-right"
autoClose={5000}
hideProgressBar={false}
/>
{/* Your routes and components */}
</>
);
}Then you can call 🤖 Prompt for AI Agents |
||
| <Formik | ||
| initialValues={initialValues} | ||
| validationSchema={YupValidation} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.