mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Add detailed logging to announcement creation for debugging
Add extensive console logging on both client and server to aid in debugging announcement creation issues, including validation checks and user role verification. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e437ffed-c31b-44eb-9fd5-b6f9faa8e7ce Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/e437ffed-c31b-44eb-9fd5-b6f9faa8e7ce/aVFsaJG
This commit is contained in:
1 parent
d7aed9dc25
commit
3134732cb2
3 files changed
+244
-2
No files matched your search
+201
@@ -0,0 +1,201 @@
|
||||
|
||||
|
||||
}
|
||||
|
||||
📊 Statistiques calculées: {
|
||||
|
||||
ordersCount: 20,
|
||||
|
||||
deliveriesCount: 42,
|
||||
|
||||
pendingOrdersCount: 8,
|
||||
|
||||
averageDeliveryTime: 0.3611111111111111,
|
||||
|
||||
totalPalettes: 120,
|
||||
|
||||
totalPackages: 36
|
||||
|
||||
}
|
||||
|
||||
GET /api/stats/monthly 200 in 91ms
|
||||
|
||||
🔍 Tasks API called with: {
|
||||
|
||||
groupIds: undefined,
|
||||
|
||||
userRole: 'admin',
|
||||
|
||||
userId: 'admin_local',
|
||||
|
||||
requestedStoreId: undefined,
|
||||
|
||||
userGroups: 'all',
|
||||
|
||||
timestamp: '2025-08-16T12:21:04.881Z'
|
||||
|
||||
}
|
||||
|
||||
🗓️ [DATE-CALC] Aujourd'hui: 2025-08-16 (Samedi)
|
||||
|
||||
🗓️ [DATE-CALC] Année précédente: 2024-08-17 (Samedi)
|
||||
|
||||
GET /api/user 200 in 73ms
|
||||
|
||||
📢 Système d'annonces en mémoire initialisé (max 5 annonces)
|
||||
|
||||
🌤️ [RESPONSE] Weather data prepared: {
|
||||
|
||||
hasCurrentYear: true,
|
||||
|
||||
hasPreviousYear: true,
|
||||
|
||||
location: 'Frouard, France'
|
||||
|
||||
}
|
||||
|
||||
GET /api/weather/current 200 in 172ms
|
||||
|
||||
📋 Tasks returned: {
|
||||
|
||||
␍ count: 55,
|
||||
|
||||
userId: 'admin_local',
|
||||
|
||||
userRole: 'admin',
|
||||
|
||||
requestedStoreId: undefined,
|
||||
|
||||
groupIds: undefined,
|
||||
|
||||
taskGroups: [
|
||||
|
||||
{ id: 91, title: 'refaire podium lot assiettes', groupId: 2 },
|
||||
|
||||
{ id: 90, title: 'caisse 1', groupId: 1 },
|
||||
|
||||
{ id: 89, title: 'caisse 3', groupId: 1 }
|
||||
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
GET /api/tasks 200 in 145ms
|
||||
|
||||
GET /api/announcements 200 in 210ms
|
||||
|
||||
Orders API called with: {
|
||||
|
||||
startDate: undefined,
|
||||
|
||||
endDate: undefined,
|
||||
|
||||
storeId: undefined,
|
||||
|
||||
userRole: 'admin'
|
||||
|
||||
}
|
||||
|
||||
Admin filtering with groupIds: undefined
|
||||
|
||||
Fetching all orders
|
||||
|
||||
GET /api/groups 200 in 93ms
|
||||
|
||||
GET /api/user 200 in 234ms
|
||||
|
||||
GET /api/user 200 in 246ms
|
||||
|
||||
Deliveries API called with: {
|
||||
|
||||
startDate: undefined,
|
||||
|
||||
endDate: undefined,
|
||||
|
||||
storeId: undefined,
|
||||
|
||||
withBL: undefined,
|
||||
|
||||
userRole: 'admin'
|
||||
|
||||
}
|
||||
|
||||
Admin filtering deliveries with groupIds: undefined
|
||||
|
||||
Fetching all deliveries
|
||||
|
||||
GET /api/publicities 200 in 217ms
|
||||
|
||||
GET /api/dlc-products/stats 200 in 273ms
|
||||
|
||||
Customer Orders API called with: { groupIds: undefined, userRole: 'admin' }
|
||||
|
||||
Customer Orders returned: 38 items
|
||||
|
||||
🔗 PRODUCTION: getOrders() récupéré 51 commandes avec relations
|
||||
|
||||
Orders returned: 51 items
|
||||
|
||||
GET /api/customer-orders 200 in 468ms
|
||||
|
||||
GET /api/orders 200 in 479ms
|
||||
|
||||
Customer Orders API called with: { groupIds: [ 1 ], userRole: 'admin' }
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 86 livraisons avec relations
|
||||
|
||||
Deliveries returned: 86 items
|
||||
|
||||
GET /api/deliveries 200 in 506ms
|
||||
|
||||
Customer Orders returned: 10 items
|
||||
|
||||
GET /api/customer-orders 200 in 73ms
|
||||
|
||||
Deliveries API called with: {
|
||||
|
||||
startDate: undefined,
|
||||
|
||||
endDate: undefined,
|
||||
|
||||
storeId: '1',
|
||||
|
||||
withBL: undefined,
|
||||
|
||||
userRole: 'admin'
|
||||
|
||||
}
|
||||
|
||||
Admin filtering deliveries with groupIds: [ 1 ]
|
||||
|
||||
Fetching all deliveries
|
||||
|
||||
Orders API called with: {
|
||||
|
||||
startDate: undefined,
|
||||
|
||||
endDate: undefined,
|
||||
|
||||
storeId: '1',
|
||||
|
||||
userRole: 'admin'
|
||||
|
||||
}
|
||||
|
||||
Admin filtering with groupIds: [ 1 ]
|
||||
|
||||
Fetching all orders
|
||||
|
||||
🔗 PRODUCTION: getDeliveries() récupéré 48 livraisons avec relations
|
||||
|
||||
Deliveries returned: 48 items
|
||||
|
||||
GET /api/deliveries 200 in 198ms
|
||||
|
||||
🔗 PRODUCTION: getOrders() récupéré 33 commandes avec relations
|
||||
|
||||
Orders returned: 33 items
|
||||
|
||||
GET /api/orders 200 in 261ms
|
||||
|
||||
GET /api/publicities 200 in 204ms
|
||||
@@ -137,6 +137,22 @@ export default function AnnouncementCard() {
|
||||
});
|
||||
|
||||
const onSubmit = (data: z.infer<typeof formSchema>) => {
|
||||
console.log('🔥 [FORM] onSubmit called with data:', data);
|
||||
console.log('🔥 [FORM] Form errors:', form.formState.errors);
|
||||
console.log('🔥 [FORM] Form is valid:', form.formState.isValid);
|
||||
console.log('🔥 [FORM] Form is submitting:', form.formState.isSubmitting);
|
||||
|
||||
if (!data.title || !data.content) {
|
||||
console.error('🔥 [FORM] Missing required fields:', { title: data.title, content: data.content });
|
||||
toast({
|
||||
title: "Erreur",
|
||||
description: "Le titre et le contenu sont obligatoires",
|
||||
variant: "destructive",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('🔥 [FORM] Calling createMutation.mutate');
|
||||
createMutation.mutate(data);
|
||||
};
|
||||
|
||||
@@ -268,7 +284,11 @@ export default function AnnouncementCard() {
|
||||
>
|
||||
Annuler
|
||||
</Button>
|
||||
<Button type="submit" disabled={createMutation.isPending}>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={createMutation.isPending}
|
||||
onClick={() => console.log('🔥 [BUTTON] Submit button clicked')}
|
||||
>
|
||||
{createMutation.isPending ? 'Création...' : 'Créer'}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
+22
-1
@@ -3029,28 +3029,49 @@ RÉSUMÉ DU SCAN
|
||||
});
|
||||
|
||||
app.post('/api/announcements', isAuthenticated, async (req: any, res) => {
|
||||
console.log('🎯 [SERVER] POST /api/announcements endpoint hit');
|
||||
console.log('🎯 [SERVER] Request body:', JSON.stringify(req.body, null, 2));
|
||||
console.log('🎯 [SERVER] User object:', {
|
||||
hasClaims: !!req.user.claims,
|
||||
hasId: !!req.user.id,
|
||||
userId: req.user.claims ? req.user.claims.sub : req.user.id
|
||||
});
|
||||
|
||||
try {
|
||||
const userId = req.user.claims ? req.user.claims.sub : req.user.id;
|
||||
console.log('🎯 [SERVER] Extracted userId:', userId);
|
||||
|
||||
const user = await storage.getUserWithGroups(userId);
|
||||
if (!user) {
|
||||
console.error('🎯 [SERVER] User not found for ID:', userId);
|
||||
return res.status(404).json({ message: "User not found" });
|
||||
}
|
||||
|
||||
console.log('🎯 [SERVER] User found:', { username: user.username, role: user.role, id: user.id });
|
||||
|
||||
// Only admin can create announcements
|
||||
if (user.role !== 'admin') {
|
||||
console.error('🎯 [SERVER] Access denied - user role:', user.role);
|
||||
return res.status(403).json({ message: "Only administrators can create announcements" });
|
||||
}
|
||||
|
||||
console.log('🎯 [SERVER] User is admin, proceeding with validation');
|
||||
|
||||
const announcementData = insertAnnouncementSchema.parse({
|
||||
...req.body,
|
||||
authorId: user.id,
|
||||
});
|
||||
|
||||
console.log('🎯 [SERVER] Announcement data validated:', announcementData);
|
||||
|
||||
const announcement = await storage.createAnnouncement(announcementData);
|
||||
console.log('🎯 [SERVER] Announcement created successfully:', announcement);
|
||||
|
||||
res.status(201).json(announcement);
|
||||
} catch (error) {
|
||||
console.error("Error creating announcement:", error);
|
||||
console.error('🎯 [SERVER] Error creating announcement:', error);
|
||||
if (error instanceof z.ZodError) {
|
||||
console.error('🎯 [SERVER] Validation errors:', error.errors);
|
||||
return res.status(400).json({ message: "Validation error", errors: error.errors });
|
||||
}
|
||||
res.status(500).json({ message: "Failed to create announcement" });
|
||||
|
||||
Reference in new issue
Block a user