Skip to content

Fix: Add logout and navigation improvements to onboarding flow #94

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Aditya30ag
Copy link
Contributor

@Aditya30ag Aditya30ag commented Jul 9, 2025

Fix: Add logout and navigation improvements to onboarding flow

Closes #93

📝 Description

This PR fixes the critical UX issue where users were trapped in the onboarding flow without any way to logout or navigate back to previous steps. The changes implement comprehensive navigation improvements to provide users with proper control during the onboarding process.

Problem Solved:

  • Users had no way to logout during onboarding
  • No option to skip onboarding and complete later
  • No back navigation to review/edit previous steps
  • Poor user experience with no escape routes

Solution Implemented:

  • Added persistent logout button with confirmation dialog
  • Implemented "Skip for now" functionality with progress saving
  • Enhanced step navigation with clickable progress indicators
  • Added auto-save functionality for session restoration
  • Improved error handling and loading states

🔧 Changes Made

  • Add logout button with confirmation dialog in onboarding header

    • Persistent logout option available throughout onboarding
    • Confirmation dialog with progress saving notification
    • Proper error handling and loading states
  • Implement 'Skip for now' option to allow completing onboarding later

    • Save current progress to localStorage with 24-hour expiration
    • Navigate to appropriate dashboard based on user role
    • Auto-restore progress when user returns
  • Add clickable step navigation to go back to previous steps

    • Enhanced progress stepper with numbered circles
    • Click functionality for completed steps
    • Visual indicators (active, completed, pending states)
  • Implement auto-save functionality for onboarding progress

    • Automatic progress persistence to localStorage
    • Session restoration on component mount
    • 24-hour expiration for saved progress
  • Add error handling and loading states for logout process

    • Comprehensive try-catch blocks with user feedback
    • Loading spinners and disabled states during operations
    • Error messages with retry capabilities
  • Enhance UI with better progress indicators and navigation

    • Improved button styling with hover states
    • Better visual hierarchy and spacing
    • Consistent color scheme and transitions
    • Step counter display (e.g., "Step 2 of 7")
  • Fix missing exit options during onboarding flow

    • Header with branding and action buttons
    • Confirmation dialogs for destructive actions
    • Clear visual feedback for all user interactions

📷 Screenshots or Visual Changes

image

Before:

  • No logout option visible
  • Simple text-based stepper
  • No way to go back or skip

After:

  • ✅ Prominent logout button in header
  • ✅ "Skip for now" option when role is selected
  • ✅ Enhanced stepper with clickable navigation
  • ✅ Loading states and error handling
  • ✅ Confirmation dialogs for user actions

Key UI Improvements:

  • Added header with "InPact Onboarding" branding
  • Red logout button with LogOut icon
  • Gray "Skip for now" button (contextual visibility)
  • Circular progress indicators with checkmarks
  • Loading spinners and error messages in dialogs
  • Enhanced button styling with hover effects

🧪 Testing

Manual Testing Performed:

  • ✅ Logout functionality from all onboarding steps
  • ✅ Skip functionality saves progress correctly
  • ✅ Clickable step navigation works as expected
  • ✅ Progress restoration after page refresh
  • ✅ Error handling for network failures
  • ✅ Loading states display properly
  • ✅ Responsive design on different screen sizes

Test Scenarios:

  1. Start onboarding → Click logout → Confirm → Redirects to homepage
  2. Complete 3 steps → Click skip → Returns to dashboard → Resume later
  3. Complete 5 steps → Click step 2 → Navigate back successfully
  4. Browser refresh → Progress restored correctly
  5. Network error during logout → Error message displayed

✅ Checklist

  • I have read the contributing guidelines.
  • I have tested the fix thoroughly across different scenarios.
  • I have ensured TypeScript compilation passes without errors.
  • The UI improvements follow the existing design system.
  • Error handling provides meaningful user feedback.
  • The solution addresses all aspects of issue BUG:Missing Logout and Back Navigation During Onboarding Flow #93.
  • Code is clean, well-commented, and follows project conventions.
  • No breaking changes introduced to existing functionality.

Summary by CodeRabbit

  • New Features

    • Added an exit confirmation dialog when choosing to skip onboarding or log out.
    • Enabled saving and resuming onboarding progress within 24 hours.
    • Allowed users to navigate back to completed onboarding steps by clicking step indicators.
  • Improvements

    • Enhanced stepper UI with clearer indicators for active, completed, and essential steps.
    • Updated navigation buttons and header with new icons and improved styling.
    • Improved error handling and loading indicators during exit actions.

- Add logout button with confirmation dialog in onboarding header
- Implement 'Skip for now' option to allow completing onboarding later
- Add clickable step navigation to go back to previous steps
- Implement auto-save functionality for onboarding progress
- Add error handling and loading states for logout process
- Enhance UI with better progress indicators and navigation
- Fix missing exit options during onboarding flow

Fixes AOSSIE-Org#93
Copy link
Contributor

coderabbitai bot commented Jul 9, 2025

"""

Walkthrough

The Onboarding component was updated to introduce an exit confirmation dialog, logout and skip options, clickable progress indicators for back navigation, and auto-saving of onboarding progress. Additional UI enhancements and error handling were added to improve navigation and user control during the onboarding flow.

Changes

File(s) Summary of Changes
Frontend/src/components/Onboarding.tsx Added exit confirmation dialog, logout and skip options, clickable step navigation, progress saving, improved UI and error handling for onboarding navigation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant OnboardingComponent
    participant AuthContext
    participant LocalStorage
    participant Router

    User->>OnboardingComponent: Clicks "Logout" or "Skip for now"
    OnboardingComponent->>OnboardingComponent: Show exit confirmation dialog
    User->>OnboardingComponent: Confirms exit action
    alt Logout
        OnboardingComponent->>AuthContext: Call logout()
        AuthContext-->>OnboardingComponent: Logout result
        OnboardingComponent->>Router: Navigate to login/dashboard
    else Skip
        OnboardingComponent->>LocalStorage: Save onboarding progress
        OnboardingComponent->>Router: Navigate to dashboard
    end
    OnboardingComponent->>OnboardingComponent: Handle errors/loading states
Loading
sequenceDiagram
    participant User
    participant OnboardingComponent

    User->>OnboardingComponent: Clicks completed step in progress indicator
    OnboardingComponent->>OnboardingComponent: Navigate to selected previous step
Loading

Assessment against linked issues

Objective Addressed Explanation
Add logout option during onboarding (#93)
Add back navigation to previous onboarding steps (#93)
Add "Skip for now" option and exit confirmation dialog (#93)
Progress indicator with clickable steps for backward movement (#93)
Auto-save onboarding progress for resuming later (#93)

Poem

A bunny hops through onboarding’s maze,
Now logout and skip light up the ways!
Breadcrumbs clickable, steps to retrace,
Progress is saved—no need to race.
With dialogs gentle and icons bright,
Users and rabbits both leap with delight!
🐇✨
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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 (2)
Frontend/src/components/Onboarding.tsx (2)

643-688: Clean up empty lines and improve error message.

The exit confirmation logic is well-implemented, but there are a few minor improvements needed:

Remove the empty lines and improve the error message specificity:

  const handleExitConfirm = async () => {
    setExitLoading(true);
    setExitError("");
    
    try {
-      
-      
      if (exitAction === 'logout') {
        await logout();
        // Note: logout() should handle navigation, so we don't close dialog here
        // The AuthContext logout function should redirect to home page
      } else if (exitAction === 'skip') {
        console.log("Skipping onboarding...");
        // Save current progress to localStorage for later
        const progressData = {
          step,
          role,
          personal,
          selectedPlatforms,
          platformDetails,
          pricing,
          profilePic: null, // Can't save file to localStorage
          brandStep,
          brandData: { ...brandData, logo: null }, // Can't save file to localStorage
          timestamp: Date.now()
        };
        localStorage.setItem('onboarding_progress', JSON.stringify(progressData));
        
        // Navigate to appropriate dashboard
        if (role === "brand") {
          navigate('/brand/dashboard');
        } else {
          navigate('/dashboard');
        }
        
        // Close dialog after navigation
        setShowExitDialog(false);
        setExitAction(null);
      }
    } catch (error) {
      console.error("Error in handleExitConfirm:", error);
-      setExitError(`Failed to ${exitAction}. Please try again.`);
+      setExitError(exitAction === 'logout' ? 'Failed to logout. Please try again.' : 'Failed to save progress. Please try again.');
    } finally {
      setExitLoading(false);
    }
  };

66-1740: Consider splitting this large component for better maintainability.

This component has grown to over 1700 lines. Consider extracting some parts into separate components:

  • Exit confirmation dialog component
  • Stepper UI component
  • Individual step form components
  • Brand onboarding flow as a separate component

This would improve code organization, reusability, and make the codebase easier to maintain.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3437948 and 8400474.

📒 Files selected for processing (1)
  • Frontend/src/components/Onboarding.tsx (9 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
Frontend/src/components/Onboarding.tsx (1)
Frontend/src/context/AuthContext.tsx (1)
  • useAuth (216-222)
🔇 Additional comments (8)
Frontend/src/components/Onboarding.tsx (8)

4-4: Icon imports look good.

The addition of LogOut, X, ArrowLeft, and AlertCircle icons from lucide-react aligns with the UI improvements for the navigation flow.


68-68: Auth context and state management properly implemented.

Good implementation of:

  • Extracting the logout function from the auth context for the new logout feature
  • Properly typed state variables for exit dialog management with appropriate initial values

Also applies to: 88-93


697-707: Step navigation properly restricted to completed steps.

Good implementation that only allows users to navigate back to previously completed steps, maintaining the integrity of the onboarding flow.


710-730: Progress restoration with expiration is well-implemented.

Excellent implementation of progress restoration with:

  • 24-hour expiration check to ensure data freshness
  • Proper error handling for JSON parsing
  • Restoration of all relevant state variables

1171-1192: Header navigation controls are well-designed.

Good implementation with:

  • Clear visual hierarchy with the InPact branding
  • Conditional rendering of the "Skip for now" button after role selection
  • Consistent styling and hover effects
  • Proper icon usage for the logout button

1194-1251: Interactive stepper with visual feedback is excellent.

The enhanced stepper implementation provides:

  • Clear visual distinction between active, completed, and pending steps
  • Clickable completed steps for backward navigation
  • Hover effects for better UX
  • Checkmarks for completed steps
  • Consistent implementation for both brand and creator flows

1277-1341: Navigation controls enhanced with better visual feedback.

Excellent improvements:

  • ArrowLeft icon enhances the back button
  • Step counter (e.g., "Step 2 of 7") provides clear progress context
  • Consistent hover effects and disabled states
  • Proper handling for both brand and creator flows

1348-1403: Exit confirmation dialog is well-structured.

Great implementation with:

  • Clear messaging differentiating logout vs skip actions
  • Loading states with spinner animation
  • Error message display
  • Proper button disable states during operations
  • Conditional button styling based on action type


{/* Exit Confirmation Dialog */}
{showExitDialog && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-opacity-50">
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix missing background color class for dialog overlay.

The overlay div uses bg-opacity-50 but is missing the actual background color class.

-        <div className="fixed inset-0 z-50 flex items-center justify-center bg-opacity-50">
+        <div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
📝 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
<div className="fixed inset-0 z-50 flex items-center justify-center bg-opacity-50">
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
🤖 Prompt for AI Agents
In Frontend/src/components/Onboarding.tsx at line 1347, the overlay div has a
background opacity class but lacks a background color class. Add an appropriate
background color class such as 'bg-black' or 'bg-gray-900' alongside
'bg-opacity-50' to ensure the overlay has a visible background color with the
specified opacity.

if (role === "brand") {
navigate('/brand/dashboard');
} else {
navigate('/dashboard');
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure if this is the logical way forward....the code is simply giving users a way to bypass onboarding especially the above code snippet....it is doing direct redirection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haved test it
it is working properly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And also in the PR #92 i have solved the goole auth process
you mention

Copy link
Collaborator

Choose a reason for hiding this comment

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

I haved test it it is working properly

ohh ...no problem then....I'll review the good when I get some free time....in the meantime can you ,in the pr description also attach. screen recording of the process?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yaa sure

@Aditya30ag
Copy link
Contributor Author

@varunchitre15 please you can also have a look in that

@Aditya30ag
Copy link
Contributor Author

Untitled.video.-.Made.with.Clipchamp.mp4

@Saahi30
Copy link
Collaborator

Saahi30 commented Jul 16, 2025

so the idea is to keep the basic fields which we'll need later on for creator recommendation and matching mandatory and not allow user to bypass them.....

@Aditya30ag
Copy link
Contributor Author

Aditya30ag commented Jul 16, 2025

@Saahi30 By Understanding your Feedback
instead of allowing users to completely skip the onboarding flow, I should:
Keep essential fields mandatory - These are fields needed for creator recommendation and matching algorithms
Allow skipping only non-essential fields - Users can bypass optional/niche fields but must complete core profile information
Prevent complete bypass - Don't let users skip the entire onboarding process

@Aditya30ag
Copy link
Contributor Author

Aditya30ag commented Jul 16, 2025

Fix: Smart Skip Functionality for Onboarding Flow

📝 Description

This PR implements smart skip functionality that prevents users from bypassing essential fields while allowing them to skip optional fields. This ensures better creator-brand matching while maintaining user flexibility.

🔧 Changes Made

Essential Fields (Required for Matching)

Creators: Role, Personal Details, Platform Selection, Platform Details
Brands: Brand Details, Contact Information, Platform Selection

Optional Fields (Can Skip)

Creators: Pricing, Profile Picture
Brands: Social Links, Collaboration Preferences

Key Improvements

  • ✅ Smart validation prevents skipping before essential fields are complete
  • ✅ Visual indicators (red asterisk) mark essential steps
  • ✅ Clear error messages explain why skipping isn't allowed
  • ✅ Updated button text: "Skip remaining fields" with tooltip
  • ✅ Progress tracking with skipped state for later completion

🎯 Problem Solved

  • Users could previously skip entire onboarding, leading to poor creator-brand matching
  • No clear indication of which fields are essential vs optional
  • Poor user experience with unclear skip functionality

🧪 Testing

  • ✅ Skip validation works correctly for both creators and brands
  • ✅ Essential fields cannot be bypassed
  • ✅ Optional fields can be skipped after completing required information
  • ✅ Visual indicators display correctly
  • ✅ Error messages are informative and helpful

📷 Visual Changes

  • Added red asterisk (*) to essential step indicators
  • Updated skip button text and added tooltip
  • Added legend explaining essential field markers
  • Enhanced error messages with specific guidance

This ensures the platform collects essential data for matching while providing users flexibility to complete optional fields later.

image

##unless we fill all the mandatory detail it will not show the skip the remaining button

Copy link
Contributor

@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)
Frontend/src/components/Onboarding.tsx (1)

1406-1406: Fix missing background color class for dialog overlay.

The overlay div uses bg-opacity-50 but is missing the actual background color class.

-        <div className="fixed inset-0 z-50 flex items-center justify-center bg-opacity-50">
+        <div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8400474 and 6df3a38.

📒 Files selected for processing (1)
  • Frontend/src/components/Onboarding.tsx (10 hunks)
🔇 Additional comments (11)
Frontend/src/components/Onboarding.tsx (11)

4-4: LGTM on icon imports.

The new lucide-react icons are properly imported and used throughout the component for enhanced navigation and dialog functionality.


24-29: Well-defined essential steps for smart skip functionality.

The essential steps definition appropriately identifies the minimum required information for creator-brand matching while allowing flexibility for optional fields.


74-74: Appropriate auth context usage.

The logout function is correctly extracted from the auth context for the new logout functionality.


94-99: Well-structured state management for exit dialog.

The state variables are appropriately typed and named for managing the exit confirmation dialog and its various states.


644-647: Simple and correct exit request handler.

The function properly initiates the exit dialog flow by setting the action type and showing the dialog.


735-740: Proper cleanup function for exit dialog.

The function correctly resets all exit dialog state variables when the user cancels the action.


742-752: Good implementation of step navigation.

The function properly enables navigation to previously completed steps with appropriate validation to prevent forward navigation to incomplete steps.


754-775: Robust progress restoration implementation.

The useEffect properly loads saved progress with appropriate expiration checks and error handling, providing a good user experience for session restoration.


1214-1238: Well-designed header with clear navigation options.

The header provides intuitive logout and skip functionality with appropriate conditional rendering, tooltips, and visual feedback.


1240-1310: Excellent stepper UI enhancement.

The enhanced stepper provides clear visual feedback with clickable navigation, essential step marking, and intuitive color coding that significantly improves the user experience.


1407-1462: Well-structured exit confirmation dialog.

The dialog provides clear messaging, proper error handling, loading states, and intuitive button interactions that enhance the user experience.

Comment on lines +649 to +733
const handleExitConfirm = async () => {
setExitLoading(true);
setExitError("");

try {
if (exitAction === 'logout') {
await logout();
// Note: logout() should handle navigation, so we don't close dialog here
// The AuthContext logout function should redirect to home page
} else if (exitAction === 'skip') {
console.log("Skipping non-essential onboarding fields...");

// Only allow skipping if essential fields are completed
if (role === "creator") {
// For creators, essential fields are: role, personal details, platform selection, platform details, pricing
const essentialFieldsComplete = role &&
personal.name && personal.email && personal.age && personal.gender &&
personal.category && personal.country &&
selectedPlatforms.length > 0;

if (!essentialFieldsComplete) {
setExitError("Please complete the essential fields (Personal Details, Platform Selection, and Platform Details) before skipping. These are required for creator matching.");
return;
}

// Allow skipping pricing and profile picture (non-essential for basic matching)
if (step < 4) { // Before pricing step
setExitError("Please complete platform details before skipping. This information is essential for creator matching.");
return;
}

} else if (role === "brand") {
// For brands, essential fields are: brand details, contact info, platforms
const essentialFieldsComplete = brandData.brand_name &&
brandData.website_url && brandData.industry && brandData.company_size &&
brandData.location && brandData.description &&
brandData.contact_person && brandData.contact_email &&
brandData.platforms.length > 0;

if (!essentialFieldsComplete) {
setExitError("Please complete the essential fields (Brand Details, Contact Information, and Platform Selection) before skipping. These are required for brand matching.");
return;
}

// Allow skipping social links and collaboration preferences (non-essential for basic matching)
if (brandStep < 2) { // Before social links step
setExitError("Please complete platform selection before skipping. This information is essential for brand matching.");
return;
}
}

// Save current progress to localStorage for later
const progressData = {
step,
role,
personal,
selectedPlatforms,
platformDetails,
pricing,
profilePic: null, // Can't save file to localStorage
brandStep,
brandData: { ...brandData, logo: null }, // Can't save file to localStorage
timestamp: Date.now(),
skipped: true // Mark as skipped for later completion
};
localStorage.setItem('onboarding_progress', JSON.stringify(progressData));

// Navigate to appropriate dashboard
if (role === "brand") {
navigate('/brand/dashboard');
} else {
navigate('/dashboard');
}

// Close dialog
setShowExitDialog(false);
setExitAction(null);
}
} catch (error) {
console.error("Error in handleExitConfirm:", error);
setExitError(`Failed to ${exitAction}. Please try again.`);
} finally {
setExitLoading(false);
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Complex exit confirmation logic needs validation improvements.

The function handles both logout and skip actions but has potential issues in the validation logic:

  1. Creator validation gap: Lines 675-678 only check if step < 4 but don't validate that platform details are actually completed. A user could be on step 4 with incomplete platform details.

  2. Consider more specific validation: The essential field validation could be more robust by checking actual data completeness rather than just step progression.

Consider this improvement for creator validation:

-          // Allow skipping pricing and profile picture (non-essential for basic matching)
-          if (step < 4) { // Before pricing step
-            setExitError("Please complete platform details before skipping. This information is essential for creator matching.");
-            return;
-          }
+          // Validate platform details are actually completed
+          const platformDetailsComplete = selectedPlatforms.length > 0 && 
+            selectedPlatforms.every(platform => {
+              const details = platformDetails[platform];
+              return details && (
+                platform === "YouTube" ? 
+                  details.channelUrl && details.channelId && details.channelName :
+                  details.profileUrl && details.followers && details.posts
+              );
+            });
+          
+          if (!platformDetailsComplete) {
+            setExitError("Please complete platform details before skipping. This information is essential for creator matching.");
+            return;
+          }
📝 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
const handleExitConfirm = async () => {
setExitLoading(true);
setExitError("");
try {
if (exitAction === 'logout') {
await logout();
// Note: logout() should handle navigation, so we don't close dialog here
// The AuthContext logout function should redirect to home page
} else if (exitAction === 'skip') {
console.log("Skipping non-essential onboarding fields...");
// Only allow skipping if essential fields are completed
if (role === "creator") {
// For creators, essential fields are: role, personal details, platform selection, platform details, pricing
const essentialFieldsComplete = role &&
personal.name && personal.email && personal.age && personal.gender &&
personal.category && personal.country &&
selectedPlatforms.length > 0;
if (!essentialFieldsComplete) {
setExitError("Please complete the essential fields (Personal Details, Platform Selection, and Platform Details) before skipping. These are required for creator matching.");
return;
}
// Allow skipping pricing and profile picture (non-essential for basic matching)
if (step < 4) { // Before pricing step
setExitError("Please complete platform details before skipping. This information is essential for creator matching.");
return;
}
} else if (role === "brand") {
// For brands, essential fields are: brand details, contact info, platforms
const essentialFieldsComplete = brandData.brand_name &&
brandData.website_url && brandData.industry && brandData.company_size &&
brandData.location && brandData.description &&
brandData.contact_person && brandData.contact_email &&
brandData.platforms.length > 0;
if (!essentialFieldsComplete) {
setExitError("Please complete the essential fields (Brand Details, Contact Information, and Platform Selection) before skipping. These are required for brand matching.");
return;
}
// Allow skipping social links and collaboration preferences (non-essential for basic matching)
if (brandStep < 2) { // Before social links step
setExitError("Please complete platform selection before skipping. This information is essential for brand matching.");
return;
}
}
// Save current progress to localStorage for later
const progressData = {
step,
role,
personal,
selectedPlatforms,
platformDetails,
pricing,
profilePic: null, // Can't save file to localStorage
brandStep,
brandData: { ...brandData, logo: null }, // Can't save file to localStorage
timestamp: Date.now(),
skipped: true // Mark as skipped for later completion
};
localStorage.setItem('onboarding_progress', JSON.stringify(progressData));
// Navigate to appropriate dashboard
if (role === "brand") {
navigate('/brand/dashboard');
} else {
navigate('/dashboard');
}
// Close dialog
setShowExitDialog(false);
setExitAction(null);
}
} catch (error) {
console.error("Error in handleExitConfirm:", error);
setExitError(`Failed to ${exitAction}. Please try again.`);
} finally {
setExitLoading(false);
}
};
const handleExitConfirm = async () => {
setExitLoading(true);
setExitError("");
try {
if (exitAction === 'logout') {
await logout();
// Note: logout() should handle navigation, so we don't close dialog here
// The AuthContext logout function should redirect to home page
} else if (exitAction === 'skip') {
console.log("Skipping non-essential onboarding fields...");
// Only allow skipping if essential fields are completed
if (role === "creator") {
// For creators, essential fields are: role, personal details, platform selection, platform details, pricing
const essentialFieldsComplete = role &&
personal.name && personal.email && personal.age && personal.gender &&
personal.category && personal.country &&
selectedPlatforms.length > 0;
if (!essentialFieldsComplete) {
setExitError("Please complete the essential fields (Personal Details, Platform Selection, and Platform Details) before skipping. These are required for creator matching.");
return;
}
// Validate platform details are actually completed
const platformDetailsComplete = selectedPlatforms.length > 0 &&
selectedPlatforms.every(platform => {
const details = platformDetails[platform];
return details && (
platform === "YouTube"
? details.channelUrl && details.channelId && details.channelName
: details.profileUrl && details.followers && details.posts
);
});
if (!platformDetailsComplete) {
setExitError("Please complete platform details before skipping. This information is essential for creator matching.");
return;
}
} else if (role === "brand") {
// For brands, essential fields are: brand details, contact info, platforms
const essentialFieldsComplete = brandData.brand_name &&
brandData.website_url && brandData.industry && brandData.company_size &&
brandData.location && brandData.description &&
brandData.contact_person && brandData.contact_email &&
brandData.platforms.length > 0;
if (!essentialFieldsComplete) {
setExitError("Please complete the essential fields (Brand Details, Contact Information, and Platform Selection) before skipping. These are required for brand matching.");
return;
}
// Allow skipping social links and collaboration preferences (non-essential for basic matching)
if (brandStep < 2) { // Before social links step
setExitError("Please complete platform selection before skipping. This information is essential for brand matching.");
return;
}
}
// Save current progress to localStorage for later
const progressData = {
step,
role,
personal,
selectedPlatforms,
platformDetails,
pricing,
profilePic: null, // Can't save file to localStorage
brandStep,
brandData: { ...brandData, logo: null }, // Can't save file to localStorage
timestamp: Date.now(),
skipped: true // Mark as skipped for later completion
};
localStorage.setItem('onboarding_progress', JSON.stringify(progressData));
// Navigate to appropriate dashboard
if (role === "brand") {
navigate('/brand/dashboard');
} else {
navigate('/dashboard');
}
// Close dialog
setShowExitDialog(false);
setExitAction(null);
}
} catch (error) {
console.error("Error in handleExitConfirm:", error);
setExitError(`Failed to ${exitAction}. Please try again.`);
} finally {
setExitLoading(false);
}
};
🤖 Prompt for AI Agents
In Frontend/src/components/Onboarding.tsx around lines 649 to 733, the exit
confirmation logic for skipping onboarding has insufficient validation for
creators, as it only checks if the step number is less than 4 without verifying
if platform details are fully completed. To fix this, enhance the validation by
explicitly checking the completeness of platform details data rather than
relying solely on the step number. Update the condition to validate that all
required platform details fields are filled before allowing the user to skip,
ensuring more robust and accurate validation of essential fields.

@Saahi30
Copy link
Collaborator

Saahi30 commented Jul 16, 2025

so by essential field what I meant was that every section/step of the onboarding process....to simplify dont just generalise that these 4-5 fields are imp/mandatory rest none like it is done In the code...rather go through each onboarding step and understand what all fields are crucial and what not for data collection...if you want you can take reference to the current code.....

@Saahi30
Copy link
Collaborator

Saahi30 commented Jul 16, 2025

P.S handle all the code rabbit suggestions

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.

BUG:Missing Logout and Back Navigation During Onboarding Flow
2 participants