Frontend School

Advanced Multi-Step Campaign Configuration Form

Machine Coding
hard

Advanced Multi-Step Campaign Configuration Form

Hard
React
Forms
State Management
Multi-step
Validation
Accessibility

Overview

As a senior engineer at a leading marketing technology company, you're tasked with enhancing the campaign creation workflow. The current process involves a complex form that is difficult to navigate and prone to errors. Your goal is to build a robust, multi-step form that guides users through campaign configuration, ensuring data integrity and a smooth user experience. This problem is crucial for streamlining our core product and improving user efficiency in launching successful marketing campaigns.

What you need to do / Task

Your primary task is to implement a multi-step form for creating a marketing campaign. This involves:

  1. Multi-Step Structure: Create a form with at least four distinct steps:

    • Step 1: Campaign Details: Basic information like campaignName (text) and campaignType (select: 'Display', 'Search', 'Social').
    • Step 2: Targeting: Define the targetAudience (text) and platforms (checkboxes: 'Google Ads', 'Facebook Ads', 'Instagram Ads'), geoTargeting (text, optional).
    • Step 3: Budget & Schedule: Set budgetAmount (number), startDate (date), and endDate (date).
    • Step 4: Review & Submit: A read-only summary of all entered data with a final submit button.
  2. Navigation: Implement "Next" and "Previous" buttons to navigate between steps.

    • The "Next" button should only become active/allow progression if the current step's fields are valid.
    • The "Previous" button should always allow navigation back to prior steps.
    • Clicking on a completed or previous step in the step indicator should also allow direct navigation.
  3. Client-Side Validation: Implement comprehensive validation for each step:

    • Required Fields: Ensure essential fields are not empty.
    • Format/Range Validation: e.g., budgetAmount must be a number > 100; endDate must be after startDate.
    • Dynamic/Conditional Validation: If campaignType (from Step 1) is 'Social', then 'Google Ads' should be disabled and unchecked in Step 2, and attempting to select it should show an error.
  4. Data Persistence: All entered form data must persist as the user navigates between steps.

  5. Dynamic UI: Implement conditional rendering for specific fields:

    • In Step 3, if budgetAmount exceeds 5000, a new checkbox field budgetApprovalRequired should appear.
  6. Submission: On the final "Review & Submit" step, clicking "Submit Campaign" should simulate an API call (e.g., using setTimeout) and display a success or error message.

UI/UX expectations

  • Clear Step Indicator: Display a visual indicator (e.g., numbered circles or a progress bar) showing the current step and overall progress.
  • Form Field Feedback: Each input field should have a clear label, and validation errors should be displayed immediately below the respective field when validation fails.
  • Button States: "Next" and "Submit" buttons should be disabled when the current step's data is invalid or during submission.
  • Accessibility: Use semantic HTML elements (e.g., label for inputs, fieldset/legend for groups) and ensure error messages are associated with their fields (e.g., via aria-describedby if you use a library or manually manage).
  • Review Display: The final review step should clearly present all collected data in a readable, non-editable format.

Acceptance criteria

  • The form correctly displays 4 distinct steps with appropriate content.
  • Users can navigate forward only if the current step's data is valid.
  • Users can navigate backward at any time without losing data.
  • All specified validation rules (required, range, conditional) are correctly enforced.
  • Error messages are displayed next to the relevant fields when validation fails.
  • Form data is preserved when navigating between steps.
  • The budgetApprovalRequired checkbox conditionally appears based on the budgetAmount in Step 3.
  • 'Google Ads' platform checkbox is disabled and correctly validated based on campaignType from Step 1.
  • The "Review & Submit" step accurately displays all entered form data.
  • Clicking "Submit Campaign" on the final step triggers a simulated API call and shows submission status.

Constraints

Constraints & assumptions

  • You should use React for this problem.
  • Avoid using heavy external form libraries (e.g., Formik, React Hook Form) unless you finish the core requirements early and want to demonstrate advanced usage. The expectation is to implement state and validation logic manually or with minimal utility libraries.
  • All validation should be client-side.
  • Simulate API calls for submission; no actual backend integration is required.
  • Focus on functionality and clear UI feedback; extensive styling beyond basic readability is not a primary concern.

Out of scope

  • Full-fledged routing (e.g., react-router-dom) for individual steps. Internal state management for steps is sufficient.
  • Complex animations or highly polished UI/UX beyond basic usability and feedback.
  • Server-side validation.

What interviewers evaluate

  • Robust State Management: How effectively you manage complex form data and validation states across multiple components and steps.
  • Conditional Logic & Dynamic UI: Your ability to implement conditional rendering, validation, and field dependencies based on user input.
  • Component Design: The clarity, reusability, and separation of concerns in your React component structure.
  • Attention to Detail: Correct handling of edge cases, user feedback (error messages, loading states), and basic accessibility considerations.

Loading editor...