mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-12 09:47:54 +02:00
Improve date handling for task creation and retrieval
Update client-side and server-side logic to correctly process and store date values, ensuring compatibility with PostgreSQL timestamp types. This includes converting string dates to Date objects before insertion and ensuring string IDs are converted to numbers for API calls. Replit-Commit-Author: Agent Replit-Commit-Session-Id: f2b9c241-9fdd-4abd-9041-720afc8b27d6 Replit-Commit-Checkpoint-Type: full_checkpoint
This commit is contained in:
1 parent
3ec315ddd2
commit
9dc199d188
4 files changed
+221
-5
No files matched your search
+209
@@ -0,0 +1,209 @@
|
||||
Search
|
||||
Filter...
|
||||
Lines
|
||||
100
|
||||
Actions
|
||||
|
||||
|
||||
|
||||
|
||||
Fetching all deliveries
|
||||
|
||||
📢 [SERVER] Fetching announcements for user: admin_local environment: production
|
||||
|
||||
Customer Orders API called with: { groupIds: [ 2 ], userRole: 'admin' }
|
||||
|
||||
🔗 PRODUCTION: getOrders() récupéré 29 commandes avec relations
|
||||
|
||||
Orders returned: 29 items
|
||||
|
||||
GET /api/orders 200 in 95ms
|
||||
|
||||
❌ PRODUCTION: Delivery #127 (store 2) linked to order #81 (store 1) - STORE MISMATCH DETECTED!
|
||||
|
||||
Customer Orders returned: 42 items
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 59 livraisons avec relations
|
||||
|
||||
Deliveries returned: 59 items
|
||||
|
||||
📢 [SERVER] User found: { username: 'admin', role: 'admin' }
|
||||
|
||||
🎯 [PRODUCTION] Using PostgreSQL DASHBOARD_MESSAGES table
|
||||
|
||||
GET /api/customer-orders 304 in 109ms
|
||||
|
||||
GET /api/deliveries 304 in 111ms
|
||||
|
||||
🔍 [PRODUCTION] Raw messages from DB: 2 items: [
|
||||
|
||||
{
|
||||
|
||||
id: 16,
|
||||
|
||||
title: 'Mise à jour Prix',
|
||||
|
||||
content: 'Merci de mettre vos prix a jour tous les matins, certain magasin ne le font pas.',
|
||||
|
||||
type: 'success',
|
||||
|
||||
storeId: null,
|
||||
|
||||
createdBy: 'admin',
|
||||
|
||||
createdAt: 2025-08-18T10:45:08.585Z
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
id: 8,
|
||||
|
||||
title: 'Bon de Livraison',
|
||||
|
||||
content: 'Lorsque vous rentrez un numéro de bon de livraison, faite le a l identique, même les majuscules. Pour My candy Shop, prendre le numéro de commande.',
|
||||
|
||||
type: 'info',
|
||||
|
||||
storeId: null,
|
||||
|
||||
createdBy: 'admin_local',
|
||||
|
||||
createdAt: 2025-08-07T11:04:38.123Z
|
||||
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
🔍 [PRODUCTION] Looking for user with username: admin
|
||||
|
||||
🔍 [PRODUCTION] Looking for user with username: admin_local
|
||||
|
||||
GET /api/groups 304 in 58ms
|
||||
|
||||
🔍 [PRODUCTION] User search result: Found
|
||||
|
||||
❌ [PRODUCTION] User not found with username: admin_local
|
||||
|
||||
🔍 [PRODUCTION] User search result: Not found
|
||||
|
||||
🎯 [PRODUCTION] Found announcements: 2
|
||||
|
||||
GET /api/announcements 304 in 117ms
|
||||
|
||||
GET /api/user 304 in 4ms
|
||||
|
||||
GET /api/users 304 in 15ms
|
||||
|
||||
HEAD /api/health 200 in 0ms
|
||||
|
||||
📝 POST /api/tasks - Received data: {
|
||||
|
||||
originalBody: {
|
||||
|
||||
title: 'test',
|
||||
|
||||
description: 'test',
|
||||
|
||||
priority: 'medium',
|
||||
|
||||
status: 'pending',
|
||||
|
||||
assignedTo: 'Non assigné',
|
||||
|
||||
startDate: '2025-09-02',
|
||||
|
||||
dueDate: '2025-09-07',
|
||||
|
||||
groupId: 2,
|
||||
|
||||
createdBy: 'admin'
|
||||
|
||||
},
|
||||
|
||||
processedData: {
|
||||
|
||||
title: 'test',
|
||||
|
||||
description: 'test',
|
||||
|
||||
priority: 'medium',
|
||||
|
||||
status: 'pending',
|
||||
|
||||
assignedTo: 'Non assigné',
|
||||
|
||||
startDate: '2025-09-02',
|
||||
|
||||
dueDate: '2025-09-07',
|
||||
|
||||
groupId: 2,
|
||||
|
||||
createdBy: 'admin_local'
|
||||
|
||||
},
|
||||
|
||||
dueDate: '2025-09-07',
|
||||
|
||||
dueDateType: 'string',
|
||||
|
||||
dueDateValue: '2025-09-07'
|
||||
|
||||
}
|
||||
|
||||
💾 DatabaseStorage.createTask - Input: {
|
||||
|
||||
taskData: {
|
||||
|
||||
title: 'test',
|
||||
|
||||
description: 'test',
|
||||
|
||||
priority: 'medium',
|
||||
|
||||
status: 'pending',
|
||||
|
||||
assignedTo: 'Non assigné',
|
||||
|
||||
startDate: '2025-09-02',
|
||||
|
||||
dueDate: '2025-09-07',
|
||||
|
||||
groupId: 2,
|
||||
|
||||
createdBy: 'admin_local'
|
||||
|
||||
},
|
||||
|
||||
dueDate: '2025-09-07',
|
||||
|
||||
dueDateType: 'string',
|
||||
|
||||
dueDateISO: '2025-09-07'
|
||||
|
||||
}
|
||||
|
||||
Error creating task: TypeError: value.toISOString is not a function
|
||||
|
||||
at PgTimestamp.mapToDriverValue (file:///app/node_modules/drizzle-orm/pg-core/columns/timestamp.js:34:18)
|
||||
|
||||
at file:///app/node_modules/drizzle-orm/sql/sql.js:131:73
|
||||
|
||||
at Array.map (<anonymous>)
|
||||
|
||||
at SQL.buildQueryFromSourceParams (file:///app/node_modules/drizzle-orm/sql/sql.js:73:32)
|
||||
|
||||
at file:///app/node_modules/drizzle-orm/sql/sql.js:92:21
|
||||
|
||||
at Array.map (<anonymous>)
|
||||
|
||||
at SQL.buildQueryFromSourceParams (file:///app/node_modules/drizzle-orm/sql/sql.js:73:32)
|
||||
|
||||
at file:///app/node_modules/drizzle-orm/sql/sql.js:95:21
|
||||
|
||||
at Array.map (<anonymous>)
|
||||
|
||||
at SQL.buildQueryFromSourceParams (file:///app/node_modules/drizzle-orm/sql/sql.js:73:32)
|
||||
|
||||
POST /api/tasks 500 in 7ms
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 281 KiB |
@@ -52,7 +52,7 @@ export default function TasksSimplified() {
|
||||
queryFn: () => {
|
||||
const params = new URLSearchParams();
|
||||
if (selectedStoreId) {
|
||||
params.append('storeId', selectedStoreId);
|
||||
params.append('storeId', selectedStoreId.toString());
|
||||
}
|
||||
return fetch(`/api/tasks?${params.toString()}`).then(res => res.json());
|
||||
},
|
||||
@@ -60,7 +60,7 @@ export default function TasksSimplified() {
|
||||
});
|
||||
|
||||
// Récupération des magasins
|
||||
const { data: stores = [] } = useQuery({
|
||||
const { data: stores = [] } = useQuery<any[]>({
|
||||
queryKey: ["/api/groups"],
|
||||
enabled: !!user,
|
||||
});
|
||||
|
||||
+10
-3
@@ -1791,7 +1791,14 @@ export class DatabaseStorage implements IStorage {
|
||||
dueDateISO: taskData.dueDate instanceof Date ? taskData.dueDate.toISOString() : taskData.dueDate
|
||||
});
|
||||
|
||||
const [task] = await db.insert(tasks).values(taskData).returning();
|
||||
// Convert string dates to Date objects for Drizzle PostgreSQL
|
||||
const processedTaskData = {
|
||||
...taskData,
|
||||
startDate: taskData.startDate ? new Date(taskData.startDate) : null,
|
||||
dueDate: taskData.dueDate ? new Date(taskData.dueDate) : null,
|
||||
};
|
||||
|
||||
const [task] = await db.insert(tasks).values(processedTaskData).returning();
|
||||
|
||||
console.log('💾 DatabaseStorage.createTask - Result:', {
|
||||
taskId: task.id,
|
||||
@@ -1840,8 +1847,8 @@ export class DatabaseStorage implements IStorage {
|
||||
if (taskData.dueDate === '' || taskData.dueDate === null) {
|
||||
cleanData.dueDate = null;
|
||||
} else {
|
||||
// due_date est un date en PostgreSQL - on passe la chaîne directement
|
||||
cleanData.dueDate = taskData.dueDate;
|
||||
// due_date est un timestamp en PostgreSQL - convertir en Date object
|
||||
cleanData.dueDate = new Date(taskData.dueDate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user