diff --git a/.replit b/.replit index ba2f351..9cd20b2 100644 --- a/.replit +++ b/.replit @@ -15,6 +15,10 @@ run = ["npm", "run", "start"] localPort = 5000 externalPort = 80 +[[ports]] +localPort = 38151 +externalPort = 3003 + [[ports]] localPort = 38343 externalPort = 3000 diff --git a/attached_assets/Pasted--PRODUCTION-Looking-for-user-with-username-admin-PRODUCTION-Looking-for-user--1757928750586_1757928750586.txt b/attached_assets/Pasted--PRODUCTION-Looking-for-user-with-username-admin-PRODUCTION-Looking-for-user--1757928750586_1757928750586.txt new file mode 100644 index 0000000..5af2ccc --- /dev/null +++ b/attached_assets/Pasted--PRODUCTION-Looking-for-user-with-username-admin-PRODUCTION-Looking-for-user--1757928750586_1757928750586.txt @@ -0,0 +1,201 @@ + + +๐Ÿ” [PRODUCTION] Looking for user with username: admin + +๐Ÿ” [PRODUCTION] Looking for user with username: admin + +๐Ÿ” [PRODUCTION] Looking for user with username: admin_local + +๐Ÿ” [PRODUCTION] User search result: Found + +๐Ÿ” [PRODUCTION] User search result: Found + +โŒ [PRODUCTION] User not found with username: admin_local + +๐Ÿ” [PRODUCTION] User search result: Not found + +๐ŸŽฏ [PRODUCTION] Found announcements: 3 + +GET /api/announcements 304 in 84ms + +GET /api/user 304 in 5ms + +Orders API called with: { + + startDate: undefined, + + endDate: undefined, + + storeId: '1', + + userRole: 'admin' + +} + +๐Ÿ” Admin orders filtering by store: { storeId: '1', groupIds: [ 1 ], role: 'admin' } + +Fetching all orders + +Deliveries API called with: { + + startDate: undefined, + + endDate: undefined, + + storeId: '1', + + withBL: undefined, + + userRole: 'admin' + +} + +๐Ÿ” Admin deliveries filtering by store: { storeId: '1', groupIds: [ 1 ], role: 'admin' } + +Fetching all deliveries + +๐Ÿ“ข [SERVER] Fetching announcements for user: admin_local environment: production + +Customer Orders API called with: { groupIds: [ 1 ], userRole: 'admin' } + +๐Ÿ”— PRODUCTION: getOrders() rรฉcupรฉrรฉ 69 commandes avec relations + +Orders returned: 69 items + +GET /api/orders 304 in 152ms + +๐Ÿ“ข [SERVER] User found: { username: 'admin', role: 'admin' } + +๐ŸŽฏ [PRODUCTION] Using PostgreSQL DASHBOARD_MESSAGES table + +๐Ÿ”— PRODUCTION: getDeliveries() rรฉcupรฉrรฉ 97 livraisons avec relations + +Deliveries returned: 97 items + +GET /api/deliveries 200 in 187ms + +Customer Orders returned: 12 items + +๐Ÿ” [PRODUCTION] Raw messages from DB: 3 items: [ + + { + + id: 17, + + title: 'Module Avoir', + + content: "Le module d'avoir est en place", + + type: 'error', + + storeId: 1, + + createdBy: 'admin', + + createdAt: 2025-09-09T07:47:47.650Z + + }, + + { + + id: 16, + + title: 'Mise ร  jour Prix', + + content: 'Merci de mettre vos prix a jour tous les matins, certain magasin ne le font pas.', + + type: 'success', + + storeId: null, + + createdBy: 'admin', + + createdAt: 2025-08-18T10:45:08.585Z + + }, + + { + + id: 8, + + title: 'Bon de Livraison', + + content: 'Lorsque vous rentrez un numรฉro de bon de livraison, faite le a l identique, mรชme les majuscules. Pour My candy Shop, prendre le numรฉro de commande.', + + type: 'info', + + storeId: null, + + createdBy: 'admin_local', + + createdAt: 2025-08-07T11:04:38.123Z + + } + +] + +๐Ÿ” [PRODUCTION] Looking for user with username: admin + +๐Ÿ” [PRODUCTION] Looking for user with username: admin + +๐Ÿ” [PRODUCTION] Looking for user with username: admin_local + +GET /api/customer-orders 304 in 189ms + +๐Ÿ” [PRODUCTION] User search result: Found + +๐Ÿ” [PRODUCTION] User search result: Found + +๐Ÿ” [PRODUCTION] User search result: Not found + +๐ŸŽฏ [PRODUCTION] Found announcements: 3 + +โŒ [PRODUCTION] User not found with username: admin_local + +GET /api/announcements 304 in 190ms + +GET /api/groups 304 in 187ms + +GET /api/user 304 in 4ms + +๐Ÿ“‹ API PUBLICITIES REQUEST: { year: '2025', filterYear: 2025, storeId: '1', userRole: 'admin' } + +๐Ÿ“‹ CALLING storage.getPublicities: { filterYear: 2025, groupIds: [ 1 ] } + +๐Ÿ“‹ PUBLICITES FETCHED: 29 rรฉsultats pour annรฉe 2025 + +๐Ÿ” PREMIERS RESULTATS: [ + + '1. Nยฐ2501 - Blanc', + + '2. Nยฐ2502 - Moins de 1โ‚ฌ 2โ‚ฌ 3โ‚ฌ 4โ‚ฌ 5โ‚ฌ', + + '3. Nยฐ2503 - Imbattables' + +] + +๐Ÿ“‹ PUBLICITIES RETURNED: { count: 29 } + +GET /api/publicities 304 in 8ms + +๐Ÿ“‹ API PUBLICITIES REQUEST: { year: '2026', filterYear: 2026, storeId: '1', userRole: 'admin' } + +๐Ÿ“‹ CALLING storage.getPublicities: { filterYear: 2026, groupIds: [ 1 ] } + +๐Ÿ“‹ PUBLICITES FETCHED: 23 rรฉsultats pour annรฉe 2026 + +๐Ÿ” PREMIERS RESULTATS: [ + + '1. Nยฐ2601 - Blanc', + + '2. Nยฐ2602 - Catalogue', + + '3. Nยฐ2602 - Catalogue plein Air Moorea 124 pages' + +] + +๐Ÿ“‹ PUBLICITIES RETURNED: { count: 23 } + +GET /api/publicities 304 in 7ms + +HEAD /api/health 200 in 0ms \ No newline at end of file diff --git a/attached_assets/image_1757928763497.png b/attached_assets/image_1757928763497.png new file mode 100644 index 0000000..f26ff38 Binary files /dev/null and b/attached_assets/image_1757928763497.png differ diff --git a/client/src/pages/Publicities.tsx b/client/src/pages/Publicities.tsx index 67d7e9f..a54c6d2 100644 --- a/client/src/pages/Publicities.tsx +++ b/client/src/pages/Publicities.tsx @@ -94,16 +94,42 @@ export default function Publicities() { const deleteMutation = useMutation({ mutationFn: async (id: number) => { - const response = await fetch(`/api/publicities/${id}`, { method: 'DELETE' }); - if (!response.ok) { - const error = await response.json(); - throw new Error(error.message || 'Erreur lors de la suppression'); + // Try POST first (for production environments that block DELETE) + console.log(`๐Ÿ—‘๏ธ [Frontend] Attempting to delete publicity ${id} using POST method`); + + try { + const response = await fetch(`/api/publicities/${id}/delete`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({}) + }); + + if (response.ok) { + console.log(`โœ… [Frontend] Successfully deleted publicity ${id} using POST`); + return response.json(); + } else if (response.status === 404) { + // Route not found, try DELETE method as fallback (for dev environment) + console.log(`โš ๏ธ [Frontend] POST route not found, trying DELETE method`); + const deleteResponse = await fetch(`/api/publicities/${id}`, { method: 'DELETE' }); + + if (!deleteResponse.ok) { + const error = await deleteResponse.json(); + throw new Error(error.message || 'Erreur lors de la suppression'); + } + + // Handle empty response (204 No Content) + if (deleteResponse.status === 204) { + return { message: "Publicity deleted successfully" }; + } + return deleteResponse.json(); + } else { + const error = await response.json(); + throw new Error(error.message || 'Erreur lors de la suppression'); + } + } catch (error) { + console.error(`โŒ [Frontend] Failed to delete publicity ${id}:`, error); + throw error; } - // Handle empty response (204 No Content) in production - if (response.status === 204) { - return { message: "Publicity deleted successfully" }; - } - return response.json(); }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['/api/publicities'] }); diff --git a/server/routes.ts b/server/routes.ts index ee5cdcf..a191d5f 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -3563,15 +3563,44 @@ export async function registerRoutes(app: Express): Promise { } }); + // Alternative DELETE route using POST (for production environments that block DELETE) + app.post('/api/publicities/:id/delete', isAuthenticated, async (req: any, res) => { + const publicityId = req.params.id; + console.log(`๐Ÿ—‘๏ธ [API-POST] DELETE via POST request received for publicity ID: ${publicityId}`); + console.log(`๐Ÿ—‘๏ธ [API-POST] User info:`, { + hasUser: !!req.user, + userId: req.user?.id || req.user?.claims?.sub, + method: req.method, + url: req.url + }); + try { + const user = await storage.getUserWithGroups(req.user.claims ? req.user.claims.sub : req.user.id); + if (!user) { + console.log(`โŒ [API-POST] User not found for publicity deletion: ${publicityId}`); + return res.status(404).json({ message: "User not found" }); + } + console.log(`๐Ÿ—‘๏ธ [API-POST] User found:`, { id: user.id, role: user.role, name: user.name }); + // Check permissions (admin only for deletion) + if (user.role !== 'admin') { + console.log(`โŒ [API-POST] Insufficient permissions for publicity deletion: ${publicityId}, user role: ${user.role}`); + return res.status(403).json({ message: "Insufficient permissions" }); + } - - - - - + const id = parseInt(publicityId); + console.log(`๐Ÿ—‘๏ธ [API-POST] Admin ${user.name} (${user.id}) attempting to delete publicity ${id} via POST`); + + await storage.deletePublicity(id); + + console.log(`โœ… [API-POST] Successfully deleted publicity ${id} by admin ${user.name} via POST`); + res.json({ message: "Publicity deleted successfully" }); + } catch (error) { + console.error(`โŒ [API-POST] Error deleting publicity ${publicityId} via POST:`, error); + res.status(500).json({ message: "Failed to delete publicity", error: error.message }); + } + }); // Schema logging route for production debugging app.get('/api/debug/log-schema', isAuthenticated, async (req: any, res) => {