diff --git a/attached_assets/{77C1298A-A150-4224-9108-40DBA8E3A2D3}_1755600117450.png b/attached_assets/{77C1298A-A150-4224-9108-40DBA8E3A2D3}_1755600117450.png new file mode 100644 index 0000000..957f5bd Binary files /dev/null and b/attached_assets/{77C1298A-A150-4224-9108-40DBA8E3A2D3}_1755600117450.png differ diff --git a/client/src/components/RouterProduction.tsx b/client/src/components/RouterProduction.tsx index d4f27a9..e5276d6 100644 --- a/client/src/components/RouterProduction.tsx +++ b/client/src/components/RouterProduction.tsx @@ -19,8 +19,7 @@ import CustomerOrders from "@/pages/CustomerOrders"; import DlcPage from "@/pages/DlcPage"; import BackupManager from "@/pages/BackupManager"; import Utilities from "@/pages/Utilities"; -import Tasks from "@/pages/Tasks"; -import TasksSimplified from "@/pages/TasksSimplified"; +import TasksProductionSimple from "@/pages/TasksProductionSimple"; import SavTickets from "@/pages/SavTickets"; import WeatherSettings from "@/pages/WeatherSettings"; import Layout from "@/components/Layout"; @@ -95,7 +94,7 @@ function RouterProduction() { - + {/* Routes de compatibilité - redirection vers utilities */} diff --git a/client/src/pages/TasksProductionSimple.tsx b/client/src/pages/TasksProductionSimple.tsx new file mode 100644 index 0000000..7c3c9c4 --- /dev/null +++ b/client/src/pages/TasksProductionSimple.tsx @@ -0,0 +1,546 @@ +import { useState, useEffect } from "react"; + +// Version 100% autonome sans aucune dépendance externe +export default function TasksProductionSimple() { + const [tasks, setTasks] = useState([]); + const [loading, setLoading] = useState(true); + const [showCreateModal, setShowCreateModal] = useState(false); + const [showEditModal, setShowEditModal] = useState(false); + const [selectedTask, setSelectedTask] = useState(null); + const [searchTerm, setSearchTerm] = useState(""); + const [statusFilter, setStatusFilter] = useState("all"); + + // Charger les tâches + const loadTasks = async () => { + try { + const response = await fetch('/api/tasks'); + if (response.ok) { + const data = await response.json(); + setTasks(data); + } + } catch (error) { + console.error('Erreur lors du chargement des tâches:', error); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + loadTasks(); + }, []); + + // Filtrer les tâches + const filteredTasks = tasks.filter(task => { + const matchesSearch = task.title?.toLowerCase().includes(searchTerm.toLowerCase()); + const matchesStatus = statusFilter === "all" || task.status === statusFilter; + return matchesSearch && matchesStatus; + }); + + // Composant formulaire inline + const TaskForm = ({ task, onClose }: any) => { + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + + const formData = new FormData(e.currentTarget); + const title = formData.get('title') as string; + const description = formData.get('description') as string; + const priority = formData.get('priority') as string; + const status = formData.get('status') as string; + const assignedTo = formData.get('assignedTo') as string; + const startDate = formData.get('startDate') as string; + const dueDate = formData.get('dueDate') as string; + + if (!title?.trim()) { + alert("Le titre est requis"); + return; + } + + if (!assignedTo?.trim()) { + alert("L'assignation est requise"); + return; + } + + const submitBtn = e.currentTarget.querySelector('button[type="submit"]') as HTMLButtonElement; + submitBtn.disabled = true; + submitBtn.textContent = "..."; + + try { + const taskData = { + title: title.trim(), + description: description?.trim() || "", + priority: priority || "medium", + status: status || "pending", + assignedTo: assignedTo.trim(), + startDate: startDate || null, + dueDate: dueDate || null, + }; + + const url = task ? `/api/tasks/${task.id}` : '/api/tasks'; + const method = task ? 'PUT' : 'POST'; + + if (!task) { + (taskData as any).groupId = 1; + (taskData as any).createdBy = 'admin'; + } + + console.log('📤 Sending request:', { url, method, taskData }); + + const response = await fetch(url, { + method, + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(taskData), + }); + + console.log('📥 Response:', { status: response.status, ok: response.ok }); + + if (!response.ok) { + const errorText = await response.text(); + console.error('❌ API Error:', { status: response.status, error: errorText }); + throw new Error(`Erreur ${response.status}: ${errorText}`); + } + + alert(task ? "Tâche modifiée avec succès" : "Tâche créée avec succès"); + onClose(); + loadTasks(); // Recharger les tâches + + } catch (error) { + console.error('Erreur:', error); + alert("Erreur lors de l'opération"); + submitBtn.disabled = false; + submitBtn.textContent = task ? "Modifier" : "Créer"; + } + }; + + return ( +
+
+

+ 📅 Date de début = Quand la tâche devient visible
+ ⏰ Date d'échéance = Quand la tâche doit être terminée +

+ +
+ +
+
+ + +
+ +
+ +