Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react_dynamic-list-of-todos_v-01 #1952

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

DenysKolbasin
Copy link

src/App.tsx Outdated
Comment on lines 17 to 18
const [query, setQuery] = useState<string>('');
const [status, setStatus] = useState<string>('all');

Choose a reason for hiding this comment

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

it's redundant to specify the primitive types

Copy link

@DarkMistyRoom DarkMistyRoom left a comment

Choose a reason for hiding this comment

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

Good job! Some small fixes:

src/App.tsx Outdated

export const App: React.FC = () => {
const [todos, setTodos] = useState<Todo[]>([]);
const [loading, setLoading] = useState(false);

Choose a reason for hiding this comment

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

Suggested change
const [loading, setLoading] = useState(false);
const [isLoading, setIsLoading] = useState(false);

Choose a reason for hiding this comment

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

src/App.tsx Outdated
const [loading, setLoading] = useState(false);
const [selectedTodo, setSelectedTodo] = useState<Todo | null>(null);
const [query, setQuery] = useState('');
const [status, setStatus] = useState('all');

Choose a reason for hiding this comment

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

use enum for filter values

src/App.tsx Outdated
Comment on lines 29 to 30
(status === 'all' || (status === 'completed' && todo.completed) || (status === 'active' && !todo.completed))
&& todo.title.toLowerCase().includes(query.toLowerCase())

Choose a reason for hiding this comment

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

could you simplify this expression

Comment on lines 33 to 72
<tr
data-cy="todo"
key={todo.id}
className={cn({
'has-background-info-light': selectedTodo === todo,
})}
>
<td className="is-vcentered">{todo.id}</td>
<td className="is-vcentered">
{todo.completed && (
<span className="icon" data-cy="iconCompleted">
<i className="fas fa-check" />
</span>
)}
</td>
<td className="is-vcentered is-expanded">
<p
className={cn({
'has-text-success': todo.completed,
'has-text-danger': !todo.completed,
})}
>
{todo.title}
</p>
</td>
<td className="has-text-right is-vcentered">
<button
data-cy="selectButton"
className="button"
type="button"
onClick={() => onSelect(todo)}
>
<span className="icon">
<i
className={cn('far', {
'fa-eye-slash': selectedTodo === todo,
'fa-eye': selectedTodo !== todo,
})}
/>
</span>

Choose a reason for hiding this comment

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

let's move this logic to the TodoItem component

onClose = () => { },
selectedTodo,
}) => {
const [loading, setLoading] = useState(false);

Choose a reason for hiding this comment

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

Suggested change
const [loading, setLoading] = useState(false);
const [isLoading, setIsLoading] = useState(false);

Copy link

@VitaliyBondarenko1982 VitaliyBondarenko1982 left a comment

Choose a reason for hiding this comment

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

Looks good

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.

4 participants