From 5881e522458d02ae6e2b4994fe41636d7ea1fea0 Mon Sep 17 00:00:00 2001 From: lukas Date: Fri, 8 Nov 2024 15:57:37 +0100 Subject: [PATCH] lint --- src/api/archive/archive.get.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/api/archive/archive.get.ts b/src/api/archive/archive.get.ts index 31c609a82..7d39221fa 100644 --- a/src/api/archive/archive.get.ts +++ b/src/api/archive/archive.get.ts @@ -11,16 +11,11 @@ const BASE_URL = '/api/archives'; export const useListArchives = () => { const { user } = React.useContext(UserContext); - const hasAccess = user && [UserType.SUPER_ADMIN, UserType.ADMIN, UserType.MEDIATOR].includes(user.type); + const hasAccess = user?.type === [UserType.SUPER_ADMIN, UserType.ADMIN, UserType.MEDIATOR].find((type) => type === user?.type); + if (!hasAccess) return; - return useQuery( - ['archives'], - async () => { - const { data } = await axios.get(`${BASE_URL}`); - return data; - }, - { - enabled: hasAccess, // La requête ne sera exécutée que si hasAccess est true - }, - ); + return useQuery(['archives'], async () => { + const { data } = await axios.get(`${BASE_URL}`); + return data; + }); };