Bring SignUp page up to par with Login dark mode, loading state, password toggle#269
Conversation
…ord toggle, and animations
✅ Deploy Preview for github-spy ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Signup page was refactored to be theme-aware, animated, and to add password visibility and loading-aware async submit handling; App now hides chrome (navbar/footer) on fullscreen routes like /signup and /login. ChangesSign-up Page Theme and Form Behavior
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🎉 Thank you @zen-ash-dev for your contribution. Please make sure your PR follows https://github.com/GitMetricsLab/github_tracker/blob/main/CONTRIBUTING.md#-pull-request-guidelines
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/pages/Signup/Signup.tsx (1)
194-202: ⚡ Quick winAdd accessible name/state to the password visibility toggle.
The icon-only button needs an
aria-label(and preferablyaria-pressed) so screen-reader users can understand and operate it reliably.Suggested fix
<button type="button" onClick={() => setShowPassword(!showPassword)} + aria-label={showPassword ? "Hide password" : "Show password"} + aria-pressed={showPassword} className={`absolute inset-y-0 right-0 pr-4 flex items-center ${ mode === "dark" ? "text-slate-400 hover:text-white" : "text-gray-500 hover:text-gray-800" } transition-colors duration-200`} >🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/pages/Signup/Signup.tsx` around lines 194 - 202, The password visibility toggle button lacks accessible name/state; update the button rendered near showPassword and setShowPassword to include an aria-label that changes with state (e.g., "Show password" when showPassword is false and "Hide password" when true) and add aria-pressed={showPassword} so screen readers know its toggle state; keep the existing onClick and type="button" behavior and ensure the accessible text is tied to the showPassword boolean used by the Eye/EyeOff icons.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/pages/Signup/Signup.tsx`:
- Around line 44-46: The redirect is currently gated on an exact
response.data.message string ("User created successfully"), which is fragile;
update the success check in the signup handler (the code that calls
navigate("/login") using the response variable) to rely on a stable indicator
such as HTTP status (e.g., response.status in the 2xx range), a boolean success
flag (response.data.success === true), or presence of a created user id
(response.data.user?.id) instead of the verbose message, and then call
navigate("/login") when that stable condition is met; also keep existing error
handling paths intact so failures still surface to the user.
- Around line 36-42: handleSubmit can be invoked multiple times before React
updates state, so add an early guard using a mutable ref (e.g., isSubmittingRef)
to block duplicate POSTs: at the top of handleSubmit return immediately if
isSubmittingRef.current is true, then set isSubmittingRef.current = true and
setIsLoading(true) before the try, and reset isSubmittingRef.current = false
(and setIsLoading(false)) in the finally block; reference handleSubmit,
isSubmittingRef, setIsLoading to locate where to implement this.
---
Nitpick comments:
In `@src/pages/Signup/Signup.tsx`:
- Around line 194-202: The password visibility toggle button lacks accessible
name/state; update the button rendered near showPassword and setShowPassword to
include an aria-label that changes with state (e.g., "Show password" when
showPassword is false and "Hide password" when true) and add
aria-pressed={showPassword} so screen readers know its toggle state; keep the
existing onClick and type="button" behavior and ensure the accessible text is
tied to the showPassword boolean used by the Eye/EyeOff icons.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b212a702-cf07-4dff-a126-914ca840cb98
📒 Files selected for processing (1)
src/pages/Signup/Signup.tsx
| const handleSubmit = async (e: React.FormEvent) => { | ||
| e.preventDefault(); | ||
| setIsLoading(true); | ||
|
|
||
| try { | ||
| const response = await axios.post(`${backendUrl}/api/auth/signup`, | ||
| formData // Include cookies for session | ||
| ); | ||
| setMessage(response.data.message); // Show success message from backend | ||
|
|
||
| // Navigate to login page after successful signup | ||
| if (response.data.message === 'User created successfully') { | ||
| navigate("/login");} | ||
|
|
||
|
|
||
| // // Simulate API call (replace with your actual backend integration) | ||
| // try { | ||
| // // Mock successful signup | ||
| // setMessage("Account created successfully! Redirecting to login..."); | ||
|
|
||
| // // In your actual implementation, integrate with your backend here: | ||
| // // const response = await fetch(`${backendUrl}/api/auth/signup`, { | ||
| // // method: 'POST', | ||
| // // headers: { 'Content-Type': 'application/json' }, | ||
| // // body: JSON.stringify(formData) | ||
| // // }); | ||
|
|
||
| // setTimeout(() => { | ||
| // // Navigate to login page in your actual implementation | ||
| // console.log("Redirecting to login page..."); | ||
| // }, 2000); | ||
|
|
||
| } catch (error) { | ||
| setMessage("Something went wrong. Please try again."); | ||
| const response = await axios.post(`${backendUrl}/api/auth/signup`, formData); | ||
| setMessage(response.data.message); |
There was a problem hiding this comment.
Prevent duplicate submit requests in handleSubmit.
Line 38 sets loading, but there’s no early guard; fast repeated Enter/click can still trigger multiple POSTs before re-render.
Suggested fix
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
+ if (isLoading) return;
setIsLoading(true);📝 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.
| const handleSubmit = async (e: React.FormEvent) => { | |
| e.preventDefault(); | |
| setIsLoading(true); | |
| try { | |
| const response = await axios.post(`${backendUrl}/api/auth/signup`, | |
| formData // Include cookies for session | |
| ); | |
| setMessage(response.data.message); // Show success message from backend | |
| // Navigate to login page after successful signup | |
| if (response.data.message === 'User created successfully') { | |
| navigate("/login");} | |
| // // Simulate API call (replace with your actual backend integration) | |
| // try { | |
| // // Mock successful signup | |
| // setMessage("Account created successfully! Redirecting to login..."); | |
| // // In your actual implementation, integrate with your backend here: | |
| // // const response = await fetch(`${backendUrl}/api/auth/signup`, { | |
| // // method: 'POST', | |
| // // headers: { 'Content-Type': 'application/json' }, | |
| // // body: JSON.stringify(formData) | |
| // // }); | |
| // setTimeout(() => { | |
| // // Navigate to login page in your actual implementation | |
| // console.log("Redirecting to login page..."); | |
| // }, 2000); | |
| } catch (error) { | |
| setMessage("Something went wrong. Please try again."); | |
| const response = await axios.post(`${backendUrl}/api/auth/signup`, formData); | |
| setMessage(response.data.message); | |
| const handleSubmit = async (e: React.FormEvent) => { | |
| e.preventDefault(); | |
| if (isLoading) return; | |
| setIsLoading(true); | |
| try { | |
| const response = await axios.post(`${backendUrl}/api/auth/signup`, formData); | |
| setMessage(response.data.message); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/pages/Signup/Signup.tsx` around lines 36 - 42, handleSubmit can be
invoked multiple times before React updates state, so add an early guard using a
mutable ref (e.g., isSubmittingRef) to block duplicate POSTs: at the top of
handleSubmit return immediately if isSubmittingRef.current is true, then set
isSubmittingRef.current = true and setIsLoading(true) before the try, and reset
isSubmittingRef.current = false (and setIsLoading(false)) in the finally block;
reference handleSubmit, isSubmittingRef, setIsLoading to locate where to
implement this.
| if (response.data.message === "User created successfully") { | ||
| navigate("/login"); | ||
| } |
There was a problem hiding this comment.
Don’t gate redirect on an exact response message string.
Line 44 couples success flow to "User created successfully". Any backend wording change can leave users stuck on signup even after successful creation.
Suggested fix
- if (response.data.message === "User created successfully") {
+ if (response.status >= 200 && response.status < 300) {
navigate("/login");
}📝 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.
| if (response.data.message === "User created successfully") { | |
| navigate("/login"); | |
| } | |
| if (response.status >= 200 && response.status < 300) { | |
| navigate("/login"); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/pages/Signup/Signup.tsx` around lines 44 - 46, The redirect is currently
gated on an exact response.data.message string ("User created successfully"),
which is fragile; update the success check in the signup handler (the code that
calls navigate("/login") using the response variable) to rely on a stable
indicator such as HTTP status (e.g., response.status in the 2xx range), a
boolean success flag (response.data.success === true), or presence of a created
user id (response.data.user?.id) instead of the verbose message, and then call
navigate("/login") when that stable condition is met; also keep existing error
handling paths intact so failures still surface to the user.
|
Hi @mehul-m-prajapati , |
…Bar, auto-label workflow; keep enhanced Signup page with dark/light mode, animations, password toggle
|
Hi @mehul-m-prajapati , review asap All merge conflicts have been successfully resolved. Please review and merge at your earliest convenience to avoid any future conflicts. Additionally, could you please add gssoc:approved label to this PR and issue? Looking forward to your approval. Thank you! |
|
🎉🎉 Thank you for your contribution! Your PR #269 has been merged! 🎉🎉 |
Related Issue
Description
The SignUp page was missing a bunch of stuff Login already had. No dark/light mode support, no loading state on submit, no way to see your password while typing, no animations. The button used
onClickinstead of a proper<form onSubmit>, and error messages were generic regardless of what the backend returned. There was also a dead block of commented-out mock code inhandleSubmit.Changes made:
ThemeContextso the page follows the app-wide dark/light toggle instead of being locked into one gradientisLoadingstate — the button disables itself and shows "Creating account..." while the request is in flightEye/EyeOfficons from lucide-reactonClickto proper<form onSubmit>— pressing Enter now workserror.response?.data?.messagefrom the backend instead of hiding behind "Something went wrong"framer-motionfade-in animations on the branding section and the form cardautoCompleteattributes on all three inputsHow Has This Been Tested?
npm run dev, navigated to/signupnpm run build— no type errors, no lint warningsScreenshots (if applicable)
Type of Change
Summary by CodeRabbit
New Features
Improvements