diff --git a/src/components/Header.tsx b/src/components/Header.tsx index b19da43f9..ee97a52e1 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -116,7 +116,6 @@ export const Header = () => { {hasAccessToNewAdmin && goToPage('/admin/newportal/create')}>Portail admin} {hasAccessToOldAdmin && goToPage('/admin/villages')}>Admin (old)} goToPage('/mon-compte')}>Mon compte - {user.type !== UserType.FAMILY && goToPage('/mes-videos')}>Mes vidéos} {user.type === UserType.TEACHER ? goToPage('/familles/1')}>Mes familles : null}{' '} diff --git a/src/components/VideoTable.tsx b/src/components/VideoTable.tsx new file mode 100644 index 000000000..b3457ba14 --- /dev/null +++ b/src/components/VideoTable.tsx @@ -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 = ({ videos, onView, onDelete }) => { + const cellStyles = { + padding: '5px', + margin: 0, + }; + + return ( + + + + ({ [theme.breakpoints.only('xs')]: cellStyles })} style={{ fontWeight: 'bold' }}> + # + + ({ [theme.breakpoints.only('xs')]: cellStyles })} style={{ fontWeight: 'bold' }}> + Nom de la vidéo + + ({ [theme.breakpoints.only('xs')]: cellStyles })} style={{ fontWeight: 'bold' }}> + Lien de la vidéo (URL) + + ({ [theme.breakpoints.only('xs')]: cellStyles })} style={{ fontWeight: 'bold' }} align="right"> + Actions + + + + + {videos.map((video, index) => ( + + ({ [theme.breakpoints.only('xs')]: cellStyles })}>{index + 1} + ({ [theme.breakpoints.only('xs')]: cellStyles })}>{video.name} + ({ [theme.breakpoints.only('xs')]: cellStyles })}>https://player.vimeo.com/video/{video.id} + ({ [theme.breakpoints.only('xs')]: cellStyles })} align="right" padding="none" style={{ minWidth: '96px' }}> + + { + onView(video); + }} + size="small" + style={{ border: '1px solid', marginRight: '0.25rem' }} + > + + + + + onDelete(video.id)} + confirmLabel="Voulez vous vraiment supprimer cette vidéo ? Attention, elle ne sera plus accessible par les activités qui l'utilisent." + /> + + + + ))} + +
+ ); +}; diff --git a/src/pages/ma-classe.tsx b/src/pages/ma-classe.tsx index ee235f900..950196393 100644 --- a/src/pages/ma-classe.tsx +++ b/src/pages/ma-classe.tsx @@ -1,3 +1,4 @@ +import { useSnackbar } from 'notistack'; import React from 'react'; import { useQueryClient } from 'react-query'; @@ -5,21 +6,28 @@ import { isMascotte } from 'src/activity-types/anyActivity'; import { Base } from 'src/components/Base'; import { Modal } from 'src/components/Modal'; import { PageLayout } from 'src/components/PageLayout'; +import { VideoTable } from 'src/components/VideoTable'; import { ActivityCard } from 'src/components/activities/ActivityCard'; import { GameCardMaClasse } from 'src/components/activities/ActivityCard/GameCardMaClasse'; import { MascotteTemplate } from 'src/components/activities/content/MascotteTemplate'; +import { VideoView } from 'src/components/activities/content/views/VideoView'; import { ActivityContext } from 'src/contexts/activityContext'; import { UserContext } from 'src/contexts/userContext'; import { useActivities } from 'src/services/useActivities'; import { useActivityRequests } from 'src/services/useActivity'; +import { useVideos } from 'src/services/useVideos'; import { axiosRequest } from 'src/utils/axiosRequest'; import type { Activity } from 'types/activity.type'; import { ActivityStatus } from 'types/activity.type'; +import type { Video } from 'types/video.type'; const MaClasse = () => { const queryClient = useQueryClient(); + const { enqueueSnackbar } = useSnackbar(); const { user, setUser } = React.useContext(UserContext); const { setActivity } = React.useContext(ActivityContext); + const [selectedVideo, setSelectedVideo] = React.useState