260401_02_ENH: 브랜드의 gap 부분 2개 연도 나올수 있도록 수정
This commit is contained in:
@@ -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<number, BannerRow>();
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user