Skip to content

Commit dbf062c

Browse files
committed
kiss
1 parent 797f335 commit dbf062c

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

src/components/CippWizard/CippWizardConfirmation.jsx

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,42 @@ export const CippWizardConfirmation = (props) => {
5252
!["user", "userPrincipalName", "username"].includes(key)
5353
);
5454

55-
// Dynamically split entries based on columns prop
55+
// Calculate total entries including special ones for even distribution
56+
const totalEntries = filteredEntries.length + (tenantEntry ? 1 : 0) + (userEntry ? 1 : 0);
57+
58+
// Dynamically split entries based on columns prop with special entries distributed
5659
const splitEntries = () => {
57-
const entriesPerColumn = Math.ceil(filteredEntries.length / columns);
58-
const result = [];
59-
60-
for (let i = 0; i < columns; i++) {
61-
const start = i * entriesPerColumn;
62-
const end = start + entriesPerColumn;
63-
result.push(filteredEntries.slice(start, end));
60+
const result = Array.from({ length: columns }, () => []);
61+
62+
// Add special entries to different columns first
63+
if (tenantEntry) {
64+
result[0].push(tenantEntry);
6465
}
65-
66+
if (userEntry && result[1]) {
67+
result[1].push(userEntry);
68+
}
69+
70+
// Distribute remaining entries across columns to balance them
71+
filteredEntries.forEach((entry) => {
72+
// Find the column with the fewest entries
73+
let targetColumn = 0;
74+
let minLength = result[0].length;
75+
76+
for (let i = 1; i < columns; i++) {
77+
if (result[i].length < minLength) {
78+
minLength = result[i].length;
79+
targetColumn = i;
80+
}
81+
}
82+
83+
result[targetColumn].push(entry);
84+
});
85+
6686
return result;
6787
};
6888

6989
const columnEntries = splitEntries();
7090

71-
// Distribute special entries across first available columns
72-
if (tenantEntry && columnEntries[0]) {
73-
columnEntries[0].unshift(tenantEntry);
74-
}
75-
if (userEntry && columnEntries[1]) {
76-
columnEntries[1].unshift(userEntry);
77-
}
78-
7991
// Calculate Grid sizes based on number of columns
8092
const getGridSize = () => {
8193
const sizes = {

0 commit comments

Comments
 (0)