mate-academy / 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:
    • 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 (ua and en), digits, and spaces in the title field. Just remove any other characters from the title.

Instructions

  • Install Prettier Extention and use this VSCode settings to enable format on save.
  • Implement a solution following the React task guideline.
  • Use the React TypeScript cheat sheet.
  • Open one more terminal and run tests with npm test to ensure your solution is correct.
  • Replace <your_account> with your Github username in the DEMO LINK and add it to the PR description.

About

License:GNU General Public License v3.0


Languages

Language:TypeScript 57.9%Language:JavaScript 36.7%Language:HTML 2.8%Language:SCSS 2.5%