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

practice solution #23

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

YePolishchuk
Copy link

@YePolishchuk YePolishchuk commented Oct 13, 2023

Copy link

@polosanya polosanya left a comment

Choose a reason for hiding this comment

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

  1. Select All to see all the products.

It is impossible to select All if some user is selected
all

  1. Clear the value after the x button click.

The button doesn't clear the value
image

  1. Show a No results message if there are no products matching the current criteria
    Reset All Filters button should clear all the filters.

No products message doesn't match the design
image
image
Reset all filters button doesn't reset the search query
image

}));

export const App = () => {
const [currentPeople, setcurrentPeople] = useState('');

Choose a reason for hiding this comment

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

Why is it a string? The name or value is confusing

Comment on lines +10 to +19
const productsCategories = productsFromServer.map(product => ({
...product,
category: categoriesFromServer
.find(category => category.id === product.categoryId), // find by product.categoryId // find by category.ownerId
}));

const products = productsCategories.map(product => ({
...product,
user: usersFromServer
.find(person => person.id === product.category.ownerId), // find by product.categoryId // find by category.ownerId

Choose a reason for hiding this comment

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

Can't you use only one map to add both properties?

selectedProducts = selectedProducts
.filter(product => (
product.category.title === currentCategory
));

Choose a reason for hiding this comment

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

You can put all these checks into one filter method. Also, would be great to create a function for filtering and call it if query or some other filter changes

Comment on lines +141 to +145
onClick={() => {
setcurrentPeople('');
setQuery('');
setCurrentCategory('');
}}

Choose a reason for hiding this comment

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

Would be great to create a separate function to handle reset

Comment on lines +161 to +167
<span className="is-flex is-flex-wrap-nowrap">
ID

<a href="#/">
<span className="icon">
<i data-cy="SortIcon" className="fas fa-sort" />
</span>

Choose a reason for hiding this comment

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

Do you really need to hardcode all categories? You can map through them

Comment on lines +241 to +257
{/* <tr data-cy="Product">
<td className="has-text-weight-bold" data-cy="ProductId">
2
</td>

<td data-cy="ProductName">Bread</td>
<td data-cy="ProductCategory">🍞 - Grocery</td>

<td
data-cy="ProductUser"
className="has-text-danger"
>
Anna
</td>
</tr>

<tr data-cy="Product">

Choose a reason for hiding this comment

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

Don't forget to remove the comments

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