fix: group project files by round in admin project detail
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m15s

- Sort files by round sortOrder first (via requirement.round.sortOrder)
- Admin project detail now uses grouped file view with round headers
- Files without a round requirement appear under "General" group

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 17:36:13 +01:00
parent 22731e7978
commit 6852278f92
2 changed files with 42 additions and 23 deletions

View File

@@ -816,33 +816,48 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
/>
</div>
{/* All Files list */}
{/* All Files list — grouped by round */}
{files && files.length > 0 && (
<>
<Separator />
<FileViewer
projectId={projectId}
files={files.map((f) => ({
id: f.id,
fileName: f.fileName,
fileType: f.fileType,
mimeType: f.mimeType,
size: f.size,
bucket: f.bucket,
objectKey: f.objectKey,
pageCount: f.pageCount,
textPreview: f.textPreview,
detectedLang: f.detectedLang,
langConfidence: f.langConfidence,
analyzedAt: f.analyzedAt ? String(f.analyzedAt) : null,
requirementId: f.requirementId,
requirement: f.requirement ? {
id: f.requirement.id,
name: f.requirement.name,
description: f.requirement.description,
isRequired: f.requirement.isRequired,
} : null,
}))}
groupedFiles={(() => {
const groups = new Map<string, { roundId: string | null; roundName: string; sortOrder: number; files: typeof mappedFiles }>()
const mappedFiles = files.map((f) => ({
id: f.id,
fileName: f.fileName,
fileType: f.fileType as 'EXEC_SUMMARY' | 'PRESENTATION' | 'VIDEO' | 'OTHER' | 'BUSINESS_PLAN' | 'VIDEO_PITCH' | 'SUPPORTING_DOC',
mimeType: f.mimeType,
size: f.size,
bucket: f.bucket,
objectKey: f.objectKey,
pageCount: f.pageCount,
textPreview: f.textPreview,
detectedLang: f.detectedLang,
langConfidence: f.langConfidence,
analyzedAt: f.analyzedAt ? String(f.analyzedAt) : null,
requirementId: f.requirementId,
requirement: f.requirement ? {
id: f.requirement.id,
name: f.requirement.name,
description: f.requirement.description,
isRequired: f.requirement.isRequired,
} : null,
}))
for (const f of files) {
const roundId = f.requirement?.roundId ?? null
const roundName = f.requirement?.round?.name ?? 'General'
const sortOrder = f.requirement?.round?.sortOrder ?? -1
const key = roundId ?? '_general'
if (!groups.has(key)) {
groups.set(key, { roundId, roundName, sortOrder, files: [] })
}
const mapped = mappedFiles.find((m) => m.id === f.id)!
groups.get(key)!.files.push(mapped)
}
return Array.from(groups.values())
})()}
/>
</>
)}

View File

@@ -358,7 +358,11 @@ export const fileRouter = router({
},
},
},
orderBy: [{ fileType: 'asc' }, { createdAt: 'asc' }],
orderBy: [
{ requirement: { round: { sortOrder: 'asc' } } },
{ fileType: 'asc' },
{ createdAt: 'asc' },
],
})
}),