-
Notifications
You must be signed in to change notification settings - Fork 6
Exo5 Modif The three symptoms #6
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
base: main
Are you sure you want to change the base?
Conversation
exercises/the-three-symptoms.js
Outdated
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]); |
There was a problem hiding this comment.
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.
exercises/the-three-symptoms.js
Outdated
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 | ||
}; |
There was a problem hiding this comment.
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.
exercises/the-three-symptoms.js
Outdated
const categorizedProducts = products.reduce((acc, product) => { | ||
acc[product.category] = acc[product.category] || []; | ||
acc[product.category].push(product); | ||
return acc; | ||
}, {}); | ||
|
There was a problem hiding this comment.
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
No description provided.