fix: ranking reorders persist across all admin sessions
All checks were successful
Build and Push Docker Image / build (push) Successful in 9m49s
All checks were successful
Build and Push Docker Image / build (push) Successful in 9m49s
Apply saved reordersJson when initializing the dashboard so any admin sees the latest drag-reorder state, not just the original AI order. The latest reorder event per category is used as the initial localOrder. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -406,15 +406,28 @@ export function RankingDashboard({ competitionId: _competitionId, roundId }: Ran
|
|||||||
if (!initialized.current && snapshot) {
|
if (!initialized.current && snapshot) {
|
||||||
const startup = (snapshot.startupRankingJson ?? []) as unknown as RankedProjectEntry[]
|
const startup = (snapshot.startupRankingJson ?? []) as unknown as RankedProjectEntry[]
|
||||||
const concept = (snapshot.conceptRankingJson ?? []) as unknown as RankedProjectEntry[]
|
const concept = (snapshot.conceptRankingJson ?? []) as unknown as RankedProjectEntry[]
|
||||||
setLocalOrder({
|
|
||||||
STARTUP: startup.map((r) => r.projectId),
|
// Track original AI order for override detection (same effect = always in sync)
|
||||||
BUSINESS_CONCEPT: concept.map((r) => r.projectId),
|
|
||||||
})
|
|
||||||
// Track original order for override detection (same effect = always in sync)
|
|
||||||
const order: Record<string, number> = {}
|
const order: Record<string, number> = {}
|
||||||
startup.forEach((r, i) => { order[r.projectId] = i + 1 })
|
startup.forEach((r, i) => { order[r.projectId] = i + 1 })
|
||||||
concept.forEach((r, i) => { order[r.projectId] = i + 1 })
|
concept.forEach((r, i) => { order[r.projectId] = i + 1 })
|
||||||
setSnapshotOrder(order)
|
setSnapshotOrder(order)
|
||||||
|
|
||||||
|
// Apply saved reorders so the ranking persists across all admin sessions.
|
||||||
|
// reordersJson is append-only — the latest event per category is the current order.
|
||||||
|
const reorders = (snapshot.reordersJson as Array<{
|
||||||
|
category: 'STARTUP' | 'BUSINESS_CONCEPT'
|
||||||
|
orderedProjectIds: string[]
|
||||||
|
}> | null) ?? []
|
||||||
|
|
||||||
|
const latestStartupReorder = [...reorders].reverse().find((r) => r.category === 'STARTUP')
|
||||||
|
const latestConceptReorder = [...reorders].reverse().find((r) => r.category === 'BUSINESS_CONCEPT')
|
||||||
|
|
||||||
|
setLocalOrder({
|
||||||
|
STARTUP: latestStartupReorder?.orderedProjectIds ?? startup.map((r) => r.projectId),
|
||||||
|
BUSINESS_CONCEPT: latestConceptReorder?.orderedProjectIds ?? concept.map((r) => r.projectId),
|
||||||
|
})
|
||||||
|
|
||||||
initialized.current = true
|
initialized.current = true
|
||||||
}
|
}
|
||||||
}, [snapshot])
|
}, [snapshot])
|
||||||
|
|||||||
Reference in New Issue
Block a user