mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Fix task due date not saving correctly to a future date
Add console logging to client and server to debug and fix an issue where task due dates were not being saved correctly, defaulting to the current date instead of the selected future date. Replit-Commit-Author: Agent Replit-Commit-Session-Id: cc2d271b-82f0-4d6a-9302-a0b067ffb429 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/cc2d271b-82f0-4d6a-9302-a0b067ffb429/xi95nEa
This commit is contained in:
1 parent
c8b76c8b2e
commit
87cc2a0f88
4 files changed
+93
-2
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 330 KiB |
@@ -134,7 +134,12 @@ export default function TaskForm({ task, onClose }: TaskFormProps) {
|
||||
createdBy: user?.id,
|
||||
dueDate: data.dueDate || null
|
||||
};
|
||||
console.log('🚀 Creating task with data:', taskData);
|
||||
console.log('🚀 Creating task with data:', {
|
||||
...taskData,
|
||||
dueDate: taskData.dueDate,
|
||||
dueDateType: typeof taskData.dueDate,
|
||||
dueDateISO: taskData.dueDate?.toISOString?.()
|
||||
});
|
||||
return apiRequest("/api/tasks", "POST", taskData);
|
||||
},
|
||||
onSuccess: () => {
|
||||
@@ -156,7 +161,16 @@ export default function TaskForm({ task, onClose }: TaskFormProps) {
|
||||
});
|
||||
|
||||
const updateMutation = useMutation({
|
||||
mutationFn: (data: any) => apiRequest(`/api/tasks/${task?.id}`, "PUT", data),
|
||||
mutationFn: (data: any) => {
|
||||
console.log('🔄 Updating task with data:', {
|
||||
taskId: task?.id,
|
||||
data,
|
||||
dueDate: data.dueDate,
|
||||
dueDateType: typeof data.dueDate,
|
||||
dueDateISO: data.dueDate?.toISOString?.()
|
||||
});
|
||||
return apiRequest(`/api/tasks/${task?.id}`, "PUT", data);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["/api/tasks"] });
|
||||
toast({
|
||||
@@ -176,6 +190,17 @@ export default function TaskForm({ task, onClose }: TaskFormProps) {
|
||||
});
|
||||
|
||||
const onSubmit = (data: TaskFormData) => {
|
||||
// Debug: log des données de soumission
|
||||
console.log('📝 TaskForm onSubmit:', {
|
||||
isEdit: !!task,
|
||||
taskId: task?.id,
|
||||
formData: data,
|
||||
dueDate: data.dueDate,
|
||||
dueDateType: typeof data.dueDate,
|
||||
dueDateISO: data.dueDate?.toISOString(),
|
||||
localSelectedStoreId
|
||||
});
|
||||
|
||||
// Vérifier qu'un magasin est auto-sélectionné
|
||||
if (!localSelectedStoreId) {
|
||||
toast({
|
||||
@@ -196,9 +221,11 @@ export default function TaskForm({ task, onClose }: TaskFormProps) {
|
||||
assignedTo: data.assignedTo,
|
||||
dueDate: data.dueDate || null,
|
||||
};
|
||||
console.log('🔄 Update task submitData:', submitData);
|
||||
updateMutation.mutate(submitData);
|
||||
} else {
|
||||
// Création d'une nouvelle tâche - le groupId sera ajouté dans createMutation
|
||||
console.log('➕ Create task data:', data);
|
||||
createMutation.mutate(data);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1390,6 +1390,14 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
createdBy: user.id,
|
||||
};
|
||||
|
||||
console.log('📝 POST /api/tasks - Received data:', {
|
||||
originalBody: req.body,
|
||||
processedData: data,
|
||||
dueDate: data.dueDate,
|
||||
dueDateType: typeof data.dueDate,
|
||||
dueDateValue: data.dueDate
|
||||
});
|
||||
|
||||
// Check if user has access to the group
|
||||
if (user.role !== 'admin') {
|
||||
const userGroupIds = user.userGroups.map(ug => ug.groupId);
|
||||
@@ -1399,6 +1407,12 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
|
||||
const task = await storage.createTask(data);
|
||||
console.log('✅ Task created:', {
|
||||
id: task.id,
|
||||
title: task.title,
|
||||
dueDate: task.dueDate,
|
||||
dueDateType: typeof task.dueDate
|
||||
});
|
||||
res.json(task);
|
||||
} catch (error) {
|
||||
console.error("Error creating task:", error);
|
||||
@@ -1420,6 +1434,19 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
return res.status(404).json({ message: "Task not found" });
|
||||
}
|
||||
|
||||
console.log('🔄 PUT /api/tasks/:id - Received data:', {
|
||||
taskId: id,
|
||||
originalTask: {
|
||||
id: task.id,
|
||||
title: task.title,
|
||||
dueDate: task.dueDate,
|
||||
dueDateType: typeof task.dueDate
|
||||
},
|
||||
updateBody: req.body,
|
||||
newDueDate: req.body.dueDate,
|
||||
newDueDateType: typeof req.body.dueDate
|
||||
});
|
||||
|
||||
// Check permissions
|
||||
if (user.role !== 'admin') {
|
||||
const userGroupIds = user.userGroups.map(ug => ug.groupId);
|
||||
@@ -1429,6 +1456,12 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
|
||||
const updatedTask = await storage.updateTask(id, req.body);
|
||||
console.log('✅ Task updated:', {
|
||||
id: updatedTask.id,
|
||||
title: updatedTask.title,
|
||||
dueDate: updatedTask.dueDate,
|
||||
dueDateType: typeof updatedTask.dueDate
|
||||
});
|
||||
res.json(updatedTask);
|
||||
} catch (error) {
|
||||
console.error("Error updating task:", error);
|
||||
|
||||
@@ -1622,16 +1622,47 @@ export class DatabaseStorage implements IStorage {
|
||||
}
|
||||
|
||||
async createTask(taskData: InsertTask): Promise<Task> {
|
||||
console.log('💾 DatabaseStorage.createTask - Input:', {
|
||||
taskData,
|
||||
dueDate: taskData.dueDate,
|
||||
dueDateType: typeof taskData.dueDate,
|
||||
dueDateISO: taskData.dueDate instanceof Date ? taskData.dueDate.toISOString() : taskData.dueDate
|
||||
});
|
||||
|
||||
const [task] = await db.insert(tasks).values(taskData).returning();
|
||||
|
||||
console.log('💾 DatabaseStorage.createTask - Result:', {
|
||||
taskId: task.id,
|
||||
title: task.title,
|
||||
dueDate: task.dueDate,
|
||||
dueDateType: typeof task.dueDate
|
||||
});
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
async updateTask(id: number, taskData: Partial<InsertTask>): Promise<Task> {
|
||||
console.log('💾 DatabaseStorage.updateTask - Input:', {
|
||||
taskId: id,
|
||||
taskData,
|
||||
dueDate: taskData.dueDate,
|
||||
dueDateType: typeof taskData.dueDate,
|
||||
dueDateISO: taskData.dueDate instanceof Date ? taskData.dueDate.toISOString() : taskData.dueDate
|
||||
});
|
||||
|
||||
const [task] = await db
|
||||
.update(tasks)
|
||||
.set({ ...taskData, updatedAt: new Date() })
|
||||
.where(eq(tasks.id, id))
|
||||
.returning();
|
||||
|
||||
console.log('💾 DatabaseStorage.updateTask - Result:', {
|
||||
taskId: task.id,
|
||||
title: task.title,
|
||||
dueDate: task.dueDate,
|
||||
dueDateType: typeof task.dueDate
|
||||
});
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user