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

Task solution #2693

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

Task solution #2693

wants to merge 3 commits into from

Conversation

AnderZerfall
Copy link

@LiliiaVol
Copy link

Good code!

Copy link

@LiliiaVol LiliiaVol left a comment

Choose a reason for hiding this comment

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

Good work!

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.

Thank you for your hard work on this pull request! There are a few critical issues that need to be addressed to ensure the functionality and correctness of the code:

  1. Typing Issues: The setSelectedTodo, setFilterBy, and setQuery props need to be correctly typed to accept the appropriate parameters. This is crucial for the components to function as expected.

  2. Error Messages: There are typos in the error messages, such as 'occured' instead of 'occurred', and 'toods' instead of 'todos'. Clear and typo-free error messages are important for a good user experience.

  3. Descriptive Error Handling: Consider providing more descriptive error messages in the catch blocks to aid in debugging.

Please address these issues to ensure the code meets the core requirements. Once these changes are made, the pull request will be ready for approval. Keep up the great work! 🌟

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

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

src/App.tsx Outdated
export const App: React.FC = () => {
const [todoList, setTodoList] = useState<Todo[]>([]);
const [isLoading, setLoading] = useState(false);
const [selectedTodo, setSelectedTodo] = useState<Todo>(null);

Choose a reason for hiding this comment

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

The useState hook for selectedTodo is initialized with null, which is correct. However, ensure that the setSelectedTodo function in the TodoList and TodoModal components is typed to accept a Todo object or null.

src/App.tsx Outdated

getTodos()
.then(setTodoList)
.catch(e => setErrorMessage(e))

Choose a reason for hiding this comment

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

Consider providing a more descriptive error message in the catch block to help with debugging. For example, setErrorMessage('Failed to load todos: ' + e.message).

src/App.tsx Outdated
return (
<>
<div className="section">
<div className="container">
{hasErrorMessage && (
<h1 className="title">Error has occured while downloading toods</h1>

Choose a reason for hiding this comment

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

There is a typo in the error message: 'toods' should be 'todos'. Ensure that error messages are clear and free of typos to improve user experience.

</span>
type Props = {
query: string;
setQuery: () => void;

Choose a reason for hiding this comment

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

The setQuery prop should be a function that accepts a string parameter, not a function that returns void. Update the type to (value: string) => void.

type Props = {
query: string;
setQuery: () => void;
setFilterBy: () => void;

Choose a reason for hiding this comment

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

The setFilterBy prop should be a function that accepts a parameter, likely a string or a specific type related to FilterByState, not a function that returns void. Update the type to (value: string) => void or the appropriate type.

</thead>
type Props = {
todoList: Todo[];
setSelectedTodo: () => void;

Choose a reason for hiding this comment

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

The setSelectedTodo prop should be a function that accepts a Todo object, not a function that returns void. Update the type to (todo: Todo) => void.


type Props = {
selectedTodo: Todo;
setSelectedTodo: () => void;

Choose a reason for hiding this comment

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

The setSelectedTodo prop should be a function that accepts a Todo object or null, not a function that returns void. Update the type to (todo: Todo | null) => void.

if (userId) {
getUser(userId)
.then(data => setUserData(data))
.catch(e => setErrorMessage(e))

Choose a reason for hiding this comment

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

Consider providing a more descriptive error message in the catch block to help with debugging. For example, setErrorMessage('Failed to load user data: ' + e.message).

<Loader />
) : (
<div className="modal-card">
<header className="modal-card-head">
{hasErrorMessage && (
<p>An Error occured while downloading user data</p>

Choose a reason for hiding this comment

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

There is a typo in the error message: 'occured' should be 'occurred'. Ensure that error messages are clear and free of typos to improve user experience.

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 addressing the previous issues! 🎉 Your code now meets the task requirements and constraints. Here are a few points to consider for further improvement:

  • Typing Issues: Ensure that the setSelectedTodo, setFilterBy, and setQuery props are correctly typed. This is crucial for the components to function as expected. For instance, setSelectedTodo should accept Todo | null, and setFilterBy should handle FilterByState correctly, especially when dealing with event.target.value.

  • Error Messages: It's important to have clear and typo-free error messages. You've corrected the typo in 'todos', which is great. Consider making error messages more descriptive to aid in debugging.

Your efforts in resolving the issues are commendable. Keep up the good work, and continue to refine your skills by addressing these points. This will help you avoid similar issues in the future and enhance your coding proficiency. 🚀

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


getTodos()
.then(setTodoList)
.catch(e => setErrorMessage('Failed to download the todos' + e.message))

Choose a reason for hiding this comment

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

There is a typo in the error message: 'Failed to download the todos'. Ensure that error messages are clear and typo-free for a good user experience.

<TodoFilter />
<TodoFilter
query={query}
setQuery={setQuery}

Choose a reason for hiding this comment

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

The setQuery prop should be correctly typed to accept the appropriate parameter. Ensure that the function signature matches the expected type.

<TodoFilter
query={query}
setQuery={setQuery}
setFilterBy={setFilterBy}

Choose a reason for hiding this comment

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

The setFilterBy prop should be correctly typed to accept the appropriate parameter. Ensure that the function signature matches the expected type.

{!isLoading && !hasErrorMessage && (
<TodoList
todoList={filteredTodos}
setSelectedTodo={setSelectedTodo}

Choose a reason for hiding this comment

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

The setSelectedTodo prop should be correctly typed to accept the appropriate parameter. Ensure that the function signature matches the expected type.

<span className="select">
<select
data-cy="statusSelect"
onChange={event => setFilterBy(event.target.value as FilterByState)}

Choose a reason for hiding this comment

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

The setFilterBy function is typed to accept a FilterByState but event.target.value is of type string. Consider using a type assertion or a type-safe way to convert the string to FilterByState.

if (userId) {
getUser(userId)
.then(data => setUserData(data))
.catch(e => setErrorMessage(e.message))

Choose a reason for hiding this comment

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

Consider providing more descriptive error messages in the catch block to aid in debugging. This will help identify the source of the error more easily.


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

Choose a reason for hiding this comment

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

Ensure that the setSelectedTodo function is correctly typed to accept Todo | null. This is crucial for the component to function as expected.

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.

3 participants