From 1d550e58e738da93dfd414da4cc49738e75976c1 Mon Sep 17 00:00:00 2001
From: Bastien Dumont <bdumont@grandlyon.com>
Date: Mon, 15 Jan 2024 15:38:19 +0100
Subject: [PATCH] cleanup

---
 src/components/Consents/Consents.tsx | 11 ++++++-----
 src/models/grdfConsent.ts            |  1 +
 src/services/sgeConsent.service.ts   |  5 ++---
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/components/Consents/Consents.tsx b/src/components/Consents/Consents.tsx
index e8ca1577..c0d2c6c7 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 63e8e7fc..6d2a7166 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 986e0fab..ad71837d 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")
-- 
GitLab