Frontend School

Local Business Finder with Interactive Map

Machine Coding
medium

Local Business Finder with Interactive Map

Medium
React
TypeScript
UI
Map
Leaflet
State Management

Overview

Gupshup's platform enables businesses to connect with their customers through various channels, often leveraging location-based services for discovery and engagement. In this problem, you will build a core component for a 'Local Business Finder' application. This component will display various business locations on an interactive map, allowing users to discover and view details of nearby establishments.

What you need to do / Task

Your task is to develop a React component that displays a list of businesses alongside an interactive map. The application should allow users to:

  1. Display Businesses: Render a list of predefined businesses and corresponding markers on a map.
  2. Filter by Category: Implement a category filter that dynamically updates both the business list and the map markers based on the selected category.
  3. Interactive Selection: When a business marker on the map is clicked, or a business item in the list is clicked, its details should be displayed in a dedicated panel. The selected business's marker on the map and its entry in the list should be visually highlighted.
  4. Map Centering: The map should automatically center on the selected business's location when it's chosen.

UI/UX expectations

  • The application should have a clear layout, ideally with the map occupying a significant portion of the screen, and a sidebar for the business list and details.
  • Markers on the map should be visually distinct, with the selected business's marker having a different appearance (e.g., color).
  • The business list should be scrollable if there are many entries.
  • The category filter should be intuitive (e.g., a dropdown).
  • Business details should be clearly presented in a dedicated panel.

Acceptance criteria

  • All mock businesses are initially displayed on the map as markers and in the business list.
  • Selecting a category from the filter correctly updates both the visible markers on the map and the business list.
  • Clicking on a business marker on the map displays its details in the detail panel and highlights the corresponding item in the business list.
  • Clicking on a business item in the list displays its details in the detail panel and highlights its corresponding marker on the map.
  • The map view automatically adjusts to center on the selected business's marker.
  • The selected business's marker uses a distinct icon/color (e.g., red) compared to unselected markers (default blue).

Constraints

Constraints & assumptions

  • You must use React (functional components with Hooks) and TypeScript.
  • All business data is provided as mock data within the App.tsx file.
  • The react-leaflet library is pre-configured and available for map rendering. You should use the provided MapContainer, TileLayer, Marker, and Popup components.
  • Focus on client-side UI logic and state management; no backend integration is required.
  • The application should be responsive enough for a desktop view, but full mobile responsiveness is not expected.

Out of scope

  • Fetching data from an API.
  • Advanced map features like clustering, custom routing, or complex geographic calculations.
  • Extensive error handling or input validation beyond basic type safety.
  • Performance optimizations for extremely large datasets (assume < 100 businesses).

What interviewers evaluate

  • Component Design: Clarity, modularity, and reusability of React components.
  • State Management: Effective use of React Hooks (useState, useEffect, useMemo, useCallback) for managing application state and data flow.
  • UI Interaction: Correct implementation of interactive elements and event handling (clicks, selections, filtering).
  • TypeScript Usage: Proper typing and adherence to TypeScript best practices.
  • Code Quality: Readability, maintainability, and clean code principles.

Loading editor...