diff --git a/attached_assets/{C1883300-1265-40A5-9139-33AC2146D78A}_1755774788638.png b/attached_assets/{C1883300-1265-40A5-9139-33AC2146D78A}_1755774788638.png new file mode 100644 index 0000000..7f9df08 Binary files /dev/null and b/attached_assets/{C1883300-1265-40A5-9139-33AC2146D78A}_1755774788638.png differ diff --git a/client/src/pages/Publicities.tsx b/client/src/pages/Publicities.tsx index a7b842e..d48bea9 100644 --- a/client/src/pages/Publicities.tsx +++ b/client/src/pages/Publicities.tsx @@ -52,7 +52,22 @@ export default function Publicities() { } const data = await response.json(); console.log('📢 Publicities received:', data.length, 'items', data.slice(0, 2)); - return Array.isArray(data) ? data : []; + + // CRITICAL FIX: Force frontend sorting by pubNumber to ensure correct order + const sortedData = Array.isArray(data) + ? data.sort((a, b) => { + const numA = parseInt(a.pubNumber) || 0; + const numB = parseInt(b.pubNumber) || 0; + return numA - numB; + }) + : []; + + console.log('📢 Publicities after frontend sort:', { + first5: sortedData.slice(0, 5).map(p => `N°${p.pubNumber}`), + total: sortedData.length + }); + + return sortedData; }, }); @@ -107,7 +122,7 @@ export default function Publicities() { // Generate month options const monthOptions = Array.from({ length: 12 }, (_, i) => ({ value: i, - label: format(new Date(2024, i, 1), 'MMMM', { locale: fr }) + label: format(new Date(selectedYear, i, 1), 'MMMM', { locale: fr }) })); // Calendar helper functions @@ -413,7 +428,7 @@ export default function Publicities() { {/* Months Grid */}
{Array.from({ length: 12 }, (_, monthIndex) => { - const monthName = format(new Date(2024, monthIndex, 1), 'MMM', { locale: fr }); + const monthName = format(new Date(selectedYear, monthIndex, 1), 'MMM', { locale: fr }); const monthWeeks = yearWeeks.filter(week => week.month === monthIndex); return ( @@ -683,7 +698,6 @@ export default function Publicities() { {publicities - .sort((a, b) => safeCompareDate(b.startDate, a.startDate)) .map((publicity) => { const now = new Date(); const start = safeDate(publicity.startDate);