feat(final-docs): mentor.getProjectFinalDocuments procedure
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -50,6 +50,7 @@ import {
|
||||
signMentorUploadToken,
|
||||
verifyMentorUploadToken,
|
||||
} from '@/lib/mentor-upload-token'
|
||||
import { getFinalDocumentStatusForProject } from '../services/final-documents'
|
||||
|
||||
/**
|
||||
* True if the project is enrolled in a MENTORING round that is still
|
||||
@@ -215,6 +216,21 @@ async function assertProjectWorkspaceAccess(
|
||||
}
|
||||
|
||||
export const mentorRouter = router({
|
||||
/** Grand-final document status for a project, for the mentor workspace panel. */
|
||||
getProjectFinalDocuments: protectedProcedure
|
||||
.input(z.object({ projectId: z.string() }))
|
||||
.query(async ({ ctx, input }) => {
|
||||
const isAdmin = ['SUPER_ADMIN', 'PROGRAM_ADMIN'].includes(ctx.user.role)
|
||||
if (!isAdmin) {
|
||||
const [mentorAssignment, teamMembership] = await Promise.all([
|
||||
ctx.prisma.mentorAssignment.findFirst({ where: { mentorId: ctx.user.id, projectId: input.projectId }, select: { id: true } }),
|
||||
ctx.prisma.teamMember.findFirst({ where: { userId: ctx.user.id, projectId: input.projectId }, select: { id: true } }),
|
||||
])
|
||||
if (!mentorAssignment && !teamMembership) throw new TRPCError({ code: 'FORBIDDEN', message: 'No access to this project' })
|
||||
}
|
||||
return getFinalDocumentStatusForProject(ctx.prisma, input.projectId)
|
||||
}),
|
||||
|
||||
/**
|
||||
* Get AI-suggested mentor matches for a project
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user