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

Solution #2713

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #2713

wants to merge 1 commit into from

Conversation

AndreaTkachuk
Copy link

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on implementing the main components and meeting most of the task requirements! 🎉 While there are some areas for improvement, such as refining event handler naming conventions and simplifying filtering logic, these are minor issues that don't critically impact the functionality. Keep up the good work, and consider the suggested improvements for future projects to enhance code readability and maintainability. 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

Comment on lines +33 to +39
const handlerInput = (e: React.ChangeEvent<HTMLInputElement> | string) => {
if (typeof e === 'string') {
setQuery('');
} else {
setQuery(e.target.value);
}
};

Choose a reason for hiding this comment

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

The handlerInput function accepts a parameter that can be either a string or an event. This dual-purpose parameter might lead to confusion. Consider separating the logic or ensuring the function is only called with one type of parameter.

Comment on lines +29 to +31
const handlerSelect = (e: React.ChangeEvent<HTMLSelectElement>) => {
setShowTodos(e.target.value);
};

Choose a reason for hiding this comment

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

Consider renaming handlerSelect to handleSelectChange for better readability and to follow common naming conventions for event handlers.

Comment on lines +33 to +39
const handlerInput = (e: React.ChangeEvent<HTMLInputElement> | string) => {
if (typeof e === 'string') {
setQuery('');
} else {
setQuery(e.target.value);
}
};

Choose a reason for hiding this comment

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

Consider renaming handlerInput to handleInputChange for better readability and to follow common naming conventions for event handlers.


type Props = {
handlerSelect: (event: React.ChangeEvent<HTMLSelectElement>) => void;
handlerInput: (event: React.ChangeEvent<HTMLInputElement> | string) => void;

Choose a reason for hiding this comment

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

The handlerInput prop is used for both handling input changes and clearing the input. Consider separating these concerns by using distinct functions for each action to improve clarity.

Comment on lines +10 to +11
handlerSelect: handlerFilter,
handlerInput: handlerInput,

Choose a reason for hiding this comment

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

Consider renaming handlerFilter and handlerInput to handleSelectChange and handleInputChange respectively, to follow common naming conventions for event handlers and improve code readability.

todos: Todo[];
select: string;
query: string;
handlerModButton: (todo: Todo) => void;

Choose a reason for hiding this comment

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

Consider renaming handlerModButton to handleModButtonClick to follow common naming conventions for event handlers and improve code readability.

Comment on lines +21 to +26
.filter(todo => {
if (select === 'all') {
return todo;
}

<tr data-cy="todo" className="">
<td className="is-vcentered">1</td>
<td className="is-vcentered" />
<td className="is-vcentered is-expanded">
<p className="has-text-danger">delectus aut autem</p>
</td>
<td className="has-text-right is-vcentered">
<button data-cy="selectButton" className="button" type="button">
<span className="icon">
<i className="far fa-eye" />
</span>
</button>
</td>
</tr>
return todo.completed === (select === 'completed');

Choose a reason for hiding this comment

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

The filtering logic can be simplified. Instead of using an if statement to return todo when select is 'all', you can directly return true for this condition.

Comment on lines +28 to +33
.filter(todo => {
if (!query) {
return todo;
}

<tr data-cy="todo" className="">
<td className="is-vcentered">6</td>
<td className="is-vcentered" />
<td className="is-vcentered is-expanded">
<p className="has-text-danger">
qui ullam ratione quibusdam voluptatem quia omnis
</p>
</td>
<td className="has-text-right is-vcentered">
<button data-cy="selectButton" className="button" type="button">
<span className="icon">
<i className="far fa-eye" />
</span>
</button>
</td>
</tr>
return 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.

The filtering logic for the query can be simplified. Instead of using an if statement to return todo when query is empty, you can directly return true for this condition.


type Props = {
todo: Todo | null;
handlerModButton: (todo: Todo | null) => void;

Choose a reason for hiding this comment

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

Consider renaming handlerModButton to handleModButtonClick to follow common naming conventions for event handlers and improve code readability.

Comment on lines +15 to +18
const [loading, setLoading] = React.useState(true);

useEffect(() => {
setLoading(true);

Choose a reason for hiding this comment

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

The loading state is set to true twice: once during initialization and again at the start of the useEffect. The second setting is redundant and can be removed.

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