mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-16 19:56:32 +02:00
Improve order creation process and add detailed logging
Add more logging to the customer order form and mutation to help debug issues with order creation and role-based access. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 31f9bd88-0285-4787-81b3-31ceeea5a08b Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/31f9bd88-0285-4787-81b3-31ceeea5a08b/KTd2gcf
This commit is contained in:
1 parent
2fe5aac6c3
commit
c88a403d6d
4 files changed
+229
-7
No files matched your search
+201
@@ -0,0 +1,201 @@
|
|||||||
|
|
||||||
|
isProduction: true,
|
||||||
|
|
||||||
|
hasDbUrl: true,
|
||||||
|
|
||||||
|
dbHost: 'logiflow-db:5432'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
✅ Using DatabaseStorage (production PostgreSQL)
|
||||||
|
|
||||||
|
⏰ Automatic backup scheduled for 2:00 AM daily (native timer)
|
||||||
|
|
||||||
|
🔍 Using development storage and authentication
|
||||||
|
|
||||||
|
🐳 PRODUCTION: Starting LogiFlow application
|
||||||
|
|
||||||
|
🐳 Environment: { NODE_ENV: 'production', DATABASE_URL: 'Present', PORT: '3000' }
|
||||||
|
|
||||||
|
🔧 Registering all production routes...
|
||||||
|
|
||||||
|
🔄 Running automatic production migrations...
|
||||||
|
|
||||||
|
🔄 MIGRATION: Starting SAV production migrations...
|
||||||
|
|
||||||
|
🔄 MIGRATION: Database URL configured: postgresql://logiflow_admin:Lo...
|
||||||
|
|
||||||
|
✅ MIGRATION: Connected to PostgreSQL database
|
||||||
|
|
||||||
|
🔄 MIGRATION: Checking if priority column exists...
|
||||||
|
|
||||||
|
🔄 MIGRATION: Priority column check result: 1
|
||||||
|
|
||||||
|
✅ MIGRATION: Priority column already exists, skipping migration
|
||||||
|
|
||||||
|
🔌 MIGRATION: Database connection closed
|
||||||
|
|
||||||
|
🔧 Using memory session store for development
|
||||||
|
|
||||||
|
Warning: connect.session() MemoryStore is not
|
||||||
|
|
||||||
|
designed for a production environment, as it will leak
|
||||||
|
|
||||||
|
memory, and will not scale past a single process.
|
||||||
|
|
||||||
|
✅ All routes registered successfully for production
|
||||||
|
|
||||||
|
🐳 Serving static files from: /app/dist/public
|
||||||
|
|
||||||
|
🐳 PRODUCTION: LogiFlow serving on port 3000
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 5ms
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 0ms
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 1ms
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 1ms
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 1ms
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 0ms
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 1ms
|
||||||
|
|
||||||
|
📄 SPA: Serving index.html for /sav
|
||||||
|
|
||||||
|
GET /api/user 401 in 1ms
|
||||||
|
|
||||||
|
📄 SPA: Serving index.html for /auth
|
||||||
|
|
||||||
|
GET /api/user 401 in 1ms
|
||||||
|
|
||||||
|
GET /api/user 401 in 1ms
|
||||||
|
|
||||||
|
GET /api/default-credentials-check 304 in 22ms
|
||||||
|
|
||||||
|
🔐 comparePasswords: {
|
||||||
|
|
||||||
|
supplied: 'HIDDEN',
|
||||||
|
|
||||||
|
stored: 'b23ec450a63faf3957a1...',
|
||||||
|
|
||||||
|
hasFormat: true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
🔐 Password comparison result: true
|
||||||
|
|
||||||
|
POST /api/login 200 in 53ms
|
||||||
|
|
||||||
|
GET /api/user 200 in 5ms
|
||||||
|
|
||||||
|
GET /api/user 304 in 11ms
|
||||||
|
|
||||||
|
Deliveries API called with: {
|
||||||
|
|
||||||
|
startDate: undefined,
|
||||||
|
|
||||||
|
endDate: undefined,
|
||||||
|
|
||||||
|
storeId: undefined,
|
||||||
|
|
||||||
|
withBL: undefined,
|
||||||
|
|
||||||
|
userRole: 'employee'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Non-admin filtering deliveries with groupIds: [ 2 ]
|
||||||
|
|
||||||
|
📊 Calcul statistiques mensuelles: {
|
||||||
|
|
||||||
|
year: 2025,
|
||||||
|
|
||||||
|
month: 8,
|
||||||
|
|
||||||
|
startDate: '2025-08-01',
|
||||||
|
|
||||||
|
endDate: '2025-09-01',
|
||||||
|
|
||||||
|
groupIds: [ 2 ]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GET /api/user 304 in 85ms
|
||||||
|
|
||||||
|
Orders API called with: {
|
||||||
|
|
||||||
|
startDate: undefined,
|
||||||
|
|
||||||
|
endDate: undefined,
|
||||||
|
|
||||||
|
storeId: undefined,
|
||||||
|
|
||||||
|
userRole: 'employee'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Non-admin filtering with groupIds: [ 2 ]
|
||||||
|
|
||||||
|
Customer Orders API called with: { groupIds: [ 2 ], userRole: 'employee' }
|
||||||
|
|
||||||
|
Tasks API called with: { groupIds: [ 2 ], userRole: 'employee' }
|
||||||
|
|
||||||
|
GET /api/publicities 304 in 179ms
|
||||||
|
|
||||||
|
🔗 PRODUCTION: getDeliveries() récupéré 38 livraisons avec relations
|
||||||
|
|
||||||
|
Deliveries returned: 38 items
|
||||||
|
|
||||||
|
GET /api/dlc-products/stats 200 in 186ms
|
||||||
|
|
||||||
|
GET /api/deliveries 200 in 194ms
|
||||||
|
|
||||||
|
Customer Orders returned: 25 items
|
||||||
|
|
||||||
|
Tasks returned: 9 items
|
||||||
|
|
||||||
|
GET /api/customer-orders 200 in 249ms
|
||||||
|
|
||||||
|
GET /api/tasks 200 in 241ms
|
||||||
|
|
||||||
|
📊 Statistiques calculées: {
|
||||||
|
|
||||||
|
ordersCount: 8,
|
||||||
|
|
||||||
|
deliveriesCount: 21,
|
||||||
|
|
||||||
|
pendingOrdersCount: 4,
|
||||||
|
|
||||||
|
averageDeliveryTime: 0.17647058823529413,
|
||||||
|
|
||||||
|
totalPalettes: 57,
|
||||||
|
|
||||||
|
totalPackages: 17
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GET /api/stats/monthly 200 in 279ms
|
||||||
|
|
||||||
|
🔗 PRODUCTION: getOrders() récupéré 18 commandes avec relations
|
||||||
|
|
||||||
|
Orders returned: 18 items
|
||||||
|
|
||||||
|
GET /api/orders 200 in 285ms
|
||||||
|
|
||||||
|
GET /api/user 304 in 8ms
|
||||||
|
|
||||||
|
GET /api/publicities 304 in 18ms
|
||||||
|
|
||||||
|
GET /api/groups 200 in 5ms
|
||||||
|
|
||||||
|
GET /api/user 304 in 3ms
|
||||||
|
|
||||||
|
GET /api/suppliers 304 in 6ms
|
||||||
|
|
||||||
|
GET /api/user 304 in 4ms
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 1ms
|
||||||
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 232 KiB |
@@ -106,13 +106,19 @@ export function CustomerOrderForm({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleSubmit = (data: CustomerOrderFormData) => {
|
const handleSubmit = (data: CustomerOrderFormData) => {
|
||||||
console.log("Form submission data:", data);
|
console.log("🚀 FORM SUBMIT STARTED");
|
||||||
console.log("Form errors:", form.formState.errors);
|
console.log("📝 Form submission data:", data);
|
||||||
console.log("Form is valid:", form.formState.isValid);
|
console.log("🔍 Form errors:", form.formState.errors);
|
||||||
|
console.log("✅ Form is valid:", form.formState.isValid);
|
||||||
|
console.log("👤 User context:", {
|
||||||
|
role: user?.role,
|
||||||
|
userGroups: user?.userGroups,
|
||||||
|
selectedStoreId
|
||||||
|
});
|
||||||
|
|
||||||
// Validate required fields
|
// Validate required fields
|
||||||
if (!data.customerName || data.customerName.trim() === '') {
|
if (!data.customerName || data.customerName.trim() === '') {
|
||||||
console.error("Customer name is required but empty");
|
console.error("❌ Customer name is required but empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,13 +148,15 @@ export function CustomerOrderForm({
|
|||||||
supplierId: data.supplierId || 1,
|
supplierId: data.supplierId || 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("✅ Customer Order Submit:", {
|
console.log("✅ Customer Order Submit FINAL:", {
|
||||||
userRole: user?.role,
|
userRole: user?.role,
|
||||||
assignedGroupId: groupId,
|
assignedGroupId: groupId,
|
||||||
submitData: submitData
|
submitData: submitData
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("🔥 CALLING onSubmit with data:", submitData);
|
||||||
onSubmit(submitData);
|
onSubmit(submitData);
|
||||||
|
console.log("🔥 onSubmit CALLED");
|
||||||
};
|
};
|
||||||
|
|
||||||
// Auto-ensure groupId is always set to user's assigned group
|
// Auto-ensure groupId is always set to user's assigned group
|
||||||
|
|||||||
@@ -77,8 +77,12 @@ export default function CustomerOrders() {
|
|||||||
|
|
||||||
// Create mutation
|
// Create mutation
|
||||||
const createMutation = useMutation({
|
const createMutation = useMutation({
|
||||||
mutationFn: (data: any) => apiRequest('/api/customer-orders', 'POST', data),
|
mutationFn: (data: any) => {
|
||||||
onSuccess: () => {
|
console.log("🔥 CREATE MUTATION STARTED with data:", data);
|
||||||
|
return apiRequest('/api/customer-orders', 'POST', data);
|
||||||
|
},
|
||||||
|
onSuccess: (result) => {
|
||||||
|
console.log("✅ CREATE MUTATION SUCCESS:", result);
|
||||||
// Force refresh of the query with store context
|
// Force refresh of the query with store context
|
||||||
queryClient.invalidateQueries({ predicate: (query) => query.queryKey[0]?.toString()?.includes('/api/customer-orders') ?? false });
|
queryClient.invalidateQueries({ predicate: (query) => query.queryKey[0]?.toString()?.includes('/api/customer-orders') ?? false });
|
||||||
queryClient.refetchQueries({ predicate: (query) => query.queryKey[0]?.toString()?.includes('/api/customer-orders') ?? false });
|
queryClient.refetchQueries({ predicate: (query) => query.queryKey[0]?.toString()?.includes('/api/customer-orders') ?? false });
|
||||||
@@ -89,6 +93,7 @@ export default function CustomerOrders() {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
onError: (error: any) => {
|
onError: (error: any) => {
|
||||||
|
console.error("❌ CREATE MUTATION ERROR:", error);
|
||||||
toast({
|
toast({
|
||||||
title: "Erreur",
|
title: "Erreur",
|
||||||
description: error.message || "Erreur lors de la création de la commande",
|
description: error.message || "Erreur lors de la création de la commande",
|
||||||
@@ -204,7 +209,15 @@ export default function CustomerOrders() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleCreateOrder = (data: any) => {
|
const handleCreateOrder = (data: any) => {
|
||||||
|
console.log("🎯 HANDLE CREATE ORDER CALLED with data:", data);
|
||||||
|
console.log("🎯 createMutation state:", {
|
||||||
|
isIdle: createMutation.isIdle,
|
||||||
|
isPending: createMutation.isPending,
|
||||||
|
isError: createMutation.isError,
|
||||||
|
isSuccess: createMutation.isSuccess
|
||||||
|
});
|
||||||
createMutation.mutate(data);
|
createMutation.mutate(data);
|
||||||
|
console.log("🎯 createMutation.mutate CALLED");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEditOrder = (data: any) => {
|
const handleEditOrder = (data: any) => {
|
||||||
|
|||||||
Reference in new issue
Block a user