fix: group project files by round in admin project detail
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m15s
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:
@@ -816,16 +816,18 @@ 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) => ({
|
||||
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,
|
||||
fileType: f.fileType as 'EXEC_SUMMARY' | 'PRESENTATION' | 'VIDEO' | 'OTHER' | 'BUSINESS_PLAN' | 'VIDEO_PITCH' | 'SUPPORTING_DOC',
|
||||
mimeType: f.mimeType,
|
||||
size: f.size,
|
||||
bucket: f.bucket,
|
||||
@@ -842,7 +844,20 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
|
||||
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())
|
||||
})()}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -358,7 +358,11 @@ export const fileRouter = router({
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: [{ fileType: 'asc' }, { createdAt: 'asc' }],
|
||||
orderBy: [
|
||||
{ requirement: { round: { sortOrder: 'asc' } } },
|
||||
{ fileType: 'asc' },
|
||||
{ createdAt: 'asc' },
|
||||
],
|
||||
})
|
||||
}),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user