Skip to content
Snippets Groups Projects
Commit 4b1019f5 authored by Pierre Ecarlat's avatar Pierre Ecarlat
Browse files

feat: Add exportAll button

parent 865d17b0
No related branches found
No related tags found
2 merge requests!178feat: Allow to download all consents,!177feat: Add exportAll button
...@@ -166,6 +166,26 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => { ...@@ -166,6 +166,26 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => {
resetSelection() resetSelection()
}, [gridApi, resetSelection]) }, [gridApi, resetSelection])
const exportAllData = useCallback(() => {
const fetchAllData = async () => {
setIsLoading(true)
if (user) {
const allConsents = await consentService.searchConsents(
'',
totalRows,
0,
getAxiosXSRFHeader(user.xsrftoken)
)
if (allConsents) {
setConsents(allConsents.rows)
toggleOpenModal()
}
}
setIsLoading(false)
}
fetchAllData()
}, [user, totalRows, consentService, toggleOpenModal])
const onGridReady = ({ api }: GridReadyEvent) => { const onGridReady = ({ api }: GridReadyEvent) => {
//Grid init method //Grid init method
setGridApi(api) setGridApi(api)
...@@ -196,16 +216,19 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => { ...@@ -196,16 +216,19 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => {
<h1>Consentements {isGRDF ? 'GRDF' : 'Enedis'}</h1> <h1>Consentements {isGRDF ? 'GRDF' : 'Enedis'}</h1>
</div> </div>
<div className={styles.content}> <div className={styles.content}>
<TextField <div className={styles.inlineButtons}>
placeholder={`N°${isGRDF ? 'PCE' : 'PDL'} (14 chiffres)`} <TextField
label="Recherche" placeholder={`N°${isGRDF ? 'PCE' : 'PDL'} (14 chiffres)`}
value={search} label="Recherche"
onChange={(e: React.ChangeEvent<HTMLInputElement>) => value={search}
handleSearchChange(e.target.value) onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
} handleSearchChange(e.target.value)
disabled={isShowingSelection} }
autoComplete="off" disabled={isShowingSelection}
/> autoComplete="off"
/>
<Button onClick={exportAllData}>Tout télécharger</Button>
</div>
<div <div
className="ag-theme-alpine-dark" className="ag-theme-alpine-dark"
style={{ width: '100%', height: '75vh' }} style={{ width: '100%', height: '75vh' }}
......
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
padding: 1rem; padding: 1rem;
} }
.inlineButtons {
display: flex;
justify-content: space-between;
align-items: center;
}
.footerButtons { .footerButtons {
padding: 1rem 0; padding: 1rem 0;
display: flex; display: flex;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment