Implement the ability to add TODOs to the TodoList
implemented in the Static List of TODOs.
Here is the working example
- Create an
App
component storing thetodos
array and displaying it using theTodoList
. - 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
withdata-cy="titleInput"
attribute; - add a
<select>
withdata-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
, andcompleted
(false
by default); id
is the largestid
in the array + 1 (adddata-id={todo.id}
attribute to each.TodoInfo
).
- 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 theselect
(Please choose a user
); - if the
title
is empty, show an error message next to thetitle
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;
- add a default empty option
- If the form is valid, add a todo to the list and clear the form.
- (* Optional) Allow entering only letters (
ru
anden
), digits, andspaces
in thetitle
field. Just remove any other characters from thetitle
.
- 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.