-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(VIL-622): adding access rights to archives to admin, s-admin and…
… mediator fix: lint lint fix: staging build failed adding mediator account to test on staging restoring initial state after testing fixing ts errors revert changes to signatures
- Loading branch information
1 parent
e274921
commit 4f76344
Showing
3 changed files
with
31 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
import axios from 'axios'; | ||
import React from 'react'; | ||
import { useQuery } from 'react-query'; | ||
|
||
import { UserType } from '../../../types/user.type'; | ||
import { UserContext } from '../../contexts/userContext'; | ||
|
||
const BASE_URL = '/api/archives'; | ||
|
||
// Récupérer la liste des années déjà archivées | ||
export const useListArchives = () => { | ||
return useQuery(['archives'], async () => { | ||
const { data } = await axios.get(`${BASE_URL}`); | ||
return data; | ||
}); | ||
const { user } = React.useContext(UserContext); | ||
|
||
const hasAccess = user?.type === UserType.SUPER_ADMIN || user?.type === UserType.ADMIN || user?.type === UserType.MEDIATOR; | ||
|
||
return useQuery( | ||
['archives'], | ||
async () => { | ||
const { data } = await axios.get(`${BASE_URL}`); | ||
return data; | ||
}, | ||
{ | ||
enabled: hasAccess, | ||
}, | ||
); | ||
}; |