diff --git a/src/app/(pages)/(main)/category/sub-page/CategoryPage.tsx b/src/app/(pages)/(main)/category/sub-page/CategoryPage.tsx index 6514e7c..6072fe1 100644 --- a/src/app/(pages)/(main)/category/sub-page/CategoryPage.tsx +++ b/src/app/(pages)/(main)/category/sub-page/CategoryPage.tsx @@ -68,26 +68,31 @@ const CategoryPage = () => { const years = Array.from(new Set(rows.map((row) => Number(row.year)))) .filter((year) => Number.isFinite(year)) .sort((a, b) => b - a) - .slice(0, 2); + .slice(0, -1); - if (years.length < 2) { + if(years.length === 0) { nextMap[f.requestKeyResolved] = rows; return; } - const [currentYear, prevYear] = years; - const gapRow = buildGapRow(rows, prevYear, currentYear, "LG"); + const gapRowsByYear = new Map(); - if (!gapRow) { - nextMap[f.requestKeyResolved] = rows; - return; - } + years.forEach((year) => { + const currentYear = year; + const prevYear = year - 1; + const gapRow = buildGapRow(rows, prevYear, currentYear, "LG"); + + if(gapRow !== null){ + gapRowsByYear.set(currentYear, gapRow); + } + }); const nextRows: BannerRow[] = []; rows.forEach((row) => { nextRows.push(row); - if (Number(row.year) === currentYear && row.rowLabel === "LG") { + const gapRow = gapRowsByYear.get(Number(row.year)); + if (row.rowLabel === "LG" && gapRow) { nextRows.push(gapRow); } });