Overview
Urban Company's success relies heavily on its network of skilled service partners. Often, these partners need to upload various documents or media—such as identity proofs, before-and-after service photos, or completion certificates—to comply with service guidelines or update their profiles. This problem focuses on building a robust and user-friendly frontend component that allows partners to efficiently upload multiple files, providing clear visual feedback and management capabilities before final submission. This component is crucial for streamlining operational workflows and ensuring data accuracy.
What you need to do / Task
Your task is to build a FileUploader React component with the following features:
- File Input: Implement a mechanism for users to select files, supporting both clicking to open a file dialog and drag-and-drop functionality into a designated area.
- Multiple File Support: Allow users to select and add multiple files simultaneously.
- File List Display: Display a clear list of all selected files. Each item in the list should show:
- The file name.
- The file size (formatted for readability, e.g., "1.2 MB").
- For image files (
image/*), a small thumbnail preview.
- File Removal: Provide an option to remove individual files from the list before they are uploaded.
- Simulated Upload Progress: When an "Upload All" button is clicked, simulate an upload process for each file. Display a progress bar or percentage for each file, updating it over a short duration (e.g., 2-3 seconds).
- Constraints Handling: Implement basic client-side validation for file type and size as specified in the constraints.
UI/UX expectations
- Drag-and-Drop Zone: A clearly visible area indicating where files can be dropped, with visual feedback (e.g., border change) when files are dragged over it.
- File List: A vertically stacked list of selected files, each with its details and actions arranged logically.
- Thumbnails: Image thumbnails should be small and not distort the layout.
- Progress Indicators: Progress bars should be intuitive and update smoothly.
- Action Buttons: Clear "Select Files" and "Upload All" buttons.
Acceptance criteria
- The component allows files to be added via both drag-and-drop and click-to-select methods.
- Multiple files can be selected and displayed in the list.
- Each listed file correctly shows its name and formatted size.
- Image files (
image/*) display a visual thumbnail preview.
- Individual files can be removed from the list before upload.
- Clicking "Upload All" triggers a simulated upload for each file, with a visible progress indicator updating for each.
- Files exceeding size or type constraints are rejected with a user-friendly message (e.g., console log or simple alert).