From 4279bc94ccab77954bc500fd34d9b365927ccb15 Mon Sep 17 00:00:00 2001 From: ousamazemzami Date: Fri, 8 Nov 2024 09:18:52 +0100 Subject: [PATCH 1/3] vidoes ar being displayed in ma class page --- src/components/VideoTable.tsx | 83 +++++++++++++++++++++++++++++++++ src/pages/ma-classe.tsx | 56 +++++++++++++++++++++- src/pages/mes-videos.tsx | 88 ++++------------------------------- 3 files changed, 146 insertions(+), 81 deletions(-) create mode 100644 src/components/VideoTable.tsx 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..139030694 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