Skip to content

Conversation

axelvuillaume
Copy link

No description provided.

Comment on lines 83 to 103
const debouncedSaveSearchState = debounce(() => {
if (saveSearchState) {
localStorage.setItem('lastSearchQuery', query);
localStorage.setItem('lastSearchFilters', JSON.stringify(filters));
}
}, 1000);


useEffect(() => {
debouncedSaveSearchState();
return () => debouncedSaveSearchState.cancel();
}, [query, filters]);

useEffect(() => {
return () => {
if (saveSearchState) {
localStorage.removeItem('lastSearchQuery');
localStorage.removeItem('lastSearchFilters');
}
};
}, [query, filters, saveSearchState]);
}, [saveSearchState]);

Choose a reason for hiding this comment

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

éviter de laisser des localhost comme ça, autant faire tout en state ou à la rigueur enregistrer ça en base si c'est important.

Comment on lines 106 to 115
const handleFilterChange = (e) => {
const { name, value, type, checked } = e.target;
const newValue = type === 'checkbox' ? checked : value;

setFilters(prev => ({
...prev,
[name]: type === 'checkbox' ? checked : value
[name]: newValue,
}));
setPage(1); // Reset page when filters change
};

Choose a reason for hiding this comment

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

directement mettre les éléments dans les onChange et pas faire une fonction générique pour les filtres.

Comment on lines 67 to 72
const categorizedProducts = products.reduce((acc, product) => {
acc[product.category] = acc[product.category] || [];
acc[product.category].push(product);
return acc;
}, {});

Choose a reason for hiding this comment

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

on privilégie ça côté back la plus part du temps

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