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:
- Personal Details: Collect Full Name, Email, and Phone Number.
- Financial Profile: Collect Occupation and Annual Income.
- Investment Preferences: Collect Risk Tolerance and Investment Horizon.
- 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).