diff --git a/src/components/Consents/Consents.tsx b/src/components/Consents/Consents.tsx index e8ca1577ceab22005373a6e5c0241984c7142614..c0d2c6c7eabd7edc67bbaa485543968421072026 100644 --- a/src/components/Consents/Consents.tsx +++ b/src/components/Consents/Consents.tsx @@ -23,8 +23,8 @@ import styles from './consents.module.scss' export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => { const isGRDF = type === 'grdf' - const [gridApi, setGridApi] = useState<GridApi | null>(null) const [isLoading, setIsLoading] = useState(false) + const [gridApi, setGridApi] = useState<GridApi | null>(null) const [search, setSearch] = useState<string>('') const [selectedNodes, setSelectedNodes] = useState<IRowNode[]>([]) const [isShowingSelection, setIsShowingSelection] = useState<boolean>(false) @@ -35,14 +35,15 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => { const [totalRows, setTotalRows] = useState<number>(50) const { data: user } = useWhoAmI() - const consentService = useMemo(() => { - return isGRDF ? new GrdfConsentService() : new SgeConsentService() - }, [isGRDF]) - const toggleOpenModal = useCallback(() => { setOpenDownloadModal(prev => !prev) }, []) + const consentService = useMemo( + () => (isGRDF ? new GrdfConsentService() : new SgeConsentService()), + [isGRDF] + ) + const defaultColDef = useMemo( () => ({ sortable: true, diff --git a/src/models/grdfConsent.ts b/src/models/grdfConsent.ts index 63e8e7fc5db18156beb5103a9b815247278909e3..6d2a7166c6ae09342e13a2aa0cec485ad85430c8 100644 --- a/src/models/grdfConsent.ts +++ b/src/models/grdfConsent.ts @@ -1,6 +1,7 @@ import { ColDef } from 'ag-grid-community' import { DateTime } from 'luxon' import { dateFormatter } from '../utils/dateFormatter' + export interface IGrdfConsent extends Omit<GrdfConsentEntity, 'CreatedAt' | 'endDate'> { startDate: DateTime diff --git a/src/services/sgeConsent.service.ts b/src/services/sgeConsent.service.ts index 986e0fab8fad60acaa8bb7b872e1eb5cf3bac996..ad71837d63e862d752dff43c1075c5988545d74e 100644 --- a/src/services/sgeConsent.service.ts +++ b/src/services/sgeConsent.service.ts @@ -23,12 +23,11 @@ export class SgeConsentService { axiosHeaders: AxiosRequestConfig ): Promise<ISgeConsentPagination | null> => { try { - const { data } = await axios.get( + const { data } = await axios.get<SgeConsentPaginationEntity>( `/api/admin/sge/consent?search=${search}&limit=${limit}&page=${page}`, axiosHeaders ) - const consentPagination = data as SgeConsentPaginationEntity - return this.parseConsentPagination(consentPagination) + return this.parseConsentPagination(data) } catch (e) { if (e.response.status === 403) { toast.error("Accès refusé : vous n'avez pas les droits nécessaires")