-
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 branch 'master' of https://github.com/parlemonde/1village into …
…ft/VIL-632
- Loading branch information
Showing
17 changed files
with
272 additions
and
144 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import React from 'react'; | ||
|
||
import VisibilityIcon from '@mui/icons-material/Visibility'; | ||
import { Table, TableBody, TableCell, TableHead, TableRow, Tooltip, IconButton } from '@mui/material'; | ||
|
||
import { DeleteButton } from './buttons/DeleteButton'; | ||
import { bgPage } from 'src/styles/variables.const'; | ||
import type { Video } from 'types/video.type'; | ||
|
||
interface VideoTableProps { | ||
videos: Video[]; | ||
onView: (video: Video) => void; | ||
onDelete: (id: number) => void; | ||
} | ||
|
||
export const VideoTable: React.FC<VideoTableProps> = ({ videos, onView, onDelete }) => { | ||
const cellStyles = { | ||
padding: '5px', | ||
margin: 0, | ||
}; | ||
|
||
return ( | ||
<Table size="medium" style={{ marginTop: '1rem' }}> | ||
<TableHead style={{ borderBottom: '1px solid white' }}> | ||
<TableRow> | ||
<TableCell sx={(theme) => ({ [theme.breakpoints.only('xs')]: cellStyles })} style={{ fontWeight: 'bold' }}> | ||
# | ||
</TableCell> | ||
<TableCell sx={(theme) => ({ [theme.breakpoints.only('xs')]: cellStyles })} style={{ fontWeight: 'bold' }}> | ||
Nom de la vidéo | ||
</TableCell> | ||
<TableCell sx={(theme) => ({ [theme.breakpoints.only('xs')]: cellStyles })} style={{ fontWeight: 'bold' }}> | ||
Lien de la vidéo (URL) | ||
</TableCell> | ||
<TableCell sx={(theme) => ({ [theme.breakpoints.only('xs')]: cellStyles })} style={{ fontWeight: 'bold' }} align="right"> | ||
Actions | ||
</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{videos.map((video, index) => ( | ||
<TableRow | ||
key={video.id} | ||
sx={{ | ||
backgroundColor: 'white', | ||
'&:nth-of-type(even)': { | ||
backgroundColor: bgPage, | ||
}, | ||
'&.sortable-ghost': { | ||
opacity: 0, | ||
}, | ||
}} | ||
> | ||
<TableCell sx={(theme) => ({ [theme.breakpoints.only('xs')]: cellStyles })}>{index + 1}</TableCell> | ||
<TableCell sx={(theme) => ({ [theme.breakpoints.only('xs')]: cellStyles })}>{video.name}</TableCell> | ||
<TableCell sx={(theme) => ({ [theme.breakpoints.only('xs')]: cellStyles })}>https://player.vimeo.com/video/{video.id}</TableCell> | ||
<TableCell sx={(theme) => ({ [theme.breakpoints.only('xs')]: cellStyles })} align="right" padding="none" style={{ minWidth: '96px' }}> | ||
<Tooltip title="Regarder"> | ||
<IconButton | ||
aria-label="Voir" | ||
onClick={() => { | ||
onView(video); | ||
}} | ||
size="small" | ||
style={{ border: '1px solid', marginRight: '0.25rem' }} | ||
> | ||
<VisibilityIcon /> | ||
</IconButton> | ||
</Tooltip> | ||
<Tooltip title="Supprimer"> | ||
<DeleteButton | ||
color="red" | ||
onDelete={() => onDelete(video.id)} | ||
confirmLabel="Voulez vous vraiment supprimer cette vidéo ? Attention, elle ne sera plus accessible par les activités qui l'utilisent." | ||
/> | ||
</Tooltip> | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
); | ||
}; |
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
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
Oops, something went wrong.