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 #2710

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

-solution #2710

wants to merge 1 commit into from

Conversation

RuslanSkl
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 todo list application! 🎉 The code is well-structured and meets the core requirements of the task. There are a few minor issues related to the handling of filter values and the select state that you might want to address for improved functionality and consistency. Keep up the good work and consider these suggestions for future enhancements! 😊

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

Comment on lines +19 to +50
function filterTodos(list: Todo[], params: Params) {
const { query, filter } = params;
let result: Todo[] = [];

if (filter) {
switch (filter) {
case 'all':
result = list;
break;

case 'active':
result = list.filter((todo: Todo) => !todo.completed);
break;

case 'completed':
result = list.filter((todo: Todo) => todo.completed);
break;

default:
result = list;
break;
}
}

if (query) {
result = result.filter((todo: Todo) =>
todo.title.toLowerCase().includes(query.toLowerCase()),
);
}

return result;
}

Choose a reason for hiding this comment

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

The filterTodos function uses a filter parameter, but the switch statement does not handle the case where filter is 'All'. This could lead to unexpected behavior since the initial state for filter is set to 'All'. Consider adding a case for 'All' or adjusting the initial state to match one of the handled cases.


const [select, setSelect] = useState(0);

const [filter, setFilter] = useState('All');

Choose a reason for hiding this comment

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

The initial state for filter is set to 'All', but this value is not handled in the filterTodos function. Ensure that the initial state matches one of the cases handled in the filterTodos function or add a case for 'All'.

const [todos, setTodos] = useState<Todo[]>([]);
const [loading, setLoading] = useState(false);

const [select, setSelect] = useState(0);

Choose a reason for hiding this comment

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

The select state is initialized with 0. Ensure that this initial value is intentional and aligns with the logic in your application, especially in the context of the TodoModal component.

data-cy="statusSelect"
onChange={event => setFilter(event.target.value)}
>
<option value="all">All</option>

Choose a reason for hiding this comment

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

The option value for 'All' is set to 'all'. Ensure that this matches the expected filter values in the filterTodos function in App.tsx. Currently, the filterTodos function does not handle 'all', which could lead to unexpected behavior.

{todos.map(todo => (
<tr
data-cy="todo"
className={cn(select === todo.id && 'has-background-info-light')}

Choose a reason for hiding this comment

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

The className conditionally applies 'has-background-info-light' when select equals todo.id. Ensure that the select prop is correctly managed and updated to reflect the intended selection logic. If select is initialized with 0, verify that this aligns with your application's logic for selecting todos.

return (
<div className="modal is-active" data-cy="modal">
<div className="modal-background" />
{select !== 0 && <div className="modal-background" />}

Choose a reason for hiding this comment

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

The modal background is displayed when select is not 0. Ensure that this logic aligns with the intended behavior of your application. If select is initialized with 0, verify that this condition is appropriate for showing the modal background.

</div>
todos.map(
todo =>
select === todo.id && (

Choose a reason for hiding this comment

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

The condition select === todo.id is used to render the modal content. Ensure that the select state is correctly managed to reflect the intended selection logic and avoid displaying incorrect data.

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