Skip to content
Snippets Groups Projects

Resolve "[1] [SGE - Backoffice] Amélioration distinction consentement expirés/valides"

1 file
+ 24
21
Compare changes
  • Side-by-side
  • Inline
@@ -153,25 +153,28 @@ const Consents: React.FC = () => {
}
}, [gridApi, selectedNodes])
const handleSearchChange = useCallback(
async (newSearch: string) => {
setSearch(newSearch)
if (user) {
const consentPagination = await consentService.searchConsents(
newSearch,
rowsPerPage,
page,
getAxiosXSRFHeader(user.xsrftoken)
)
if (consentPagination) {
setConsents(consentPagination.rows)
checkSelectedNodes()
setTotalRows(consentPagination.totalRows)
}
const searchConsents = async () => {
if (user) {
const consentPagination = await consentService.searchConsents(
search,
rowsPerPage,
page,
getAxiosXSRFHeader(user.xsrftoken)
)
if (consentPagination) {
setConsents(consentPagination.rows)
checkSelectedNodes()
setTotalRows(consentPagination.totalRows)
console.log(search)
console.log(consentPagination)
}
},
[user, consentService, rowsPerPage, page, checkSelectedNodes]
)
}
}
const handleSearchChange = (newSearch: string) => {
setSearch(newSearch)
setPage(0)
}
const resetSelection = useCallback(() => {
if (gridApi) {
@@ -252,12 +255,12 @@ const Consents: React.FC = () => {
}
}, [gridApi])
/** Trigger search when page loads or when admin changes pagination */
/** Trigger search when page loads or when admin changes input or pagination */
useEffect(() => {
handleSearchChange(search)
searchConsents()
// /!\ Do not change dependencies or effect will not trigger when pagination changes
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [rowsPerPage, page])
}, [rowsPerPage, page, search])
return (
<>
Loading