-
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.
Merge pull request #1003 from parlemonde/feat/VIL-622
feat(VIL-622): adding access rights to archives to admin, s-admin and…
- Loading branch information
Showing
7 changed files
with
37 additions
and
20 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 !== null && user.type in [UserType.ADMIN, UserType.SUPER_ADMIN, UserType.MEDIATOR]; | ||
|
||
return useQuery( | ||
['archives'], | ||
async () => { | ||
const { data } = await axios.get(`${BASE_URL}`); | ||
return data; | ||
}, | ||
{ | ||
enabled: hasAccess, | ||
}, | ||
); | ||
}; |
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
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