Skip to content
Snippets Groups Projects
Commit 0cba63c6 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

add loading state

parent 752e8ad4
No related branches found
No related tags found
1 merge request!137feat(grdf): display grdf consents
Pipeline #90146 passed
...@@ -15,6 +15,7 @@ import { IGrdfConsent, grdfColumnDef } from '../../models/grdfConsent' ...@@ -15,6 +15,7 @@ import { IGrdfConsent, grdfColumnDef } from '../../models/grdfConsent'
import { ISgeConsent, sgeColumnDefs } from '../../models/sgeConsent.model' import { ISgeConsent, sgeColumnDefs } from '../../models/sgeConsent.model'
import { GrdfConsentService } from '../../services/grdfConsent.service' import { GrdfConsentService } from '../../services/grdfConsent.service'
import { SgeConsentService } from '../../services/sgeConsent.service' import { SgeConsentService } from '../../services/sgeConsent.service'
import Loader from '../Loader/Loader'
import DownloadModal from './DownloadModal' import DownloadModal from './DownloadModal'
import './agGridOverrides.scss' import './agGridOverrides.scss'
import styles from './consents.module.scss' import styles from './consents.module.scss'
...@@ -23,6 +24,7 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => { ...@@ -23,6 +24,7 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => {
const isGRDF = type === 'grdf' const isGRDF = type === 'grdf'
const [gridApi, setGridApi] = useState<GridApi | null>(null) const [gridApi, setGridApi] = useState<GridApi | null>(null)
const [isLoading, setIsLoading] = useState(false)
const [search, setSearch] = useState<string>('') const [search, setSearch] = useState<string>('')
const [selectedNodes, setSelectedNodes] = useState<IRowNode[]>([]) const [selectedNodes, setSelectedNodes] = useState<IRowNode[]>([])
const [isShowingSelection, setIsShowingSelection] = useState<boolean>(false) const [isShowingSelection, setIsShowingSelection] = useState<boolean>(false)
...@@ -75,13 +77,14 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => { ...@@ -75,13 +77,14 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => {
.filter(node => node.isSelected) .filter(node => node.isSelected)
.map(node => node.data.ID) .map(node => node.data.ID)
newNodes.forEach(node => { newNodes?.forEach(node => {
if (idsToCheck.includes(node.data.ID)) node.setSelected(true, false) if (idsToCheck.includes(node.data.ID)) node.setSelected(true, false)
}) })
} }
}, [gridApi, selectedNodes]) }, [gridApi, selectedNodes])
const searchConsents = async () => { const searchConsents = async () => {
setIsLoading(true)
if (user) { if (user) {
const consentPagination = await consentService.searchConsents( const consentPagination = await consentService.searchConsents(
search, search,
...@@ -95,6 +98,7 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => { ...@@ -95,6 +98,7 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => {
setTotalRows(consentPagination.totalRows) setTotalRows(consentPagination.totalRows)
} }
} }
setIsLoading(false)
} }
const handleSearchChange = (newSearch: string) => { const handleSearchChange = (newSearch: string) => {
...@@ -208,24 +212,27 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => { ...@@ -208,24 +212,27 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => {
className="ag-theme-alpine-dark" className="ag-theme-alpine-dark"
style={{ width: '100%', height: '75vh' }} style={{ width: '100%', height: '75vh' }}
> >
<AgGridReact {isLoading && <Loader />}
onGridReady={onGridReady} {!isLoading && (
defaultColDef={defaultColDef} <AgGridReact
rowHeight={35} onGridReady={onGridReady}
rowData={consents} defaultColDef={defaultColDef}
columnDefs={columnDefs} rowHeight={35}
animateRows={true} rowData={consents}
rowSelection="multiple" columnDefs={columnDefs}
allowDragFromColumnsToolPanel={false} animateRows={true}
onRowSelected={onRowSelected} rowSelection="multiple"
sortingOrder={['asc', 'desc']} allowDragFromColumnsToolPanel={false}
rowMultiSelectWithClick={true} onRowSelected={onRowSelected}
pagination={false} sortingOrder={['asc', 'desc']}
suppressCellFocus={true} rowMultiSelectWithClick={true}
rowClassRules={{ pagination={false}
expired: params => params.data.endDate < DateTime.now(), suppressCellFocus={true}
}} rowClassRules={{
/> expired: params => params.data.endDate < DateTime.now(),
}}
/>
)}
{!isShowingSelection && ( {!isShowingSelection && (
<TablePagination <TablePagination
labelRowsPerPage="Consentements par page" labelRowsPerPage="Consentements par page"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment