feat: reset to system-calculated ranking order
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m34s
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m34s
Adds a 'Reset to system order' button per category (Startups and Business Concepts). The button only appears when admins have drag-reordered that category — otherwise there's nothing to reset. Clicking it wipes that category's reorder history from the snapshot's reordersJson via a new ranking.clearReorders mutation, after which the dashboard re-initializes and falls back to the live composite ranking (balanced/raw score, optionally blended with balanced pass rate per the toggles). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -350,6 +350,15 @@ export function RankingDashboard({ competitionId: _competitionId, roundId }: Ran
|
||||
// Do NOT invalidate getSnapshot — would reset localOrder
|
||||
})
|
||||
|
||||
const clearReordersMutation = trpc.ranking.clearReorders.useMutation({
|
||||
onSuccess: () => {
|
||||
toast.success('Reverted to system-calculated order')
|
||||
initialized.current = false // allow re-init on next snapshot load
|
||||
void utils.ranking.getSnapshot.invalidate()
|
||||
},
|
||||
onError: (err) => toast.error(`Failed to reset: ${err.message}`),
|
||||
})
|
||||
|
||||
const updateRoundMutation = trpc.round.update.useMutation({
|
||||
onSuccess: () => {
|
||||
toast.success('Ranking config saved')
|
||||
@@ -953,7 +962,7 @@ export function RankingDashboard({ competitionId: _competitionId, roundId }: Ran
|
||||
{/* Per-category sections */}
|
||||
{(['STARTUP', 'BUSINESS_CONCEPT'] as const).map((category) => (
|
||||
<Card key={category}>
|
||||
<CardHeader>
|
||||
<CardHeader className="flex-row items-center justify-between space-y-0">
|
||||
<CardTitle className="text-sm font-semibold uppercase tracking-wide text-muted-foreground">
|
||||
{categoryLabels[category]}
|
||||
{evalConfig && evalConfig.advanceMode === 'threshold' && evalConfig.advanceScoreThreshold != null ? (
|
||||
@@ -966,6 +975,26 @@ export function RankingDashboard({ competitionId: _competitionId, roundId }: Ran
|
||||
</span>
|
||||
) : null}
|
||||
</CardTitle>
|
||||
{(() => {
|
||||
const reorders = (snapshot?.reordersJson as Array<{
|
||||
category: 'STARTUP' | 'BUSINESS_CONCEPT'
|
||||
}> | null) ?? []
|
||||
const hasManualOrder = reorders.some((r) => r.category === category)
|
||||
if (!hasManualOrder || !latestSnapshotId) return null
|
||||
return (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-7 text-xs"
|
||||
disabled={clearReordersMutation.isPending}
|
||||
onClick={() => clearReordersMutation.mutate({ snapshotId: latestSnapshotId, category })}
|
||||
title="Discard manual drag-reorder for this category and revert to system-calculated order"
|
||||
>
|
||||
<RefreshCw className="h-3 w-3 mr-1" />
|
||||
Reset to system order
|
||||
</Button>
|
||||
)
|
||||
})()}
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{localOrder[category].length === 0 ? (
|
||||
|
||||
Reference in New Issue
Block a user