mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-23 15:08:22 +02:00
Fix order delivery status synchronization issues and improve client-side handling
Implement a client-side sync logic to correct order statuses where deliveries are marked as 'delivered' but the order status is not updated, addressing synchronization problems reported by users. Replit-Commit-Author: Agent Replit-Commit-Session-Id: a8a78c07-e900-425c-a577-5b4c5894379d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/a8a78c07-e900-425c-a577-5b4c5894379d/KuIk8gU
This commit is contained in:
1 parent
de8e6ad9d6
commit
d2e546c1bd
3 files changed
+245
-6
No files matched your search
+208
@@ -0,0 +1,208 @@
|
|||||||
|
ions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
Deliveries API called with: {
|
||||||
|
|
||||||
|
startDate: '2025-08-01',
|
||||||
|
|
||||||
|
endDate: '2025-08-31',
|
||||||
|
|
||||||
|
storeId: '1',
|
||||||
|
|
||||||
|
withBL: undefined,
|
||||||
|
|
||||||
|
userRole: 'admin'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin filtering deliveries with groupIds: [ 1 ]
|
||||||
|
|
||||||
|
Fetching deliveries by date range: 2025-08-01 to 2025-08-31
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
Orders API called with: {
|
||||||
|
|
||||||
|
startDate: '2025-08-01',
|
||||||
|
|
||||||
|
endDate: '2025-08-31',
|
||||||
|
|
||||||
|
storeId: '1',
|
||||||
|
|
||||||
|
userRole: 'admin'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin filtering with groupIds: [ 1 ]
|
||||||
|
|
||||||
|
Fetching orders by date range: 2025-08-01 to 2025-08-31
|
||||||
|
|
||||||
|
Deliveries returned: 20 items
|
||||||
|
|
||||||
|
Orders returned: 9 items
|
||||||
|
|
||||||
|
GET /api/orders 304 in 28ms
|
||||||
|
|
||||||
|
GET /api/deliveries 304 in 30ms
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 1ms
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
📄 SPA: Serving index.html for /[object%20Object]
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 2ms
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 1ms
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
📄 SPA: Serving index.html for /[object%20Object]
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
📄 SPA: Serving index.html for /[object%20Object]
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
📄 SPA: Serving index.html for /[object%20Object]
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: admin_local
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: admin_local
|
||||||
|
|
||||||
|
🔍 Found 0 group assignments for user admin_local
|
||||||
|
|
||||||
|
🔍 Raw query result: []
|
||||||
|
|
||||||
|
✅ Processed 0 groups for user admin_local
|
||||||
|
|
||||||
|
📄 SPA: Serving index.html for /[object%20Object]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 211 KiB |
@@ -148,16 +148,47 @@ export default function Calendar() {
|
|||||||
setIsSyncing(true);
|
setIsSyncing(true);
|
||||||
try {
|
try {
|
||||||
console.log('🔄 Starting manual sync of order-delivery status...');
|
console.log('🔄 Starting manual sync of order-delivery status...');
|
||||||
const response = await apiRequest({
|
|
||||||
url: '/api/sync-order-delivery-status',
|
// Solution temporaire : récupérer les données et faire la sync côté client
|
||||||
method: 'POST'
|
const ordersResponse = await fetch('/api/orders', { credentials: 'include' });
|
||||||
});
|
const allOrders = await ordersResponse.json();
|
||||||
|
|
||||||
|
console.log('📊 Orders loaded for sync:', allOrders.length);
|
||||||
|
|
||||||
|
let problematicOrders = 0;
|
||||||
|
let fixedOrders = 0;
|
||||||
|
|
||||||
|
// Parcourir les commandes et identifier celles à corriger
|
||||||
|
for (const order of allOrders) {
|
||||||
|
if (order.deliveries && order.deliveries.length > 0) {
|
||||||
|
const hasDeliveredDeliveries = order.deliveries.some(d => d.status === 'delivered');
|
||||||
|
|
||||||
|
if (hasDeliveredDeliveries && order.status !== 'delivered') {
|
||||||
|
problematicOrders++;
|
||||||
|
console.log(`🔍 Found problematic order: #CMD-${order.id} (status: ${order.status}) with delivered deliveries`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Corriger la commande via l'API PUT existante
|
||||||
|
await apiRequest({
|
||||||
|
url: `/api/orders/${order.id}`,
|
||||||
|
method: 'PUT',
|
||||||
|
data: { status: 'delivered' }
|
||||||
|
});
|
||||||
|
|
||||||
|
fixedOrders++;
|
||||||
|
console.log(`✅ Fixed order #CMD-${order.id} status to 'delivered'`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`❌ Failed to fix order #CMD-${order.id}:`, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log('🔄 Sync result:', response);
|
console.log('🔄 Sync completed:', { problematicOrders, fixedOrders });
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: "Synchronisation terminée",
|
title: "Synchronisation terminée",
|
||||||
description: `${response.diagnostics.ordersFixed} commande(s) corrigée(s) sur ${response.diagnostics.problematicOrdersFound} problématique(s)`,
|
description: `${fixedOrders} commande(s) corrigée(s) sur ${problematicOrders} problématique(s)`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Rafraîchir les données du calendrier
|
// Rafraîchir les données du calendrier
|
||||||
|
|||||||
Reference in new issue
Block a user