mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Compare commits
3 commits
473bb0c869
...
3347c4bba1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3347c4bba1 | ||
|
|
51cebdaba1 | ||
|
|
57c5321c09 |
1 changed files with 223 additions and 122 deletions
|
|
@ -38,7 +38,7 @@ import {
|
|||
Upload,
|
||||
FolderCopy,
|
||||
ContentCopy,
|
||||
Edit,
|
||||
Edit
|
||||
} from '@mui/icons-material';
|
||||
import ShareQuizModal from 'src/components/ShareQuizModal/ShareQuizModal';
|
||||
|
||||
|
|
@ -65,6 +65,7 @@ const Dashboard: React.FC = () => {
|
|||
const [selectedRoom, selectRoom] = useState<RoomType>(); // menu
|
||||
const [errorMessage, setErrorMessage] = useState('');
|
||||
const [showErrorDialog, setShowErrorDialog] = useState(false);
|
||||
const [isSearchVisible, setIsSearchVisible] = useState(false);
|
||||
|
||||
// Filter quizzes based on search term
|
||||
// const filteredQuizzes = quizzes.filter(quiz =>
|
||||
|
|
@ -120,6 +121,10 @@ const Dashboard: React.FC = () => {
|
|||
}
|
||||
};
|
||||
|
||||
const toggleSearchVisibility = () => {
|
||||
setIsSearchVisible(!isSearchVisible);
|
||||
};
|
||||
|
||||
// Créer une salle
|
||||
const createRoom = async (title: string) => {
|
||||
// Créer la salle et récupérer l'objet complet
|
||||
|
|
@ -133,10 +138,9 @@ const Dashboard: React.FC = () => {
|
|||
selectRoomByName(newRoom); // Utiliser l'ID de l'objet retourné
|
||||
};
|
||||
|
||||
|
||||
// Sélectionner une salle
|
||||
const selectRoomByName = (roomId: string) => {
|
||||
const room = rooms.find(r => r._id === roomId);
|
||||
const room = rooms.find((r) => r._id === roomId);
|
||||
selectRoom(room);
|
||||
localStorage.setItem('selectedRoomId', roomId);
|
||||
};
|
||||
|
|
@ -150,7 +154,7 @@ const Dashboard: React.FC = () => {
|
|||
setOpenAddRoomDialog(false);
|
||||
setNewRoomTitle('');
|
||||
} catch (error) {
|
||||
setErrorMessage(error instanceof Error ? error.message : "Erreur inconnue");
|
||||
setErrorMessage(error instanceof Error ? error.message : 'Erreur inconnue');
|
||||
setShowErrorDialog(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -402,30 +406,63 @@ const Dashboard: React.FC = () => {
|
|||
|
||||
return (
|
||||
<div className="dashboard">
|
||||
<div className="title">Tableau de bord</div>
|
||||
{/* Conteneur pour le titre et le sélecteur de salle */}
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
marginBottom: '20px'
|
||||
}}
|
||||
>
|
||||
{/* Titre tableau de bord */}
|
||||
<div className="title" style={{ fontSize: '30px', fontWeight: 'bold' }}>
|
||||
Tableau de bord
|
||||
</div>
|
||||
|
||||
<div className="roomSelection">
|
||||
<label htmlFor="select-room">Sélectionner une salle: </label>
|
||||
<select value={selectedRoom?._id || ''} onChange={(e) => handleSelectRoom(e)}>
|
||||
{/* Sélecteur de salle */}
|
||||
<div
|
||||
className="roomSelection"
|
||||
style={{ display: 'flex', justifyContent: 'flex-end', gap: '15px' }}
|
||||
>
|
||||
<select
|
||||
value={selectedRoom?._id || ''}
|
||||
onChange={(e) => handleSelectRoom(e)}
|
||||
id="room-select"
|
||||
style={{
|
||||
padding: '8px 12px',
|
||||
fontSize: '14px',
|
||||
borderRadius: '8px',
|
||||
border: '1px solid #ccc',
|
||||
backgroundColor: '#fff',
|
||||
maxWidth: '200px',
|
||||
cursor: 'pointer',
|
||||
fontWeight: '500'
|
||||
}}
|
||||
>
|
||||
<option value="" disabled>
|
||||
-- Sélectionner une salle --
|
||||
Sélectionner une salle
|
||||
</option>
|
||||
{rooms.map((room) => (
|
||||
<option key={room._id} value={room._id}>
|
||||
{room.title}
|
||||
</option>
|
||||
))}
|
||||
<option value="add-room">Ajouter salle</option>
|
||||
<option
|
||||
value="add-room"
|
||||
style={{
|
||||
color: 'black',
|
||||
backgroundColor: '#f0f0f0',
|
||||
fontWeight: 'bold'
|
||||
}}
|
||||
>
|
||||
Ajouter une salle
|
||||
</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{selectedRoom && (
|
||||
<div className="roomTitle">
|
||||
<h2>Salle sélectionnée: {selectedRoom.title}</h2>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Dialog pour créer une salle */}
|
||||
<Dialog open={openAddRoomDialog} onClose={() => setOpenAddRoomDialog(false)}>
|
||||
<DialogTitle>Créer une nouvelle salle</DialogTitle>
|
||||
<DialogContent>
|
||||
|
|
@ -450,24 +487,17 @@ const Dashboard: React.FC = () => {
|
|||
</DialogActions>
|
||||
</Dialog>
|
||||
|
||||
<div className="search-bar">
|
||||
<TextField
|
||||
onChange={handleSearch}
|
||||
value={searchTerm}
|
||||
placeholder="Rechercher un quiz par son titre"
|
||||
fullWidth
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
<IconButton>
|
||||
<Search />
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
)
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'flex-end',
|
||||
alignItems: 'center',
|
||||
width: '100%',
|
||||
gap: '20px'
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
></div>
|
||||
|
||||
{/* Conteneur principal avec les actions et la liste des quiz */}
|
||||
<div className="folder">
|
||||
<div className="select">
|
||||
<NativeSelect
|
||||
|
|
@ -475,13 +505,18 @@ const Dashboard: React.FC = () => {
|
|||
color="primary"
|
||||
value={selectedFolderId}
|
||||
onChange={handleSelectFolder}
|
||||
sx={{
|
||||
padding: '6px 12px',
|
||||
maxWidth: '180px',
|
||||
borderRadius: '8px',
|
||||
borderColor: '#e0e0e0',
|
||||
'&:hover': { borderColor: '#5271FF' }
|
||||
}}
|
||||
>
|
||||
<option value="">Tous les dossiers...</option>
|
||||
|
||||
{folders.map((folder: FolderType) => (
|
||||
{folders.map((folder) => (
|
||||
<option value={folder._id} key={folder._id}>
|
||||
{' '}
|
||||
{folder.title}{' '}
|
||||
{folder.title}
|
||||
</option>
|
||||
))}
|
||||
</NativeSelect>
|
||||
|
|
@ -537,14 +572,77 @@ const Dashboard: React.FC = () => {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div className="ajouter">
|
||||
<div
|
||||
className="search-bar"
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
gap: '20px',
|
||||
width: '100%'
|
||||
}}
|
||||
>
|
||||
<div style={{ flex: 1 }}>
|
||||
{!isSearchVisible ? (
|
||||
<IconButton
|
||||
onClick={toggleSearchVisibility}
|
||||
sx={{
|
||||
borderRadius: '8px',
|
||||
border: '1px solid #ccc',
|
||||
padding: '8px 12px',
|
||||
backgroundColor: '#fff',
|
||||
color: '#5271FF'
|
||||
}}
|
||||
>
|
||||
<Search />
|
||||
</IconButton>
|
||||
) : (
|
||||
<TextField
|
||||
onChange={handleSearch}
|
||||
value={searchTerm}
|
||||
placeholder="Rechercher un quiz"
|
||||
fullWidth
|
||||
autoFocus
|
||||
sx={{
|
||||
borderRadius: '8px',
|
||||
border: '1px solid #ccc',
|
||||
padding: '8px 12px',
|
||||
backgroundColor: '#fff',
|
||||
fontWeight: 500,
|
||||
width: '100%',
|
||||
maxWidth: '1000px'
|
||||
}}
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
<IconButton
|
||||
onClick={toggleSearchVisibility}
|
||||
sx={{
|
||||
borderRadius: '8px',
|
||||
border: '1px solid #ccc',
|
||||
backgroundColor: '#fff',
|
||||
color: '#5271FF'
|
||||
}}
|
||||
>
|
||||
<Search />
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* À droite : les boutons */}
|
||||
<div style={{ display: 'flex', gap: '12px' }}>
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
startIcon={<Add />}
|
||||
onClick={handleCreateQuiz}
|
||||
sx={{ borderRadius: '8px', minWidth: 'auto', padding: '4px 12px' }}
|
||||
>
|
||||
Ajouter un nouveau quiz
|
||||
Nouveau quiz
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
|
|
@ -553,9 +651,11 @@ const Dashboard: React.FC = () => {
|
|||
startIcon={<Upload />}
|
||||
onClick={handleOnImport}
|
||||
>
|
||||
Import
|
||||
Importer
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="list">
|
||||
{Object.keys(quizzesByFolder).map((folderName) => (
|
||||
<CustomCard key={folderName} className="folder-card">
|
||||
|
|
@ -571,7 +671,9 @@ const Dashboard: React.FC = () => {
|
|||
onClick={() => handleLancerQuiz(quiz)}
|
||||
disabled={!validateQuiz(quiz.content)}
|
||||
>
|
||||
{`${quiz.title} (${quiz.content.length} question${
|
||||
{`${quiz.title} (${
|
||||
quiz.content.length
|
||||
} question${
|
||||
quiz.content.length > 1 ? 's' : ''
|
||||
})`}
|
||||
</Button>
|
||||
|
|
@ -609,21 +711,20 @@ const Dashboard: React.FC = () => {
|
|||
<ContentCopy />{' '}
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<div className="quiz-share">
|
||||
<ShareQuizModal quiz={quiz} />
|
||||
</div>
|
||||
|
||||
<Tooltip title="Supprimer" placement="top">
|
||||
<IconButton
|
||||
aria-label="delete"
|
||||
color="primary"
|
||||
color="error"
|
||||
onClick={() => handleRemoveQuiz(quiz)}
|
||||
>
|
||||
{' '}
|
||||
<DeleteOutline />{' '}
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
|
||||
<div className="quiz-share">
|
||||
<ShareQuizModal quiz={quiz} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
|
|
|||
Loading…
Reference in a new issue