mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-12 01:37:40 +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
@@ -106,13 +106,19 @@ export function CustomerOrderForm({
|
||||
});
|
||||
|
||||
const handleSubmit = (data: CustomerOrderFormData) => {
|
||||
console.log("Form submission data:", data);
|
||||
console.log("Form errors:", form.formState.errors);
|
||||
console.log("Form is valid:", form.formState.isValid);
|
||||
console.log("🚀 FORM SUBMIT STARTED");
|
||||
console.log("📝 Form submission data:", data);
|
||||
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
|
||||
if (!data.customerName || data.customerName.trim() === '') {
|
||||
console.error("Customer name is required but empty");
|
||||
console.error("❌ Customer name is required but empty");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -142,13 +148,15 @@ export function CustomerOrderForm({
|
||||
supplierId: data.supplierId || 1,
|
||||
};
|
||||
|
||||
console.log("✅ Customer Order Submit:", {
|
||||
console.log("✅ Customer Order Submit FINAL:", {
|
||||
userRole: user?.role,
|
||||
assignedGroupId: groupId,
|
||||
submitData: submitData
|
||||
});
|
||||
|
||||
console.log("🔥 CALLING onSubmit with data:", submitData);
|
||||
onSubmit(submitData);
|
||||
console.log("🔥 onSubmit CALLED");
|
||||
};
|
||||
|
||||
// Auto-ensure groupId is always set to user's assigned group
|
||||
|
||||
@@ -77,8 +77,12 @@ export default function CustomerOrders() {
|
||||
|
||||
// Create mutation
|
||||
const createMutation = useMutation({
|
||||
mutationFn: (data: any) => apiRequest('/api/customer-orders', 'POST', data),
|
||||
onSuccess: () => {
|
||||
mutationFn: (data: any) => {
|
||||
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
|
||||
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 });
|
||||
@@ -89,6 +93,7 @@ export default function CustomerOrders() {
|
||||
});
|
||||
},
|
||||
onError: (error: any) => {
|
||||
console.error("❌ CREATE MUTATION ERROR:", error);
|
||||
toast({
|
||||
title: "Erreur",
|
||||
description: error.message || "Erreur lors de la création de la commande",
|
||||
@@ -204,7 +209,15 @@ export default function CustomerOrders() {
|
||||
};
|
||||
|
||||
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);
|
||||
console.log("🎯 createMutation.mutate CALLED");
|
||||
};
|
||||
|
||||
const handleEditOrder = (data: any) => {
|
||||
|
||||
Reference in new issue
Block a user