diff --git a/client/src/pages/Admin/Images.tsx b/client/src/pages/Admin/Images.tsx index a03f70d..be97c5c 100644 --- a/client/src/pages/Admin/Images.tsx +++ b/client/src/pages/Admin/Images.tsx @@ -1,112 +1,18 @@ -import React, { useState, useEffect } from "react"; -import { - Table, - TableBody, - TableCell, - TableContainer, - TableRow, - TableHead, - IconButton, - Paper, - Box, - CircularProgress, - Button -} from "@mui/material"; -import DeleteIcon from "@mui/icons-material/Delete"; -import { ImageType } from "../../Types/ImageType"; -import ApiService from '../../services/ApiService'; +import React from "react"; +import ImageGallery from "../../components/ImageGallery/ImageGallery"; const Images: React.FC = () => { - const [images, setImages] = useState([]); - const [totalImg, setTotalImg] = useState(0); - const [imgPage, setImgPage] = useState(1); - const [imgLimit] = useState(10); - const [loading, setLoading] = useState(false); - const fetchImages = async (page: number, limit: number) => { - setLoading(true); - const data = await ApiService.getImages(page, limit); - setImages(data.images); - setTotalImg(data.total); - setLoading(false); - }; - - useEffect(() => { - fetchImages(imgPage, imgLimit); - }, [imgPage]); - - - const handleDelete = async (id: string) => { - setLoading(true); - const isDeleted = await ApiService.deleteImage(id); - setLoading(false); - if (isDeleted) { - setImages(images.filter(image => image.id !== id)); - } - }; - - const handleNextPage = () => { - if ((imgPage * imgLimit) < totalImg) { - setImgPage(prev => prev + 1); - } - }; - - const handlePrevPage = () => { - if (imgPage > 1) { - setImgPage(prev => prev - 1); + const handleCopy = (id: string) => { + if (navigator.clipboard) { + navigator.clipboard.writeText(id); } }; return ( - - {loading ? ( - - - - ) : ( - - - - - - Nom - Image ID - - - - {images.map((obj: ImageType) => ( - - - {`Image - - {obj.file_name} - - {obj.id} - - - handleDelete(obj.id)} color="error"> - - - - - ))} - -
-
- )} - - - - -
+ ); }; diff --git a/client/src/pages/Admin/Stats.tsx b/client/src/pages/Admin/Stats.tsx index 2288572..f1ab115 100644 --- a/client/src/pages/Admin/Stats.tsx +++ b/client/src/pages/Admin/Stats.tsx @@ -1,10 +1,15 @@ import React, { useState, useEffect } from "react"; -import { Paper, Grid, Typography, CircularProgress, Box } from "@mui/material"; +import { Paper, Grid, Typography, CircularProgress, Box, Card, CardContent} from "@mui/material"; import ApiService from '../../services/ApiService'; import { AdminTableType } from "../../Types/AdminTableType"; import AdminTable from "../../components/AdminTable/AdminTable"; +const styles = { + cardBg: 'rgba(82, 113, 255, 1)', + cardHover: 'rgba(65, 105, 225, 0.7)', +}; + const Users: React.FC = () => { const [quizzes, setQuizzes] = useState([]); const [monthlyQuizzes, setMonthlyQuizzes] = useState(0); @@ -49,6 +54,13 @@ const Users: React.FC = () => { ); } + const stats = [ + { label: "Quiz du Mois", value: monthlyQuizzes }, + { label: "Quiz total", value: totalQuizzes }, + { label: "Enseignants", value: totalUsers }, + { label: "Enseignants du Mois", value: totalUsers }, + ]; + const labelMap = { _id: "ID", email: "Enseignant", @@ -58,36 +70,30 @@ const Users: React.FC = () => { }; return ( - - - - Quiz du Mois - - - - {monthlyQuizzes} - - + + + {stats.map((stat, index) => ( + + + + {stat.label} + + {stat.value} + + + - - Quiz total - - - - {totalQuizzes} - - - - - Enseignants - - - - {totalUsers} - - - - + ))} + +