Skip to content

complete part 1 of todo app#2421

Open
Roma-Yamshchikov wants to merge 2 commits into
mate-academy:masterfrom
Roma-Yamshchikov:develop
Open

complete part 1 of todo app#2421
Roma-Yamshchikov wants to merge 2 commits into
mate-academy:masterfrom
Roma-Yamshchikov:develop

Conversation

@Roma-Yamshchikov

Copy link
Copy Markdown

@etojeDenys etojeDenys left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

almost done

  1. split the app into several components

Comment thread src/App.tsx Outdated
const [title, setTitle] = useState('');
const [todos, setTodos] = useState<Todo[]>([]);
const [error, setError] = useState<string | null>(null);
const [filter, setFilter] = useState('all');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create an enum for the filter parameters

Comment thread src/App.tsx Outdated
setError(null);
getTodos()
.then(setTodos)
.catch(() => setError('Unable to load todos'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create an enum for errors as well

Comment thread src/App.tsx Outdated
Comment on lines +138 to +158
<a
href="#/"
className={classNames('filter__link', {
selected: filter === 'all',
})}
data-cy="FilterLinkAll"
onClick={() => setFilter('all')}
>
All
</a>

{/* 'is-active' class puts this modal on top of the todo */}
<div data-cy="TodoLoader" className="modal overlay is-active">
<div className="modal-background has-background-white-ter" />
<div className="loader" />
</div>
</div>
</section>

{/* Hide the footer if there are no todos */}
<footer className="todoapp__footer" data-cy="Footer">
<span className="todo-count" data-cy="TodosCounter">
3 items left
</span>

{/* Active link should have the 'selected' class */}
<nav className="filter" data-cy="Filter">
<a
href="#/"
className="filter__link selected"
data-cy="FilterLinkAll"
>
All
</a>
<a
href="#/active"
className={classNames('filter__link', {
selected: filter === 'active',
})}
data-cy="FilterLinkActive"
onClick={() => setFilter('active')}
>
Active
</a>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can create an array with the required parameters and then map through it to create links and avoid code repetition

@etojeDenys etojeDenys left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants