tYuriy / react_add-todo-form

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Add TODO Form

Implement the ability to add TODOs to the TodoList implemented in the Static List of TODOs.

Here is the working example

  1. Create an App component storing the todos array and displaying it using the TodoList.
  2. Create a form to add new TODOs:
    • don't create a separate component for the form (later, we will learn how to do it);
    • there should be a text input for the title with data-cy="titleInput" attribute;
    • add a <select> with data-cy="userSelect" attribute showing all the given users;
    • add labels and placeholders where they are needed;
    • add a new todo to the list after clicking the Add button;
    • each TODO should have id, title, userId, and completed (false by default);
    • id is the largest id in the array + 1 (add data-id={todo.id} attribute to each .TodoInfo).
  3. Add validation to the form:
    • add a default empty option Choose a user to the select;
    • before creating a todo, check if a user was selected; if not, show an error message next to the select (Please choose a user);
    • if the title is empty, show an error message next to the title field (Please enter a title);
    • errors should appear only after clicking the Add button;
    • hide the message immediately after any change of the field with an error;
  4. If the form is valid, add a todo to the list and clear the form.
  5. (* Optional) Allow entering only letters (ru and en), digits, and spaces in the title field. Just remove any other characters from the title.

Instructions

About

License:GNU General Public License v3.0


Languages

Language:JavaScript 49.1%Language:TypeScript 45.7%Language:SCSS 3.3%Language:HTML 1.7%Language:Shell 0.2%