feat: mentor self-drop dialog on project detail page

DropAssignmentDialog with required reason (10-1000 chars) calls
mentor.dropAssignment, redirects to /mentor on success. Button surfaces
in the project header only when the viewer is the assigned mentor and
the assignment is neither dropped nor completed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt
2026-04-28 18:48:09 +02:00
parent 3bc1cc14c7
commit 3d8aab46f1
2 changed files with 128 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
import { Suspense, use, useState, useEffect } from 'react'
import { useRouter } from 'next/navigation'
import { useSession } from 'next-auth/react'
import { trpc } from '@/lib/trpc/client'
import {
Card,
@@ -31,6 +32,7 @@ import { AnimatedCard } from '@/components/shared/animated-container'
import { FileViewer } from '@/components/shared/file-viewer'
import { MentorChat } from '@/components/shared/mentor-chat'
import { ProjectLogoWithUrl } from '@/components/shared/project-logo-with-url'
import { DropAssignmentDialog } from '@/components/mentor/drop-assignment-dialog'
import {
ArrowLeft,
AlertCircle,
@@ -76,6 +78,7 @@ const statusColors: Record<string, 'default' | 'secondary' | 'destructive' | 'ou
function ProjectDetailContent({ projectId }: { projectId: string }) {
const router = useRouter()
const { data: session } = useSession()
const { data: project, isLoading, error } = trpc.mentor.getProjectDetail.useQuery({
projectId,
})
@@ -132,8 +135,15 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
const teamLead = project.teamMembers?.find((m) => m.role === 'LEAD')
const otherMembers = project.teamMembers?.filter((m) => m.role !== 'LEAD') || []
const mentorAssignmentId = project.mentorAssignment?.id
const mentorAssignment = project.mentorAssignment
const mentorAssignmentId = mentorAssignment?.id
const programId = project.program?.id
const viewerIsAssignedMentor =
!!mentorAssignment && session?.user?.id === mentorAssignment.mentor?.id
const canDrop =
viewerIsAssignedMentor &&
!mentorAssignment.droppedAt &&
mentorAssignment.completionStatus !== 'completed'
return (
<div className="space-y-6">
@@ -179,6 +189,12 @@ function ProjectDetailContent({ projectId }: { projectId: string }) {
)}
</div>
</div>
{canDrop && mentorAssignmentId && (
<DropAssignmentDialog
assignmentId={mentorAssignmentId}
projectTitle={project.title}
/>
)}
</div>
{project.assignedAt && (