Completed Task
- ✅ Todo List Display: View all todos with title, description, and completion status
- ✅ Add New Todo: Create new todos with validation
- ✅ Update Todo: Edit existing todos inline
- ✅ Mark as Complete: Toggle completion status with checkboxes
- ✅ Delete Todo: Remove todos with confirmation
- Simulated REST API: Mock API calls with realistic delays
- Network Latency: Simulated delays (400-800ms) for realistic UX
- Random Failures: 10% chance of API failures for error handling
- Full CRUD Operations: GET, POST, PUT, DELETE endpoints
- Loading States: Spinners and skeleton loaders during API calls
- Error Handling: Clear error messages with retry functionality
- Strict Typing: Comprehensive TypeScript interfaces
- Component Architecture: Reusable, well-structured components
- Responsive Design: Mobile-first design with Tailwind CSS
- Modern Hooks: useState, useEffect, useCallback, useMemo
- Component Lifecycles: Proper side effect management
- Clean Code: Well-commented, maintainable codebase
- React 18 - UI library with hooks
- TypeScript - Type safety and developer experience
- Tailwind CSS - Utility-first CSS framework
- Vite - Fast build tool and dev server
- ESLint - Code linting and formatting
src/
├── components/ # Reusable UI components
│ ├── AddTodoForm.tsx # Form for creating new todos
│ ├── ErrorMessage.tsx # Error display component
│ ├── LoadingSpinner.tsx # Loading state component
│ ├── TodoItem.tsx # Individual todo item
│ └── TodoList.tsx # Todo list with filtering/sorting
├── services/ # API and business logic
│ └── mockApi.ts # Mock API service
├── types/ # TypeScript type definitions
│ └── todo.ts # Todo-related interfaces
├── App.tsx # Main application component
├── main.tsx # Application entry point
└── index.css # Global styles and Tailwind imports
- Node.js (v16 or higher)
- npm or yarn
-
Install dependencies:
npm install
-
Start development server:
npm run dev
-
Open in browser: Navigate to
http://localhost:3000
npm run dev
- Start development servernpm run build
- Build for productionnpm run preview
- Preview production buildnpm run lint
- Run ESLint
The mockApi.ts
service simulates a real REST API with:
- Realistic delays: 400-800ms response times
- Error simulation: 10% random failure rate
- CRUD operations: Full create, read, update, delete functionality
- Type safety: Strongly typed request/response interfaces
The app uses React hooks for state management:
- useState: Local component state
- useEffect: Side effects and API calls
- useCallback: Memoized functions for performance
- useMemo: Computed values and filtering
- AddTodoForm: Handles todo creation with validation
- TodoItem: Individual todo with edit/delete functionality
- TodoList: Manages todo display with filtering and sorting
- LoadingSpinner: Reusable loading state component
- ErrorMessage: Consistent error display
Built with mobile-first approach:
- Tailwind CSS: Utility-first styling
- Responsive breakpoints: sm, md, lg, xl
- Touch-friendly: Large tap targets on mobile
- Accessible: Proper ARIA labels and keyboard navigation
GET /todos
- Fetch all todosPOST /todos
- Create new todoPUT /todos/:id
- Update existing todoDELETE /todos/:id
- Delete todo
The application includes comprehensive error handling:
- API errors: Network failures and server errors
- Validation errors: Form input validation
- User feedback: Clear error messages with retry options
- Graceful degradation: App continues working despite errors
- Memoized callbacks: Prevent unnecessary re-renders
- Efficient filtering: useMemo for computed values
- Lazy loading: Components load as needed
- Optimized re-renders: Proper dependency arrays
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - feel free to use this project for learning or as a starting point for your own applications.
Built with ❤️ using React, TypeScript, and Tailwind CSS (Dancel Ngonidzashe Mautsa)