mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Sort advertisements by number on the frontend
Fixes an issue where advertisements were not consistently sorted by their publication number on the frontend by implementing a client-side sort function in `Publicities.tsx`. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 0ec86cdf-a5be-4b0e-84a3-07b926f5cc80 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/0ec86cdf-a5be-4b0e-84a3-07b926f5cc80/nmin1YE
This commit is contained in:
1 parent
172541c2b7
commit
df061adf7a
2 files changed
+18
-4
No files matched your search
@@ -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 */}
|
||||
<div className="grid grid-cols-12 gap-2">
|
||||
{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() {
|
||||
</thead>
|
||||
<tbody className="bg-white divide-y divide-gray-200">
|
||||
{publicities
|
||||
.sort((a, b) => safeCompareDate(b.startDate, a.startDate))
|
||||
.map((publicity) => {
|
||||
const now = new Date();
|
||||
const start = safeDate(publicity.startDate);
|
||||
|
||||
Reference in new issue
Block a user