mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-20 21:49:07 +02:00
Add feedback and error handling for creating new announcements
Implement toast notifications for successful announcement creation and display detailed error messages from the API response if creation fails. 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
f2d056ee5d
commit
d7aed9dc25
3 files changed
+233
-3
No files matched your search
+201
@@ -0,0 +1,201 @@
|
|||||||
|
|
||||||
|
|
||||||
|
🔍 Tasks API called with: {
|
||||||
|
|
||||||
|
groupIds: undefined,
|
||||||
|
|
||||||
|
userRole: 'admin',
|
||||||
|
|
||||||
|
userId: 'admin_local',
|
||||||
|
|
||||||
|
requestedStoreId: undefined,
|
||||||
|
|
||||||
|
userGroups: 'all',
|
||||||
|
|
||||||
|
timestamp: '2025-08-16T12:14:15.937Z'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GET /api/user 200 in 130ms
|
||||||
|
|
||||||
|
🗓️ [DATE-CALC] Aujourd'hui: 2025-08-16 (Samedi)
|
||||||
|
|
||||||
|
🗓️ [DATE-CALC] Année précédente: 2024-08-17 (Samedi)
|
||||||
|
|
||||||
|
GET /api/user 200 in 83ms
|
||||||
|
|
||||||
|
GET /api/user 200 in 140ms
|
||||||
|
|
||||||
|
📢 Système d'annonces en mémoire initialisé (max 5 annonces)
|
||||||
|
|
||||||
|
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/announcements 200 in 165ms
|
||||||
|
|
||||||
|
GET /api/publicities 200 in 137ms
|
||||||
|
|
||||||
|
Customer Orders API called with: { groupIds: undefined, userRole: 'admin' }
|
||||||
|
|
||||||
|
GET /api/groups 200 in 66ms
|
||||||
|
|
||||||
|
🌤️ [RESPONSE] Weather data prepared: {
|
||||||
|
|
||||||
|
hasCurrentYear: true,
|
||||||
|
|
||||||
|
hasPreviousYear: true,
|
||||||
|
|
||||||
|
location: 'Frouard, France'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Orders API called with: {
|
||||||
|
|
||||||
|
startDate: undefined,
|
||||||
|
|
||||||
|
endDate: undefined,
|
||||||
|
|
||||||
|
storeId: undefined,
|
||||||
|
|
||||||
|
userRole: 'admin'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin filtering with groupIds: undefined
|
||||||
|
|
||||||
|
Fetching all orders
|
||||||
|
|
||||||
|
📊 Statistiques calculées: {
|
||||||
|
|
||||||
|
ordersCount: 20,
|
||||||
|
|
||||||
|
deliveriesCount: 42,
|
||||||
|
|
||||||
|
pendingOrdersCount: 8,
|
||||||
|
|
||||||
|
averageDeliveryTime: 0.3611111111111111,
|
||||||
|
|
||||||
|
totalPalettes: 120,
|
||||||
|
|
||||||
|
totalPackages: 36
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
📋 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/weather/current 200 in 328ms
|
||||||
|
|
||||||
|
GET /api/stats/monthly 200 in 307ms
|
||||||
|
|
||||||
|
GET /api/tasks 200 in 271ms
|
||||||
|
|
||||||
|
Customer Orders returned: 38 items
|
||||||
|
|
||||||
|
GET /api/customer-orders 200 in 370ms
|
||||||
|
|
||||||
|
🔗 PRODUCTION: getDeliveries() récupéré 86 livraisons avec relations
|
||||||
|
|
||||||
|
Deliveries returned: 86 items
|
||||||
|
|
||||||
|
GET /api/dlc-products/stats 200 in 433ms
|
||||||
|
|
||||||
|
GET /api/deliveries 200 in 456ms
|
||||||
|
|
||||||
|
Orders API called with: {
|
||||||
|
|
||||||
|
startDate: undefined,
|
||||||
|
|
||||||
|
endDate: undefined,
|
||||||
|
|
||||||
|
storeId: '1',
|
||||||
|
|
||||||
|
userRole: 'admin'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin filtering with groupIds: [ 1 ]
|
||||||
|
|
||||||
|
Fetching all orders
|
||||||
|
|
||||||
|
Customer Orders API called with: { groupIds: [ 1 ], userRole: 'admin' }
|
||||||
|
|
||||||
|
Deliveries API called with: {
|
||||||
|
|
||||||
|
startDate: undefined,
|
||||||
|
|
||||||
|
endDate: undefined,
|
||||||
|
|
||||||
|
storeId: '1',
|
||||||
|
|
||||||
|
withBL: undefined,
|
||||||
|
|
||||||
|
userRole: 'admin'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin filtering deliveries with groupIds: [ 1 ]
|
||||||
|
|
||||||
|
Fetching all deliveries
|
||||||
|
|
||||||
|
🔗 PRODUCTION: getOrders() récupéré 51 commandes avec relations
|
||||||
|
|
||||||
|
Orders returned: 51 items
|
||||||
|
|
||||||
|
GET /api/orders 200 in 521ms
|
||||||
|
|
||||||
|
Customer Orders returned: 10 items
|
||||||
|
|
||||||
|
GET /api/customer-orders 200 in 409ms
|
||||||
|
|
||||||
|
🔗 PRODUCTION: getOrders() récupéré 33 commandes avec relations
|
||||||
|
|
||||||
|
Orders returned: 33 items
|
||||||
|
|
||||||
|
GET /api/orders 200 in 485ms
|
||||||
|
|
||||||
|
🔗 PRODUCTION: getDeliveries() récupéré 48 livraisons avec relations
|
||||||
|
|
||||||
|
Deliveries returned: 48 items
|
||||||
|
|
||||||
|
GET /api/deliveries 200 in 502ms
|
||||||
|
|
||||||
|
GET /api/publicities 200 in 272ms
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 1ms
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 396 KiB |
@@ -17,6 +17,7 @@ import { insertAnnouncementSchema } from "@shared/schema";
|
|||||||
import type { AnnouncementWithRelations } from "@shared/schema";
|
import type { AnnouncementWithRelations } from "@shared/schema";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { safeFormat, safeDate } from "@/lib/dateUtils";
|
import { safeFormat, safeDate } from "@/lib/dateUtils";
|
||||||
|
import { useToast } from "@/hooks/use-toast";
|
||||||
|
|
||||||
const formSchema = insertAnnouncementSchema.extend({
|
const formSchema = insertAnnouncementSchema.extend({
|
||||||
groupId: z.coerce.number().optional(),
|
groupId: z.coerce.number().optional(),
|
||||||
@@ -27,6 +28,7 @@ export default function AnnouncementCard() {
|
|||||||
const { selectedStoreId } = useStore();
|
const { selectedStoreId } = useStore();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false);
|
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false);
|
||||||
|
const { toast } = useToast();
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof formSchema>>({
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
@@ -68,6 +70,8 @@ export default function AnnouncementCard() {
|
|||||||
// Create announcement mutation
|
// Create announcement mutation
|
||||||
const createMutation = useMutation({
|
const createMutation = useMutation({
|
||||||
mutationFn: async (data: z.infer<typeof formSchema>) => {
|
mutationFn: async (data: z.infer<typeof formSchema>) => {
|
||||||
|
console.log('📢 Creating announcement with data:', data);
|
||||||
|
|
||||||
const response = await fetch('/api/announcements', {
|
const response = await fetch('/api/announcements', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
@@ -75,16 +79,41 @@ export default function AnnouncementCard() {
|
|||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('📢 Create announcement response:', {
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
ok: response.ok
|
||||||
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Failed to create announcement');
|
const errorText = await response.text();
|
||||||
|
console.error('📢 Create announcement failed:', errorText);
|
||||||
|
throw new Error(`Failed to create announcement: ${response.status} - ${errorText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.json();
|
const result = await response.json();
|
||||||
|
console.log('📢 Announcement created successfully:', result);
|
||||||
|
return result;
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: (data) => {
|
||||||
|
console.log('📢 Announcement creation success callback:', data);
|
||||||
queryClient.invalidateQueries({ queryKey: ['/api/announcements'] });
|
queryClient.invalidateQueries({ queryKey: ['/api/announcements'] });
|
||||||
setIsCreateDialogOpen(false);
|
setIsCreateDialogOpen(false);
|
||||||
form.reset();
|
form.reset();
|
||||||
|
// Add success toast
|
||||||
|
toast({
|
||||||
|
title: "Succès",
|
||||||
|
description: "Annonce créée avec succès",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error('📢 Announcement creation error:', error);
|
||||||
|
// Add error toast
|
||||||
|
toast({
|
||||||
|
title: "Erreur",
|
||||||
|
description: error.message || "Impossible de créer l'annonce",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user