From e627ff650d8bb760963d02b04bb3706f96e16b87 Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Mon, 11 Aug 2025 21:56:18 +0000 Subject: [PATCH] Show relevant advertisements on the calendar based on store participation Update client-side filtering logic to correctly display advertisements based on selected store or user group affiliations, and adjust backend query to fetch participation data. Replit-Commit-Author: Agent Replit-Commit-Session-Id: b163d4c0-de5e-4f4e-a9c0-aed4c7049718 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/b163d4c0-de5e-4f4e-a9c0-aed4c7049718/ByygiiM --- client/src/components/CalendarGrid.tsx | 25 ++++++++++++++++++++++--- server/storage.ts | 22 +++++++++++++++++++--- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/client/src/components/CalendarGrid.tsx b/client/src/components/CalendarGrid.tsx index d705b8c..61b7836 100644 --- a/client/src/components/CalendarGrid.tsx +++ b/client/src/components/CalendarGrid.tsx @@ -178,6 +178,17 @@ export default function CalendarGrid({ const getPublicitiesForDate = (date: Date) => { const dateStr = format(date, 'yyyy-MM-dd'); + console.log('🔍 CalendarGrid getPublicitiesForDate:', { + date: dateStr, + totalPublicities: publicities.length, + selectedStoreId, + userGroups: userGroups.length + }); + + if (publicities.length > 0) { + console.log('📄 Sample publicity structure:', publicities[0]); + } + return publicities.filter(pub => { // Check if the date is within the publicity period const pubStart = pub.startDate; @@ -194,14 +205,22 @@ export default function CalendarGrid({ // If a specific store is selected, check if that store participates if (selectedStoreId) { - return pub.participatingGroups?.some((pg: any) => pg.groupId === selectedStoreId); + const matches = pub.participations?.some((pg: any) => pg.groupId === selectedStoreId); + if (matches) { + console.log('🎯 Publicity matches selected store:', { pubNumber: pub.pubNumber, selectedStoreId }); + } + return matches; } // If no specific store selected but user has assigned stores, // show publicities where any of user's stores participate if (userGroups && userGroups.length > 0) { const userGroupIds = userGroups.map((ug: any) => ug.groupId); - return pub.participatingGroups?.some((pg: any) => userGroupIds.includes(pg.groupId)); + const matches = pub.participations?.some((pg: any) => userGroupIds.includes(pg.groupId)); + if (matches) { + console.log('👥 Publicity matches user groups:', { pubNumber: pub.pubNumber, userGroupIds }); + } + return matches; } return true; @@ -358,7 +377,7 @@ export default function CalendarGrid({