Welcome to the ELI React Intern coding task! This project is designed to help you learn React basics by implementing simple features in a pre-built Todo application.
This is a Todo List application with pre-built components and styling. Some basic functionality is already implemented for you, so you can focus on learning the core concepts.
Your task is to implement these three specific features:
- Adding new todos
- Deleting todos
- Toggling todo completion status
-
Clone the repository:
git clone https://github.com/YOUR-USERNAME/eli-react-intern-task.git cd eli-react-intern-task -
Install dependencies:
npm install -
Start the development server:
npm run dev
You'll only need to modify two files for this task:
src/components/todos/todo-form.tsx- For adding new todossrc/components/todos/todos-section.tsx- For deleting and toggling todos and handle creating new todos
Here's what you need to implement:
Find the handleSubmit & handleCreateTodo function in src/components/todos/todo-form.tsx and implement it to:
- Create a new todo using the
todoApi.createTodo()function - Clear the input field after submission
- Update the todo list in the UI with the new todo or refetch the todo list
Find the handleDeleteTodo function in src/components/todos/todos-section.tsx and implement it to:
- Delete a todo using the
todoApi.deleteTodo()function - Remove the deleted todo from the UI
Find the handleToggleTodo function in src/components/todos/todos-section.tsx and implement it to:
- Toggle a todo's completion status using the
todoApi.toggleTodo()function - Update the todo's status in the UI
- Use the existing code as a reference for how to call the API and update state
- Make sure to handle loading states and errors appropriately
- Use console.log() to debug if you get stuck
- The application already shows the list of todos - you just need to add the interactivity
We've provided the API functionality in src/api/todoApi.ts. The API includes methods for creating, deleting, and toggling todos:
createTodo(todoName: string): Create a new tododeleteTodo(id: number): Delete a todo by IDtoggleTodo({ id, completed }: TodoToggle): Toggle todo completion status
You can view the API documentation at:
Note: The URLs in the Swagger documentation do not exactly match the ones used in this project. The Swagger shows generic endpoints like /api/todos, while in our implementation we're using user-specific endpoints /api/users/eli-intern/todos. Use the Swagger for understanding the data models and response structures, but refer to the todoApi.ts file for the correct endpoints used in this project.
Good luck! Remember, the goal is to learn - don't be afraid to ask questions if you get stuck.