fix: save roundId on admin file upload and group assignments by round
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m45s
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m45s
The admin upload flow accepted roundId but never wrote it to the ProjectFile record, causing all admin-uploaded files to appear under "General". Fixed the create call, the listByProject filter, and the listByProjectForStage grouping to also use the direct roundId field. Jury assignments on the project detail page are now grouped by round with per-round completion counts instead of a flat list. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -845,9 +845,10 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
|
|||||||
} : null,
|
} : null,
|
||||||
}))
|
}))
|
||||||
for (const f of files) {
|
for (const f of files) {
|
||||||
const roundId = f.requirement?.roundId ?? null
|
const roundId = f.requirement?.roundId ?? f.roundId ?? null
|
||||||
const roundName = f.requirement?.round?.name ?? 'General'
|
const matchedRound = roundId ? competitionRounds.find((r: any) => r.id === roundId) : null
|
||||||
const sortOrder = f.requirement?.round?.sortOrder ?? -1
|
const roundName = f.requirement?.round?.name ?? matchedRound?.name ?? 'General'
|
||||||
|
const sortOrder = f.requirement?.round?.sortOrder ?? matchedRound?.sortOrder ?? -1
|
||||||
const key = roundId ?? '_general'
|
const key = roundId ?? '_general'
|
||||||
if (!groups.has(key)) {
|
if (!groups.has(key)) {
|
||||||
groups.set(key, { roundId, roundName, sortOrder, files: [] })
|
groups.set(key, { roundId, roundName, sortOrder, files: [] })
|
||||||
@@ -864,8 +865,25 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
|
|||||||
</Card>
|
</Card>
|
||||||
</AnimatedCard>
|
</AnimatedCard>
|
||||||
|
|
||||||
{/* Assignments Section */}
|
{/* Assignments Section — grouped by round */}
|
||||||
{assignments && assignments.length > 0 && (
|
{assignments && assignments.length > 0 && (() => {
|
||||||
|
// Group assignments by round
|
||||||
|
const roundGroups = new Map<string, {
|
||||||
|
roundId: string
|
||||||
|
roundName: string
|
||||||
|
assignments: typeof assignments
|
||||||
|
}>()
|
||||||
|
for (const a of assignments) {
|
||||||
|
const rId = a.round?.id ?? '_unknown'
|
||||||
|
const rName = a.round?.name ?? 'Unknown Round'
|
||||||
|
if (!roundGroups.has(rId)) {
|
||||||
|
roundGroups.set(rId, { roundId: rId, roundName: rName, assignments: [] })
|
||||||
|
}
|
||||||
|
roundGroups.get(rId)!.assignments.push(a)
|
||||||
|
}
|
||||||
|
const groups = Array.from(roundGroups.values())
|
||||||
|
|
||||||
|
return (
|
||||||
<AnimatedCard index={5}>
|
<AnimatedCard index={5}>
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
@@ -880,7 +898,7 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
|
|||||||
<CardDescription>
|
<CardDescription>
|
||||||
{assignments.filter((a) => a.evaluation?.status === 'SUBMITTED')
|
{assignments.filter((a) => a.evaluation?.status === 'SUBMITTED')
|
||||||
.length}{' '}
|
.length}{' '}
|
||||||
of {assignments.length} evaluations completed
|
of {assignments.length} evaluations completed across {groups.length} round{groups.length !== 1 ? 's' : ''}
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
</div>
|
</div>
|
||||||
<Button variant="outline" size="sm" asChild>
|
<Button variant="outline" size="sm" asChild>
|
||||||
@@ -890,7 +908,17 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent className="space-y-6">
|
||||||
|
{groups.map((group) => {
|
||||||
|
const submitted = group.assignments.filter((a) => a.evaluation?.status === 'SUBMITTED').length
|
||||||
|
return (
|
||||||
|
<div key={group.roundId}>
|
||||||
|
<div className="flex items-center justify-between mb-2">
|
||||||
|
<h4 className="text-sm font-semibold">{group.roundName}</h4>
|
||||||
|
<span className="text-xs text-muted-foreground">
|
||||||
|
{submitted} of {group.assignments.length} completed
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -903,7 +931,7 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{assignments.map((assignment) => (
|
{group.assignments.map((assignment) => (
|
||||||
<TableRow
|
<TableRow
|
||||||
key={assignment.id}
|
key={assignment.id}
|
||||||
className={assignment.evaluation?.status === 'SUBMITTED' ? 'cursor-pointer hover:bg-muted/50' : ''}
|
className={assignment.evaluation?.status === 'SUBMITTED' ? 'cursor-pointer hover:bg-muted/50' : ''}
|
||||||
@@ -995,10 +1023,14 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
|
|||||||
))}
|
))}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</AnimatedCard>
|
</AnimatedCard>
|
||||||
)}
|
)
|
||||||
|
})()}
|
||||||
|
|
||||||
{/* Evaluation Detail Sheet */}
|
{/* Evaluation Detail Sheet */}
|
||||||
<EvaluationEditSheet
|
<EvaluationEditSheet
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ export function MultiWindowDocViewer({ roundId, projectId }: MultiWindowDocViewe
|
|||||||
}> = {}
|
}> = {}
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const roundName = file.requirement?.round?.name ?? 'General'
|
const rId = file.requirement?.round?.id ?? (file as any).roundId ?? null
|
||||||
const rId = file.requirement?.round?.id ?? null
|
const roundName = file.requirement?.round?.name ?? (rId ? 'Round Files' : 'General')
|
||||||
const sortOrder = file.requirement?.round?.sortOrder ?? 999
|
const sortOrder = file.requirement?.round?.sortOrder ?? 999
|
||||||
if (!groupMap[roundName]) {
|
if (!groupMap[roundName]) {
|
||||||
groupMap[roundName] = { roundId: rId, roundName, sortOrder, files: [] }
|
groupMap[roundName] = { roundId: rId, roundName, sortOrder, files: [] }
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ export const fileRouter = router({
|
|||||||
const file = await ctx.prisma.projectFile.create({
|
const file = await ctx.prisma.projectFile.create({
|
||||||
data: {
|
data: {
|
||||||
projectId: input.projectId,
|
projectId: input.projectId,
|
||||||
|
roundId: input.roundId ?? null,
|
||||||
fileType: input.fileType,
|
fileType: input.fileType,
|
||||||
fileName: input.fileName,
|
fileName: input.fileName,
|
||||||
mimeType: input.mimeType,
|
mimeType: input.mimeType,
|
||||||
@@ -341,7 +342,10 @@ export const fileRouter = router({
|
|||||||
|
|
||||||
const where: Record<string, unknown> = { projectId: input.projectId }
|
const where: Record<string, unknown> = { projectId: input.projectId }
|
||||||
if (input.roundId) {
|
if (input.roundId) {
|
||||||
where.requirement = { roundId: input.roundId }
|
where.OR = [
|
||||||
|
{ requirement: { roundId: input.roundId } },
|
||||||
|
{ roundId: input.roundId, requirementId: null },
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.prisma.projectFile.findMany({
|
return ctx.prisma.projectFile.findMany({
|
||||||
@@ -429,7 +433,8 @@ export const fileRouter = router({
|
|||||||
projectId: input.projectId,
|
projectId: input.projectId,
|
||||||
OR: [
|
OR: [
|
||||||
{ requirement: { roundId: { in: eligibleRoundIds } } },
|
{ requirement: { roundId: { in: eligibleRoundIds } } },
|
||||||
{ requirementId: null },
|
{ roundId: { in: eligibleRoundIds }, requirementId: null },
|
||||||
|
{ roundId: null, requirementId: null },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
@@ -454,7 +459,8 @@ export const fileRouter = router({
|
|||||||
files: typeof files
|
files: typeof files
|
||||||
}> = []
|
}> = []
|
||||||
|
|
||||||
const generalFiles = files.filter((f) => !f.requirementId)
|
// Files with no round association at all go to General
|
||||||
|
const generalFiles = files.filter((f) => !f.requirementId && !f.roundId)
|
||||||
if (generalFiles.length > 0) {
|
if (generalFiles.length > 0) {
|
||||||
grouped.push({
|
grouped.push({
|
||||||
roundId: null,
|
roundId: null,
|
||||||
@@ -465,7 +471,9 @@ export const fileRouter = router({
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const round of eligibleRounds) {
|
for (const round of eligibleRounds) {
|
||||||
const roundFiles = files.filter((f) => f.requirement?.roundId === round.id)
|
const roundFiles = files.filter(
|
||||||
|
(f) => f.requirement?.roundId === round.id || (!f.requirementId && f.roundId === round.id)
|
||||||
|
)
|
||||||
if (roundFiles.length > 0) {
|
if (roundFiles.length > 0) {
|
||||||
grouped.push({
|
grouped.push({
|
||||||
roundId: round.id,
|
roundId: round.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user