Skip to content

Conversation

@Saikiran-Sugurthi
Copy link

@Saikiran-Sugurthi Saikiran-Sugurthi commented Oct 9, 2025

Done with adding Toasts for Signup and SignIn ... i have just worked on frontend and have not disturbed any backend code ...so the toast is showing firebase error on my local machine..it works fine on deployement ..
Screenshot 2025-10-09 184736

Summary by CodeRabbit

  • New Features

    • Global on-screen toast notifications for sign-in, sign-up and auth outcomes; friendly error messages shown.
  • Bug Fixes

    • Sign-up uses correct password value.
    • Auth-state listener unsubscribes on unmount; console logs replaced with user-facing toasts.
    • Sign-in UI text changed to “Sign in to your account!”.
  • Chores

    • After successful sign-up, users are redirected to Sign In after a brief delay.

@coderabbitai
Copy link

coderabbitai bot commented Oct 9, 2025

Walkthrough

Adds react-toastify usage across App, SignIn, and SignUp; replaces console logs with toast.success/toast.error for auth outcomes; SignIn useEffect now returns the onAuthStateChanged unsubscribe; SignUp uses values.password for account creation and navigates to /signin after success.

Changes

Cohort / File(s) Summary
Top-level app: global toasts
src/App.js
Imported ToastContainer and its CSS; added a global <ToastContainer /> before <Routes /> with position/autoClose/hideProgressBar/closeOnClick/pauseOnHover props.
Sign-in page: toast, auth cleanup, text update
src/pages/SignIn.js
Imported toast and toast CSS; added getAuthErrorMessage mapping; replaced console logs with toast.success/toast.error for Google and email/password flows; added a ToastContainer to the component; useEffect subscribes to onAuthStateChanged and returns the unsubscribe; title text changed to "Sign in to your account!".
Sign-up page: toast, correct password usage, navigation
src/pages/SignUp.js
Imported ToastContainer, toast, and CSS; added getSignUpErrorMessage mapping; rendered <ToastContainer />; use values.password (not confirmPassword) for createUserWithEmailAndPassword; show toast.success on success and toast.error on failure; navigate to /signin after success (triggered on toast close).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant App
  participant SignIn
  participant SignUp
  participant Auth
  participant Toast
  participant Router

  rect rgba(230,240,255,0.6)
    note over App: Global ToastContainer added
  end

  User->>SignIn: submit credentials / click Google
  SignIn->>Auth: signInWithEmailAndPassword / signInWithPopup
  alt success
    Auth-->>SignIn: userCredential
    SignIn->>Toast: toast.success(...)
    SignIn->>Router: navigate(...)
  else error
    Auth-->>SignIn: error(code)
    SignIn->>Toast: toast.error(getAuthErrorMessage(code))
  end

  User->>SignUp: submit signup form
  SignUp->>Auth: createUserWithEmailAndPassword(email, values.password)
  alt success
    Auth-->>SignUp: userCredential
    SignUp->>Toast: toast.success(...)
    SignUp->>Router: navigate(/signin) after toast onClose
  else error
    Auth-->>SignUp: error(code)
    SignUp->>Toast: toast.error(getSignUpErrorMessage(code))
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

I nibble code and polish logs,
Toasts pop bright like crunchy clogs.
Success hops in, errors get a seat,
My whiskers twitch — auth's complete.
A tiny rabbit cheers, so neat 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately and concisely describes the primary change by stating that toast notifications were added for login and signup and directly reflects the modifications in the PR. It is clear and specific enough for a teammate scanning history to understand the focus of the changeset. The phrasing aligns with the main functionality introduced without extraneous details.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/pages/SignIn.js (1)

71-72: Duplicate ToastContainer: use single instance at app root.

This is the same issue as in SignUp.js (line 60). You have multiple ToastContainer instances across different page components. As mentioned in the SignUp.js review, best practice is to render ToastContainer once at the application root.

See the detailed recommendation in the SignUp.js review (lines 59-60) for how to refactor this.

Based on learnings.

🧹 Nitpick comments (5)
src/pages/SignUp.js (3)

4-6: Optional: CSS import is redundant in react-toastify v11.

The library auto-injects its stylesheet in v11.x, so the explicit CSS import on line 6 is optional. You can remove it unless you need explicit control over CSS injection timing.

Apply this diff if you want to remove the redundant import:

-import 'react-toastify/dist/ReactToastify.css'; // Important: Import the CSS

Based on learnings.


23-31: Simplify toast configuration using defaults.

The toast options are verbose and duplicated. Since you're already using <ToastContainer /> (line 60), you can configure defaults there and simplify individual toast calls.

Apply this diff to simplify:

         // 3. Call the success toast
-        toast.success("Account created successfully!", {
-          position: "top-right",
-          autoClose: 5000,
-          hideProgressBar: false,
-          closeOnClick: true,
-          pauseOnHover: true,
-          draggable: true,
-          progress: undefined,
-        });
+        toast.success("Account created successfully!");
         // 3. Call the error toast
-        toast.error(error.message, {
-          position: "top-right",
-          autoClose: 5000,
-          hideProgressBar: false,
-          closeOnClick: true,
-          pauseOnHover: true,
-          draggable: true,
-          progress: undefined,
-        });
+        toast.error(error.message);

Then configure defaults on the ToastContainer at line 60:

-      <ToastContainer />
+      <ToastContainer 
+        position="top-right"
+        autoClose={5000}
+        hideProgressBar={false}
+        closeOnClick
+        pauseOnHover
+        draggable
+      />

This matches the simpler approach used in SignIn.js and reduces code duplication.

Also applies to: 40-47


59-60: Consider using a single ToastContainer at app root.

You're adding ToastContainer in both SignUp.js and SignIn.js (line 72). Best practice is to render ToastContainer once at the application root (e.g., in App.js) rather than in individual page components. This ensures consistent configuration and avoids potential conflicts.

Move the ToastContainer to your app's root component:

In App.js (or your root component):

import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

function App() {
  return (
    <>
      <ToastContainer 
        position="top-right"
        autoClose={5000}
        hideProgressBar={false}
        closeOnClick
        pauseOnHover
        draggable
      />
      {/* Your routes and other components */}
    </>
  );
}

Then remove the ToastContainer from both SignUp.js and SignIn.js. The toast calls (toast.success(), toast.error()) will still work because the container is rendered globally.

Based on learnings.

src/pages/SignIn.js (2)

12-14: Optional: CSS import is redundant in react-toastify v11.

The library auto-injects its stylesheet in v11.x, so the explicit CSS import on line 14 is optional. You can remove it unless you need explicit control over CSS injection timing.

Apply this diff if you want to remove the redundant import:

-import 'react-toastify/dist/ReactToastify.css'; // Import the CSS

Based on learnings.


28-36: LGTM with minor note on comment clarity.

The empty dependency array is correct here—you want the auth state listener to be set up once on mount. The Navigate function from useNavigate is stable across renders, so omitting it is safe. The comment on line 36 could be more confident: "should likely" → "should" or "is correct".

Optional: Update the comment for clarity:

-  }, []); // Note: The dependency array should likely be empty here
+  }, []); // Empty dependency array: set up auth listener once on mount
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca140b5 and 251725a.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json and included by none
  • package.json is excluded by none and included by none
📒 Files selected for processing (2)
  • src/pages/SignIn.js (3 hunks)
  • src/pages/SignUp.js (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/pages/SignIn.js (3)
src/pages/SignUp.js (2)
  • Navigate (17-17)
  • auth (16-16)
src/firebase.js (2)
  • auth (33-33)
  • auth (33-33)
src/components/Form/FormContainer.js (1)
  • FormContainer (4-40)
src/pages/SignUp.js (1)
src/firebase.js (2)
  • auth (33-33)
  • auth (33-33)
🔇 Additional comments (4)
src/pages/SignUp.js (1)

20-20: Correct fix: using the right password field.

Good catch! Using values.password instead of values.confirmPassword for account creation is the correct implementation.

src/pages/SignIn.js (3)

45-52: Clean toast implementation.

The simplified toast calls (without verbose configuration objects) are much cleaner than the approach in SignUp.js. This is a good pattern.


57-66: LGTM!

Consistent toast implementation for email/password sign-in. The user feedback flow is clear and the code is maintainable.


70-70: Nice text improvement.

The title change from "Sign in for an account!" to "Sign in to your account!" is more natural and grammatically correct.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
src/pages/SignIn.js (1)

53-63: Same consideration for user-friendly error messages applies here.

Similar to the Google sign-in handler, consider mapping Firebase error codes to user-friendly messages for better UX in the email/password sign-in flow.

🧹 Nitpick comments (5)
src/pages/SignUp.js (3)

19-35: Good fix: onClose callback prevents memory leak.

The use of onClose: () => Navigate("/signin") on line 25 properly addresses the previous concern about potential memory leaks from setTimeout. The navigation now occurs only after the toast completes, and no cleanup is needed if the component unmounts.

Minor: Consider removing the empty lines at 22, 24, 26, and 34 for cleaner formatting.


56-56: Consider centralizing ToastContainer at the app level.

Since the SignIn page (per the AI summary) also renders its own ToastContainer, you may have multiple instances. Best practice is to render ToastContainer once at the application root (e.g., in App.js or a layout component) rather than in individual pages. This prevents potential conflicts and ensures consistent toast behavior across the app.

If you move the ToastContainer to your app root, remove it from this component:

-      <ToastContainer />

Then add it once in your main App component:

// In App.js or root component
import { ToastContainer } from 'react-toastify';

function App() {
  return (
    <>
      <ToastContainer />
      {/* Your routes and other components */}
    </>
  );
}

4-5: Remove CSS import and centralize ToastContainer

  • Delete import 'react-toastify/dist/ReactToastify.css'; (v11+ auto-injects styles).
  • Move <ToastContainer> from SignUp.js into your root App component so notifications render globally.
src/pages/SignIn.js (2)

13-13: Remove CSS import for react-toastify v11.x.

React-toastify v11.x automatically injects styles when ToastContainer is rendered, so the CSS import is no longer required.

Based on learnings

Apply this diff:

-import 'react-toastify/dist/ReactToastify.css';

42-51: Consider user-friendly error messages.

Firebase error messages (e.g., auth/popup-closed-by-user, auth/invalid-email) may be too technical for end users. Consider mapping common Firebase errors to user-friendly messages for better UX.

Example:

const SignInWithGoogle = () => {
  const provider = new GoogleAuthProvider();
  signInWithPopup(auth, provider)
    .then(() => {
      toast.success("Successfully logged in!");
    })
    .catch((err) => {
      const friendlyMessage = getFriendlyErrorMessage(err.code) || err.message;
      toast.error(friendlyMessage);
    });
};

// Helper function
const getFriendlyErrorMessage = (errorCode) => {
  const errorMessages = {
    'auth/popup-closed-by-user': 'Sign-in cancelled. Please try again.',
    'auth/network-request-failed': 'Network error. Please check your connection.',
    'auth/too-many-requests': 'Too many attempts. Please try again later.',
  };
  return errorMessages[errorCode];
};
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 251725a and 7cfd8eb.

📒 Files selected for processing (2)
  • src/pages/SignIn.js (2 hunks)
  • src/pages/SignUp.js (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/pages/SignIn.js (2)
src/firebase.js (2)
  • auth (33-33)
  • auth (33-33)
src/components/Form/FormContainer.js (1)
  • FormContainer (4-40)
src/pages/SignUp.js (1)
src/firebase.js (2)
  • auth (33-33)
  • auth (33-33)
🔇 Additional comments (2)
src/pages/SignUp.js (1)

36-47: LGTM: Error handling is appropriate.

The error toast configuration is well-structured, and the 5-second autoClose duration is appropriate for error messages (giving users more time to read than the 2-second success message).

src/pages/SignIn.js (1)

66-66: LGTM! Improved title text.

The title change from "Sign in for an account!" to "Sign in to your account!" is grammatically correct and more natural.

Comment on lines 27 to 36
useEffect(() => {
onAuthStateChanged(auth, (user) => {
const unsubscribe = onAuthStateChanged(auth, (user) => {
if (user) {
Navigate("/main");
}
});
// eslint-disable-next-line
}, [auth]);

return () => unsubscribe();
}, [Navigate]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Use empty dependency array for mount-only effect.

The Navigate function from useNavigate() is stable and doesn't require inclusion in the dependency array. This effect should run once on mount to set up the auth state listener.

Apply this diff:

   useEffect(() => {
     const unsubscribe = onAuthStateChanged(auth, (user) => {
       if (user) {
         Navigate("/main");
       }
     });

     return () => unsubscribe();
-  }, [Navigate]); 
+  }, []); 
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
onAuthStateChanged(auth, (user) => {
const unsubscribe = onAuthStateChanged(auth, (user) => {
if (user) {
Navigate("/main");
}
});
// eslint-disable-next-line
}, [auth]);
return () => unsubscribe();
}, [Navigate]);
useEffect(() => {
const unsubscribe = onAuthStateChanged(auth, (user) => {
if (user) {
Navigate("/main");
}
});
return () => unsubscribe();
}, []);
🤖 Prompt for AI Agents
In src/pages/SignIn.js around lines 28 to 36, the useEffect currently lists
[Navigate] as a dependency causing unnecessary re-runs; change the dependency
array to an empty array ([]) so the auth state listener is registered only once
on mount. Keep the onAuthStateChanged unsubscribe return as-is and do not
include Navigate in the dependency list since useNavigate() returns a stable
function.

return (
<FormContainer Icon={LoginIcon} title="Sign in for an account!">
<FormContainer Icon={LoginIcon} title="Sign in to your account!">
<ToastContainer position="top-right" autoClose={5000} hideProgressBar={false} />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Move ToastContainer to app root level.

Rendering ToastContainer inside individual page components can lead to multiple container instances when navigating between pages (e.g., SignIn ↔ SignUp), potentially causing duplicate toasts or inconsistent behavior.

Recommended approach:

  1. Remove ToastContainer from this component (and from SignUp.js)
  2. Add a single ToastContainer at the app root level (typically in App.js or index.js)

Example in App.js:

import { ToastContainer } from 'react-toastify';

function App() {
  return (
    <>
      <ToastContainer 
        position="top-right" 
        autoClose={5000} 
        hideProgressBar={false} 
      />
      {/* Your routes and components */}
    </>
  );
}

Then you can call toast.success() or toast.error() from any component without needing to render ToastContainer in each one.

🤖 Prompt for AI Agents
In src/pages/SignIn.js around line 67, the ToastContainer is rendered inside the
SignIn page which can produce multiple instances and duplicate toasts when
navigating; remove the ToastContainer from this file (and similarly from
SignUp.js) and add a single ToastContainer at the app root (e.g., App.js or
index.js) with the same props (position="top-right", autoClose={5000},
hideProgressBar={false}) so all components can call toast.* without rendering
their own container.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
src/pages/SignIn.js (1)

28-36: Use empty dependency array for mount-only effect.

The Navigate function from useNavigate() is stable and doesn't require inclusion in the dependency array. This effect should run once on mount to set up the auth state listener.

Apply this diff:

   useEffect(() => {
     const unsubscribe = onAuthStateChanged(auth, (user) => {
       if (user) {
         Navigate("/main");
       }
     });

     return () => unsubscribe();
-  }, [Navigate]); 
+  }, []); 
🧹 Nitpick comments (1)
src/pages/SignIn.js (1)

12-13: Remove ToastContainer import and consider removing CSS import.

Since ToastContainer is now rendered at the app root level (in App.js), you only need the toast import here. Additionally, react-toastify v11 auto-injects CSS, making the manual CSS import optional.

Based on learnings

Apply this diff:

-import { ToastContainer, toast } from 'react-toastify';
-import 'react-toastify/dist/ReactToastify.css';
+import { toast } from 'react-toastify';
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7cfd8eb and d70263c.

📒 Files selected for processing (2)
  • src/App.js (2 hunks)
  • src/pages/SignIn.js (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/pages/SignIn.js (2)
src/firebase.js (2)
  • auth (33-33)
  • auth (33-33)
src/components/Form/FormContainer.js (1)
  • FormContainer (4-40)
🔇 Additional comments (2)
src/App.js (1)

13-19: LGTM: Global ToastContainer placement is correct.

Once the import is added, this global ToastContainer placement follows best practices and aligns with the recommended approach from previous reviews. The configuration props are appropriate for typical toast notifications.

src/pages/SignIn.js (1)

66-66: LGTM: Title text improved.

The updated title "Sign in to your account!" is grammatically correct and clearer than the previous version.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/pages/SignUp.js (1)

13-24: Consider consolidating error message helpers.

The getSignUpErrorMessage helper provides good UX by mapping Firebase error codes to user-friendly messages. However, SignIn.js likely has a similar getAuthErrorMessage helper. Consider extracting these into a shared utility file (e.g., utils/firebaseErrors.js) to reduce duplication and maintain consistency across authentication flows.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce18863 and 32b6ce5.

📒 Files selected for processing (2)
  • src/pages/SignIn.js (2 hunks)
  • src/pages/SignUp.js (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/SignIn.js
🧰 Additional context used
🧬 Code graph analysis (1)
src/pages/SignUp.js (1)
src/firebase.js (2)
  • auth (33-33)
  • auth (33-33)
🔇 Additional comments (4)
src/pages/SignUp.js (4)

4-5: LGTM!

The react-toastify imports are correct and follow the library's standard usage pattern.


32-32: LGTM!

Using values.password (rather than confirmPassword) is correct. The confirmPassword field is solely for validation purposes, while password is the actual credential for account creation.


34-37: LGTM!

The navigation pattern using onClose avoids the previous memory leak concern with setTimeout. The toast will complete its autoClose cycle before navigation, providing a smooth UX.


40-46: LGTM!

The error handling correctly maps Firebase errors to user-friendly messages and displays them via toast, while still logging the original error for debugging purposes.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/pages/SignUp.js (3)

4-4: Remove unused ToastContainer import.

The ToastContainer component is no longer rendered in this file (correctly removed as per previous review feedback, since App.js provides the global container). The import should be cleaned up.

Apply this diff:

-import { ToastContainer, toast } from 'react-toastify';
+import { toast } from 'react-toastify';

5-5: Optional: CSS import is redundant in react-toastify v11.

In react-toastify v11, the CSS is automatically injected by default, so this manual import is technically redundant. However, it's harmless and some teams prefer explicit imports for clarity.

Based on learnings.

If you prefer to rely on the auto-injection, you can remove this line:

-import 'react-toastify/dist/ReactToastify.css';

13-24: Well-structured error message mapping.

The getSignUpErrorMessage helper provides clear, user-friendly error messages for common Firebase auth errors. This is good UX and follows best practices for error handling.

If this pattern is used in other authentication flows (e.g., SignIn), consider extracting this to a shared utility file like utils/authErrors.js to avoid duplication.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 32b6ce5 and 82e0f94.

📒 Files selected for processing (1)
  • src/pages/SignUp.js (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/pages/SignUp.js (1)
src/firebase.js (2)
  • auth (33-33)
  • auth (33-33)
🔇 Additional comments (3)
src/pages/SignUp.js (3)

32-32: Correct use of password field.

Good fix! Now correctly uses values.password instead of values.confirmPassword for account creation, which aligns with Firebase's createUserWithEmailAndPassword API expectations.


34-37: Excellent navigation pattern with toast.

The implementation correctly uses autoClose: 2000 with an onClose callback to navigate after the toast is dismissed. This addresses the previous memory leak concern from the setTimeout pattern and ensures the user sees the success message before navigation.


40-46: Proper error handling with user-friendly messages.

The error flow correctly maps Firebase errors to user-friendly messages via the helper function and displays them in a toast. Logging the full error to console is also helpful for debugging.

@Saikiran-Sugurthi
Copy link
Author

@ctrixcode can u merge now...i resolved all conflicts

@ctrixcode
Copy link
Owner

@coderabbitai review PR now

@coderabbitai
Copy link

coderabbitai bot commented Oct 10, 2025

@ctrixcode: I'll review the PR now and provide feedback on the toast notification implementation for login and signup functionality.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Saikiran-Sugurthi
Copy link
Author

@ctrixcode i think no more imprvments sugggestd by Coderabbit

@ctrixcode
Copy link
Owner

Why removed auth from deps? @Saikiran-Sugurthi
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants