Frontend School

Build a Multi-Step Order Placement Wizard

Machine Coding
medium

Build a Multi-Step Order Placement Wizard

Medium
React
Frontend
UI
Stepper
State Management

Overview

At Paytm, providing a seamless user experience for critical flows like order placement is paramount. A multi-step wizard helps users navigate complex processes by breaking them into manageable parts, reducing cognitive load and improving conversion rates. This problem challenges you to build a robust and intuitive Stepper Wizard component, crucial for guiding users through an e-commerce checkout or any sequential data entry process within our applications.

What you need to do / Task

Your primary task is to build a Stepper component in React that orchestrates a multi-step process.

  1. Implement the Stepper Component: Create a reusable Stepper component that takes an array of step configurations as props.
  2. Manage Step State: The Stepper should maintain its own internal state to track the currentStepIndex.
  3. Dynamic Content Rendering: Render the content associated with the currentStepIndex. Each step will have its own form or display.
  4. Navigation Controls: Implement "Next" and "Previous" buttons to move between steps.
    • The "Previous" button should be disabled when on the first step.
    • The "Next" button should be disabled if the current step's content is invalid (i.e., its form is not filled out correctly).
    • On the final step, the "Next" button should change its label to "Place Order" or "Submit".
  5. Step Validation: Each step's content should include a simple validation mechanism. The Stepper component should prevent advancement to the next step if the current step's content is invalid.
  6. Completion Handling: When "Place Order" is clicked on the final step, trigger a completion callback, simulating a successful order submission.

UI/UX expectations

  • Step Indicators: Display a clear visual indicator for each step (e.g., numbered circles or text labels), showing its title.
  • Active Step Highlight: The currently active step indicator must be visually distinct (e.g., different color, bold text).
  • Navigation Layout: Position "Previous" and "Next" buttons appropriately, typically at the bottom of the step content.
  • Form Elements: Each step's content will contain basic input fields (e.g., text inputs, textareas) and display any validation errors.
  • Minimal Styling: Focus on functionality, but ensure a basic, readable layout.

Acceptance criteria

  • The Stepper component renders correctly with all defined steps.
  • Clicking "Next" successfully advances the user to the subsequent step.
  • Clicking "Previous" successfully navigates the user to the prior step.
  • The "Previous" button is disabled when the currentStepIndex is 0 (first step).
  • The "Next" button is disabled if the current step's form content is invalid.
  • The "Next" button's label changes to "Place Order" on the last step.
  • Clicking the "Place Order" button on the final step triggers a confirmation (e.g., an alert or console log).
  • The active step indicator is clearly highlighted.
  • Attempting to navigate "Next" from an invalid step displays an error and keeps the user on the current step.

Constraints

Constraints & assumptions

  • You must use React functional components and hooks for state management.
  • Styling should be done using plain CSS (either inline, module, or global /styles.css). No external UI libraries (e.g., Material UI, Ant Design) are allowed.
  • Assume all step configurations (titles, content components) are provided upfront as an array.
  • Step content components will manage their own internal form state and expose a simple isValid property or function via onValidationChange callback.
  • Simple client-side validation is sufficient (e.g., checking if a text field is not empty).
  • The problem focuses on the Stepper logic and UI, not complex form state management within each step component.

Out of scope

  • Backend integration or API calls.
  • Advanced form validation patterns (e.g., regex, debounce, async validation).
  • Full accessibility implementation beyond basic button focus.
  • Complex responsive design.
  • Routing or URL management for steps.

What interviewers evaluate

  • Component Design: Modularity, reusability, and separation of concerns in the Stepper and step content components.
  • State Management: Effective use of React hooks (useState, useCallback, etc.) for managing the stepper's state and interactions.
  • Interaction Handling: Correct implementation of navigation logic, button disabling, and step validation.
  • Code Quality: Readability, maintainability, and adherence to best practices for React development.
  • Problem Solving: Ability to break down the problem into smaller, manageable parts and integrate them effectively.

Loading editor...