Update Dashboard.jsx
quelque changement sans tout pété
This commit is contained in:
parent
bea871581c
commit
e63603ae39
@ -4,7 +4,6 @@ import { RadioTower, ArrowRight, BadgePlus, Settings } from "lucide-react";
|
||||
import { API_BASE_URL } from "../../config.js";
|
||||
import axios from "axios";
|
||||
|
||||
// Widgets initiaux pour le dashboard
|
||||
const initialWidgets = [
|
||||
{ id: 1, type: "summary" },
|
||||
{ id: 2, type: "users" },
|
||||
@ -12,7 +11,6 @@ const initialWidgets = [
|
||||
];
|
||||
|
||||
function Dashboard() {
|
||||
// États simulés (données fictives pour l'exemple)
|
||||
const [users, setUsers] = useState([])
|
||||
|
||||
const [logs, setLogs] = useState([
|
||||
@ -34,7 +32,7 @@ function Dashboard() {
|
||||
setUsers(response.data);
|
||||
});
|
||||
}, []);
|
||||
// État pour simuler les objets présents dans la section AdminObjet.jsx
|
||||
|
||||
const [adminObjects, setAdminObjects] = useState([
|
||||
{
|
||||
id: 101,
|
||||
@ -65,24 +63,19 @@ function Dashboard() {
|
||||
},
|
||||
]);
|
||||
|
||||
// Gestion du mode de gestion et des widgets
|
||||
const [manageMode, setManageMode] = useState(false);
|
||||
const [widgets, setWidgets] = useState(initialWidgets);
|
||||
|
||||
// Contrôle d'affichage du modal de sélection de widget
|
||||
const [showAddWidgetModal, setShowAddWidgetModal] = useState(false);
|
||||
|
||||
// Suppression d'un widget
|
||||
const handleDeleteWidget = (id) => {
|
||||
setWidgets(widgets.filter((widget) => widget.id !== id));
|
||||
};
|
||||
|
||||
// Ouvre le modal pour ajouter un widget
|
||||
const openAddWidgetModal = () => {
|
||||
setShowAddWidgetModal(true);
|
||||
};
|
||||
|
||||
// Ajoute le widget sélectionné en fonction du type choisi
|
||||
|
||||
const handleWidgetSelection = (widgetType) => {
|
||||
const newWidget = { id: Date.now(), type: widgetType };
|
||||
setWidgets([...widgets, newWidget]);
|
||||
@ -93,7 +86,6 @@ function Dashboard() {
|
||||
<div className="flex min-h-screen">
|
||||
<Sidebar />
|
||||
<main className="flex-1 bg-gradient-to-br from-blue-50 to-indigo-50 p-8 overflow-auto">
|
||||
{/* En-tête : titre + bouton pour activer/désactiver le mode gestion */}
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<h1 className="text-3xl font-bold">Dashboard</h1>
|
||||
<button
|
||||
@ -105,7 +97,6 @@ function Dashboard() {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Grille des widgets */}
|
||||
<section>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{widgets.map((widget) => (
|
||||
@ -113,7 +104,6 @@ function Dashboard() {
|
||||
key={widget.id}
|
||||
className="relative bg-white p-6 rounded-xl shadow hover:shadow-md"
|
||||
>
|
||||
{/* Bouton de suppression, visible en mode gestion */}
|
||||
{manageMode && (
|
||||
<button
|
||||
onClick={() => handleDeleteWidget(widget.id)}
|
||||
@ -123,7 +113,6 @@ function Dashboard() {
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* Contenu du widget selon son type */}
|
||||
{widget.type === "summary" && (
|
||||
<div>
|
||||
<h2 className="text-xl font-semibold mb-4">
|
||||
@ -236,7 +225,6 @@ function Dashboard() {
|
||||
<h2 className="text-xl font-semibold mb-4">
|
||||
Liste des Objets et Outils/Services
|
||||
</h2>
|
||||
{/* Afficher seulement les 2 premiers objets */}
|
||||
<ul className="mb-4 space-y-2">
|
||||
{adminObjects.slice(0, 2).map((obj) => (
|
||||
<li
|
||||
@ -260,7 +248,6 @@ function Dashboard() {
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* Case pour ajouter un widget */}
|
||||
<div
|
||||
onClick={openAddWidgetModal}
|
||||
className="flex items-center justify-center border-2 border-dashed border-gray-300 rounded-xl p-6 hover:bg-gray-50 cursor-pointer"
|
||||
@ -273,7 +260,6 @@ function Dashboard() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Modal de sélection du type de widget */}
|
||||
{showAddWidgetModal && (
|
||||
<div className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50">
|
||||
<div className="bg-white rounded-lg p-6 w-80">
|
||||
@ -320,4 +306,4 @@ function Dashboard() {
|
||||
);
|
||||
}
|
||||
|
||||
export default Dashboard;
|
||||
export default Dashboard;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user