Frontend School

Groww Investment Profile Setup Form

Machine Coding
medium

Groww Investment Profile Setup Form

Medium
multi-step form
React
Frontend
State Management
Validation
TypeScript

Overview

At Groww, we empower millions to invest in a simple and transparent way. A crucial part of this journey is setting up a user's investment profile, which involves collecting various pieces of information across multiple steps. This problem challenges you to build a robust and user-friendly multi-step form for 'Investment Profile Setup', ensuring a smooth data collection process with clear navigation and validation.

What you need to do / Task

Your primary goal is to implement a client-side multi-step form in React that guides a user through setting up their investment profile. The form should consist of four distinct steps:

  1. Personal Details: Collect Full Name, Email, and Phone Number.
  2. Financial Profile: Collect Occupation and Annual Income.
  3. Investment Preferences: Collect Risk Tolerance and Investment Horizon.
  4. Review & Confirm: Display all collected data for review.

Your implementation must satisfy the following:

  • Multi-step Structure: Create a clear separation between the steps, rendering only the active step's content.
  • Navigation: Implement 'Next' and 'Previous' buttons to move between steps. The 'Next' button should only be enabled if the current step's inputs are valid.
  • Progress Indicator: Display a visual indicator (e.g., a progress bar or step numbers) showing the user's current position in the form flow.
  • Data Persistence: Ensure that data entered in previous steps is retained when navigating back and forth within the form.
  • Client-side Validation: Implement basic validation for each step before allowing the user to proceed. For example, required fields, valid email format, and 10-digit phone number.
  • Form Submission: On the final 'Review & Confirm' step, a 'Submit' button should be available. Clicking it should log all collected form data to the console.

UI/UX expectations

  • The form should have a clean and intuitive layout, clearly separating input fields and navigation controls.
  • Each step should have a distinct title.
  • The progress indicator should visually update to reflect the active and completed steps.
  • Validation errors should be displayed clearly next to the corresponding input fields.
  • Basic responsiveness is expected (e.g., fields stack vertically on smaller screens, though a fixed-width container is acceptable for this exercise).

Acceptance criteria

  • The form renders with 'Personal Details' (Step 1) as the active step.
  • Clicking 'Next' proceeds to the next step if all inputs in the current step are valid.
  • Clicking 'Previous' navigates to the prior step, retaining previously entered data.
  • The 'Next' button is disabled if required fields in the current step are empty or invalid.
  • Error messages appear for invalid inputs and disappear once the input becomes valid.
  • The progress indicator accurately reflects the current step and completed steps.
  • On the 'Review & Confirm' step, all collected data from previous steps is displayed accurately.
  • Clicking 'Submit' on the final step logs the complete form data object to the browser console and shows an alert confirming submission.
  • The form should be implemented using React functional components and hooks (e.g., useState).

Constraints

Constraints & assumptions

  • Environment: React with TypeScript. Use functional components and hooks.
  • State Management: In-memory state management using React's built-in useState (or useReducer if preferred) is sufficient. No external state management libraries (e.g., Redux, Zustand) are required.
  • Backend: No backend integration is required. The 'Submit' action should only log data to the console.
  • Styling: Basic CSS is provided as a starting point. Focus on functionality over pixel-perfect design. You are free to modify or add styles as needed to meet UI/UX expectations.
  • Data Size: The form data is small and can be managed entirely within a single component's state or a few interconnected states.

Out of scope

  • Advanced form libraries (e.g., Formik, React Hook Form).
  • Complex validation schemas (e.g., Yup, Zod) – simple inline validation is sufficient.
  • Global state management beyond what's necessary for the multi-step form.
  • Accessibility (beyond basic semantic HTML and clear visual feedback).
  • Internationalization (i18n) or localization (l10n).

What interviewers evaluate

  • Component Design & Structure: How well the form is broken down into logical, maintainable components and how state is managed across them.
  • State Management: Effective and idiomatic use of React hooks (useState, potentially useEffect) to manage form data, current step, and validation errors.
  • Form Validation: Implementation of clear, actionable client-side validation for various input types.
  • User Experience: Smooth navigation, clear feedback mechanisms (e.g., error messages, progress indicator), and data persistence.
  • Code Quality & TypeScript Usage: Readability, maintainability, and correct application of TypeScript for type safety.

Loading editor...