'use client' import { useParams } from 'next/navigation' import Link from 'next/link' import { trpc } from '@/lib/trpc/client' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table' import { Skeleton } from '@/components/ui/skeleton' import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from '@/components/ui/alert-dialog' import { ArrowLeft, Plus, UserMinus } from 'lucide-react' import { toast } from 'sonner' export default function ProjectAssignmentsPage() { const params = useParams() const id = params.id as string const { data: project, isLoading: projectLoading } = trpc.project.get.useQuery({ id }) const { data: assignments = [], isLoading: assignmentsLoading } = trpc.assignment.listByProject.useQuery({ projectId: id }) const utils = trpc.useUtils() const removeAssignment = trpc.assignment.delete.useMutation({ onSuccess: () => { toast.success('Assignment removed') utils.assignment.listByProject.invalidate({ projectId: id }) }, onError: (error) => { toast.error(error.message || 'Failed to remove assignment') }, }) // Remove handled via AlertDialog in JSX const isLoading = projectLoading || assignmentsLoading if (isLoading) { return (
{project?.title}