- {/* Render all but the last row of stats normally */}
- {stats.slice(0, totalStats - remainingItems).map((stat) => (
-
- {stat.create(playerScore)}
-
- ))}
+ {Array.from({ length: numRows }).map((_, rowIndex) => {
+ const startIndex = rowIndex * itemsPerRow;
+ const endIndex = startIndex + itemsPerRow;
+ const rowStats = stats.slice(startIndex, endIndex);
+ const emptySpaces = itemsPerRow - rowStats.length;
- {/* Handle the last row - align right and push empty spaces to the left */}
-
- {Array(emptySpaces)
- .fill(null)
- .map((_, index) => (
-
- ))}
- {stats.slice(totalStats - remainingItems).map((stat) => (
-
- {stat.create(playerScore)}
+ return (
+
+ {rowIndex === numRows - 1 &&
+ emptySpaces > 0 &&
+ Array(emptySpaces)
+ .fill(null)
+ .map((_, index) =>
)}
+ {rowStats.map((stat) => (
+
+
+
+ ))}
- ))}
-
+ );
+ })}
);
}