Skip to content

feat: implement multi-step community signup flow with validation and API integration#21

Open
Pranavkale11 wants to merge 1 commit intoNexGenStudioDev:masterfrom
Pranavkale11:feat/community-signup
Open

feat: implement multi-step community signup flow with validation and API integration#21
Pranavkale11 wants to merge 1 commit intoNexGenStudioDev:masterfrom
Pranavkale11:feat/community-signup

Conversation

@Pranavkale11
Copy link
Copy Markdown

@Pranavkale11 Pranavkale11 commented Apr 15, 2026

#2
Overview
This PR implements a multi-step community signup flow aligned with the backend schema.
The goal was to create a smooth, user-friendly onboarding experience while keeping the implementation scalable and production-ready.

Features

  1. 5-step signup flow with step-wise validation using React Hook Form and Zod
  2. Centralized form state using FormProvider (no prop drilling)
  3. File upload with validation, preview, and proper reset handling
  4. Controlled step navigation with validation-based progression
  5. API integration with structured error handling (including snake_case mapping support)
  6. Post-signup flow: Email verification → Pending approval screen
  7. Improved accessibility with proper label-input associations

Fixes & Improvements

  1. Fixed step component rendering issue (avoiding stale component instances)
  2. Added clear error feedback for invalid file uploads
  3. Refactored upload logic to allow easy replacement with S3/Cloudinary in future
  4. Resolved potential memory leak using useEffect cleanup
  5. Improved URL handling by normalizing inputs (e.g., adding https:// when missing)
  6. Strengthened API error mapping to ensure consistent field-level errors
  7. Cleaned up TypeScript issues (no remaining type errors)

Testing

  1. Verified step navigation and validation behavior
  2. Tested edge cases like invalid file uploads and incomplete inputs
  3. Confirmed state persistence across all steps
  4. Checked API error handling and fallback scenarios

Notes

  1. File upload is currently simulated and can be replaced with a real storage service
  2. Backend integration assumes the existing schema contract

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the SignUpPage into a comprehensive multi-step form utilizing react-hook-form and zod for validation. It introduces a modular architecture with dedicated components for each step, a custom hook for form logic, and an API utility for handling submissions and logo uploads. Review feedback suggests improving code maintainability by replacing hardcoded magic numbers—specifically the post-state transition timeout and the file size limit—with constants, and adopting the best practice of throwing Error instances instead of plain objects in the API layer.

Comment on lines +67 to +71
useEffect(() => {
if (post !== "email") return;
const id = setTimeout(() => setPost("pending"), 3500);
return () => clearTimeout(id);
}, [post]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The useEffect hook for transitioning the post state relies on a hardcoded timeout of 3500ms. This magic number should be defined as a constant to improve maintainability and clarity.

Comment on lines +20 to +22
if (!res.ok) {
throw { status: res.status, data: json };
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The error handling logic throws a plain object. It is better practice to throw an Error instance or a custom error class to maintain a consistent error stack trace.

Suggested change
if (!res.ok) {
throw { status: res.status, data: json };
}
if (!res.ok) {
throw new Error(json.message || "Signup failed");
}

Comment on lines +31 to +35
if (file.size > 2 * 1024 * 1024) {
setUploadError("File must be under 2MB.");
if (fileRef.current) fileRef.current.value = "";
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The file size validation uses a hardcoded limit of 2MB. This should be defined as a constant to ensure consistency if the limit needs to be updated in the future.

@abhishek-nexgen-dev
Copy link
Copy Markdown
Member

@Pranavkale11 fix these issue that Gemini suggest you

@abhishek-nexgen-dev
Copy link
Copy Markdown
Member

abhishek-nexgen-dev commented Apr 16, 2026

🚀 UI & Form Improvements (Production-Ready Guidelines)

1. 🎨 Improve Left Section (Signup Page)

Screenshot at 2026-04-16 07-40-17

Issues

  • UI is not visually appealing
  • Does not match the overall theme
  • Lacks hierarchy and engagement

Requirements

  • Redesign the left section to align with the application theme

  • Add:

    • Gradient or branded background
    • Illustration or abstract visuals
    • Clear heading + subheading
    • Proper spacing and typography
  • Ensure responsiveness across screen sizes

Expected Outcome

A visually attractive, modern, and theme-consistent left section that enhances user engagement.


2. 🔗 URL Input Component

Screenshot at 2026-04-16 07-49-26

Requirements

Screenshot at 2026-04-16 07-50-00
  • Users should NOT include protocol (http://, https://)

  • System should:

    • Automatically prepend protocol internally if needed
    • Validate domain format strictly

Validation Rules

  • Accept:

    example.com
    x.com/username
    
  • Reject:

    https://example.com ❌ (user input should not include protocol)
    abhishek_nexgen ❌ (invalid domain)
    

Suggested Validation Logic

  • Must contain a valid domain
  • Must not include protocol
  • Should support subpaths

3. 🌍 Country Dropdown

Requirements

  • ❌ Do NOT use default HTML <select>
  • ✅ Use global reusable dropdown component

Why

  • Consistency across app
  • Better UX (search, keyboard nav, styling)

Action

  • Replace existing dropdown with global dropdown component

  • Ensure:

    • Searchable
    • Accessible
    • Styled consistently

4. 📱 Contact Phone Input

Requirements

  • Split into two parts:

    1. Country code (dropdown)
    2. Phone number (input)

Behavior

  • User selects country code from dropdown
  • User enters number manually

Example

[ +91 ▼ ] [ 9876543210 ]

Validation

  • Country code required
  • Phone number numeric only
  • Length validation based on country (optional advanced)

5. 🌐 Social Component

UI Improvements

  • Add proper:

    • Padding
    • Margin
    • Input spacing
  • Improve visual grouping


Screenshot at 2026-04-16 08-01-07

Validation Requirements (IMPORTANT)

Current issue:

https://abhishek_nexgen ❌ accepted (WRONG)

Correct Validation Rules

  • Must be a valid URL

  • Must include:

    • Protocol (https://)
    • Valid domain

Accept:

https://x.com/abhishek_nexgen ✅
https://linkedin.com/in/username ✅

Reject:

https://abhishek_nexgen ❌
x.com/username ❌ (missing protocol)

Recommendation

Use robust validation:

  • Regex OR
  • URL constructor:
new URL(value)

6. ⭐ Review Component Fix

Issue

Something went wrong. Please try again.

Requirements

  • Fix underlying error

  • Ensure:

    • Proper error handling
    • Clear API response handling
    • No silent failures

Production Guidelines

✔ Error Handling

try {
  // API call
} catch (error) {
  console.error(error);
  showToast("Failed to load reviews");
}

✔ Use Existing Components

  • Reuse:

    • Input components
    • Dropdown components
    • Button components

✔ If Not Available

Create reusable components:

Example: Custom Dropdown

  • Search support
  • Keyboard navigation
  • Reusable props

🧠 Engineering Principles (IMPORTANT)

✔ Consistency

  • Use global components everywhere

✔ Validation-first approach

  • Never trust user input

✔ Reusability

  • Build once → use everywhere

✔ Clean Code

  • Proper naming
  • Modular structure
  • Easy to understand

🏁 Final Summary

You need to:

  • 🎨 Improve UI (left section, spacing, layout)
  • 🔗 Fix URL handling (protocol rules)
  • 🌍 Use global dropdown (no default select)
  • 📱 Improve phone input UX
  • 🌐 Fix social URL validation
  • ⭐ Make review component stable & production-ready

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants