Update task module presentation and resolve console errors

Refactor task route to use a new component and implement data validation and cleaning before updating tasks in the database to prevent errors.

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/grlWN1D
This commit is contained in:
michaelschal committed 2025-08-19 11:12:49 +00:00
1 parent 26579affb3
commit a2eecfb2ac
3 files changed
+48 -15

No files matched your search

+46 -13
View File
@@ -1710,21 +1710,54 @@ export class DatabaseStorage implements IStorage {
dueDateType: typeof taskData.dueDate,
dueDateISO: taskData.dueDate instanceof Date ? taskData.dueDate.toISOString() : taskData.dueDate
});
// Validation des données avant update
if (!taskData || typeof taskData !== 'object') {
throw new Error('Invalid task data provided');
}
// Nettoyer les données pour éviter les problèmes de type
const cleanData: any = {};
const [task] = await db
.update(tasks)
.set({ ...taskData, updatedAt: new Date() })
.where(eq(tasks.id, id))
.returning();
if (taskData.title !== undefined) cleanData.title = taskData.title;
if (taskData.description !== undefined) cleanData.description = taskData.description;
if (taskData.priority !== undefined) cleanData.priority = taskData.priority;
if (taskData.status !== undefined) cleanData.status = taskData.status;
if (taskData.assignedTo !== undefined) cleanData.assignedTo = taskData.assignedTo;
if (taskData.startDate !== undefined) {
cleanData.startDate = taskData.startDate === '' ? null : taskData.startDate;
}
if (taskData.dueDate !== undefined) {
cleanData.dueDate = taskData.dueDate === '' ? null : taskData.dueDate;
}
cleanData.updatedAt = new Date();
console.log('🧹 Cleaned data for database update:', cleanData);
try {
const [task] = await db
.update(tasks)
.set(cleanData)
.where(eq(tasks.id, id))
.returning();
console.log('✅ DatabaseStorage.updateTask - Success:', {
taskId: task.id,
title: task.title,
dueDate: task.dueDate,
dueDateType: typeof task.dueDate
});
console.log('💾 DatabaseStorage.updateTask - Result:', {
taskId: task.id,
title: task.title,
dueDate: task.dueDate,
dueDateType: typeof task.dueDate
});
return task;
return task;
} catch (error) {
console.error('❌ DatabaseStorage.updateTask - Database Error:', {
taskId: id,
error: error instanceof Error ? error.message : String(error),
cleanData
});
throw new Error(`Failed to update task in database: ${error instanceof Error ? error.message : String(error)}`);
}
}
async deleteTask(id: number): Promise<void> {