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,16 +816,18 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
/> />
</div> </div>
{/* All Files list */} {/* All Files list — grouped by round */}
{files && files.length > 0 && ( {files && files.length > 0 && (
<> <>
<Separator /> <Separator />
<FileViewer <FileViewer
projectId={projectId} projectId={projectId}
files={files.map((f) => ({ groupedFiles={(() => {
const groups = new Map<string, { roundId: string | null; roundName: string; sortOrder: number; files: typeof mappedFiles }>()
const mappedFiles = files.map((f) => ({
id: f.id, id: f.id,
fileName: f.fileName, fileName: f.fileName,
fileType: f.fileType, fileType: f.fileType as 'EXEC_SUMMARY' | 'PRESENTATION' | 'VIDEO' | 'OTHER' | 'BUSINESS_PLAN' | 'VIDEO_PITCH' | 'SUPPORTING_DOC',
mimeType: f.mimeType, mimeType: f.mimeType,
size: f.size, size: f.size,
bucket: f.bucket, bucket: f.bucket,
@@ -842,7 +844,20 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
description: f.requirement.description, description: f.requirement.description,
isRequired: f.requirement.isRequired, isRequired: f.requirement.isRequired,
} : null, } : 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' },
],
}) })
}), }),