Sort stage items (#324)

This commit is contained in:
Erik Vroon
2023-11-08 17:24:38 +01:00
committed by GitHub
parent 5c78ee922f
commit a76abc9364
2 changed files with 23 additions and 19 deletions

View File

@@ -155,16 +155,18 @@ export default function Brackets({
const stages_map = Object.fromEntries(
swrStagesResponse.data.data.map((x: StageWithStageItems) => [x.id, x])
);
const rounds = stages_map[selectedStageId].stage_items.map((stageItem: StageItemWithRounds) =>
getRoundsGridCols(
stageItem,
tournamentData,
swrStagesResponse,
swrCourtsResponse,
swrUpcomingMatchesResponse,
readOnly
)
);
const rounds = stages_map[selectedStageId].stage_items
.sort((i1: StageItemWithRounds, i2: StageItemWithRounds) => (i1.name > i2.name ? 1 : 0))
.map((stageItem: StageItemWithRounds) =>
getRoundsGridCols(
stageItem,
tournamentData,
swrStagesResponse,
swrCourtsResponse,
swrUpcomingMatchesResponse,
readOnly
)
);
return (
<div>

View File

@@ -140,15 +140,17 @@ function StageColumn({
return null;
}
const rows = stage.stage_items.map((stageItem: StageItemWithRounds) => (
<StageItemRow
key={stageItem.id}
teamsMap={teamsMap}
tournament={tournament}
stageItem={stageItem}
swrStagesResponse={swrStagesResponse}
/>
));
const rows = stage.stage_items
.sort((i1: StageItemWithRounds, i2: StageItemWithRounds) => (i1.name > i2.name ? 1 : 0))
.map((stageItem: StageItemWithRounds) => (
<StageItemRow
key={stageItem.id}
teamsMap={teamsMap}
tournament={tournament}
stageItem={stageItem}
swrStagesResponse={swrStagesResponse}
/>
));
return (
<Grid.Col mb="1rem" sm={6} lg={4} xl={3} key={stage.id}>