AI category-aware evaluation: per-round config, file parsing, shortlist, advance flow
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
- Per-juror cap mode (HARD/SOFT/NONE) in add-member dialog and members table - Jury invite flow: create user + add to group + send invitation from dialog - Per-round config: notifyOnAdvance, aiParseFiles, startupAdvanceCount, conceptAdvanceCount - Moved notify-on-advance from competition-level to per-round setting - AI filtering: round-tagged files with newest-first sorting, optional file content extraction - File content extractor service (pdf-parse for PDF, utf-8 for text files) - AI shortlist runs independently per category (STARTUP / BUSINESS_CONCEPT) - generateAIRecommendations tRPC endpoint with per-round config integration - AI recommendations UI: trigger button, confirmation dialog, per-category results display - Category-aware advance dialog: select/deselect projects by category with target caps - STAGE_ACTIVE bug fix in assignment router Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { Search } from 'lucide-react'
|
||||
import { Search, UserPlus, Mail } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
import { trpc } from '@/lib/trpc/client'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select'
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
||||
|
||||
interface AddMemberDialogProps {
|
||||
juryGroupId: string
|
||||
@@ -30,10 +31,22 @@ interface AddMemberDialogProps {
|
||||
}
|
||||
|
||||
export function AddMemberDialog({ juryGroupId, open, onOpenChange }: AddMemberDialogProps) {
|
||||
const [tab, setTab] = useState<'search' | 'invite'>('search')
|
||||
|
||||
// Search existing user state
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
const [selectedUserId, setSelectedUserId] = useState<string>('')
|
||||
const [role, setRole] = useState<'CHAIR' | 'MEMBER' | 'OBSERVER'>('MEMBER')
|
||||
const [maxAssignments, setMaxAssignments] = useState<string>('')
|
||||
const [capMode, setCapMode] = useState<string>('')
|
||||
|
||||
// Invite new user state
|
||||
const [inviteName, setInviteName] = useState('')
|
||||
const [inviteEmail, setInviteEmail] = useState('')
|
||||
const [inviteRole, setInviteRole] = useState<'CHAIR' | 'MEMBER' | 'OBSERVER'>('MEMBER')
|
||||
const [inviteMaxAssignments, setInviteMaxAssignments] = useState<string>('')
|
||||
const [inviteCapMode, setInviteCapMode] = useState<string>('')
|
||||
const [inviteExpertise, setInviteExpertise] = useState('')
|
||||
|
||||
const utils = trpc.useUtils()
|
||||
|
||||
@@ -44,7 +57,7 @@ export function AddMemberDialog({ juryGroupId, open, onOpenChange }: AddMemberDi
|
||||
|
||||
const users = userResponse?.users || []
|
||||
|
||||
const { mutate: addMember, isPending } = trpc.juryGroup.addMember.useMutation({
|
||||
const { mutate: addMember, isPending: isAdding } = trpc.juryGroup.addMember.useMutation({
|
||||
onSuccess: () => {
|
||||
utils.juryGroup.getById.invalidate({ id: juryGroupId })
|
||||
toast.success('Member added successfully')
|
||||
@@ -56,14 +69,49 @@ export function AddMemberDialog({ juryGroupId, open, onOpenChange }: AddMemberDi
|
||||
},
|
||||
})
|
||||
|
||||
const { mutate: createUser, isPending: isCreating } = trpc.user.create.useMutation({
|
||||
onSuccess: (newUser) => {
|
||||
// Immediately add the newly created user to the jury group
|
||||
addMember({
|
||||
juryGroupId,
|
||||
userId: newUser.id,
|
||||
role: inviteRole,
|
||||
maxAssignmentsOverride: inviteMaxAssignments ? parseInt(inviteMaxAssignments, 10) : null,
|
||||
capModeOverride: inviteCapMode && inviteCapMode !== 'DEFAULT' ? (inviteCapMode as 'HARD' | 'SOFT' | 'NONE') : null,
|
||||
})
|
||||
// Send invitation email
|
||||
sendInvitation({ userId: newUser.id, juryGroupId })
|
||||
},
|
||||
onError: (err) => {
|
||||
toast.error(err.message)
|
||||
},
|
||||
})
|
||||
|
||||
const { mutate: sendInvitation } = trpc.user.sendInvitation.useMutation({
|
||||
onSuccess: (result) => {
|
||||
toast.success(`Invitation sent to ${result.email}`)
|
||||
},
|
||||
onError: (err) => {
|
||||
// Don't block — user was created and added, just invitation failed
|
||||
toast.error(`Member added but invitation email failed: ${err.message}`)
|
||||
},
|
||||
})
|
||||
|
||||
const resetForm = () => {
|
||||
setSearchQuery('')
|
||||
setSelectedUserId('')
|
||||
setRole('MEMBER')
|
||||
setMaxAssignments('')
|
||||
setCapMode('')
|
||||
setInviteName('')
|
||||
setInviteEmail('')
|
||||
setInviteRole('MEMBER')
|
||||
setInviteMaxAssignments('')
|
||||
setInviteCapMode('')
|
||||
setInviteExpertise('')
|
||||
}
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
const handleSearchSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
|
||||
if (!selectedUserId) {
|
||||
@@ -76,92 +124,253 @@ export function AddMemberDialog({ juryGroupId, open, onOpenChange }: AddMemberDi
|
||||
userId: selectedUserId,
|
||||
role,
|
||||
maxAssignmentsOverride: maxAssignments ? parseInt(maxAssignments, 10) : null,
|
||||
capModeOverride: capMode && capMode !== 'DEFAULT' ? (capMode as 'HARD' | 'SOFT' | 'NONE') : null,
|
||||
})
|
||||
}
|
||||
|
||||
const handleInviteSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
|
||||
if (!inviteEmail.trim()) {
|
||||
toast.error('Please enter an email address')
|
||||
return
|
||||
}
|
||||
|
||||
const expertiseTags = inviteExpertise
|
||||
.split(',')
|
||||
.map((t) => t.trim())
|
||||
.filter(Boolean)
|
||||
|
||||
createUser({
|
||||
email: inviteEmail.trim(),
|
||||
name: inviteName.trim() || undefined,
|
||||
role: 'JURY_MEMBER',
|
||||
expertiseTags: expertiseTags.length > 0 ? expertiseTags : undefined,
|
||||
maxAssignments: inviteMaxAssignments ? parseInt(inviteMaxAssignments, 10) : undefined,
|
||||
})
|
||||
}
|
||||
|
||||
const isPending = isAdding || isCreating
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogContent className="sm:max-w-lg">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Add Member to Jury Group</DialogTitle>
|
||||
<DialogDescription>
|
||||
Search for a user and assign them to this jury group
|
||||
Search for an existing user or invite a new juror to the platform
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="search">Search User</Label>
|
||||
<div className="relative">
|
||||
<Search className="absolute left-3 top-3 h-4 w-4 text-muted-foreground" />
|
||||
<Input
|
||||
id="search"
|
||||
placeholder="Search by name or email..."
|
||||
className="pl-9"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
{isSearching && (
|
||||
<p className="text-sm text-muted-foreground">Searching...</p>
|
||||
)}
|
||||
{users && users.length > 0 && (
|
||||
<div className="max-h-40 overflow-y-auto border rounded-md">
|
||||
{users.map((user) => (
|
||||
<button
|
||||
key={user.id}
|
||||
type="button"
|
||||
className={`w-full px-3 py-2 text-left text-sm hover:bg-accent ${
|
||||
selectedUserId === user.id ? 'bg-accent' : ''
|
||||
}`}
|
||||
onClick={() => {
|
||||
setSelectedUserId(user.id)
|
||||
setSearchQuery(user.email)
|
||||
}}
|
||||
>
|
||||
<div className="font-medium">{user.name || 'Unnamed User'}</div>
|
||||
<div className="text-muted-foreground text-xs">{user.email}</div>
|
||||
</button>
|
||||
))}
|
||||
<Tabs value={tab} onValueChange={(v) => setTab(v as 'search' | 'invite')}>
|
||||
<TabsList className="grid w-full grid-cols-2">
|
||||
<TabsTrigger value="search" className="flex items-center gap-2">
|
||||
<Search className="h-3.5 w-3.5" />
|
||||
Search Existing
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="invite" className="flex items-center gap-2">
|
||||
<Mail className="h-3.5 w-3.5" />
|
||||
Invite New
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
{/* Search existing user tab */}
|
||||
<TabsContent value="search">
|
||||
<form onSubmit={handleSearchSubmit} className="space-y-4 pt-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="search">Search User</Label>
|
||||
<div className="relative">
|
||||
<Search className="absolute left-3 top-3 h-4 w-4 text-muted-foreground" />
|
||||
<Input
|
||||
id="search"
|
||||
placeholder="Search by name or email..."
|
||||
className="pl-9"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
{isSearching && (
|
||||
<p className="text-sm text-muted-foreground">Searching...</p>
|
||||
)}
|
||||
{users && users.length > 0 && (
|
||||
<div className="max-h-40 overflow-y-auto border rounded-md">
|
||||
{users.map((user) => (
|
||||
<button
|
||||
key={user.id}
|
||||
type="button"
|
||||
className={`w-full px-3 py-2 text-left text-sm hover:bg-accent ${
|
||||
selectedUserId === user.id ? 'bg-accent' : ''
|
||||
}`}
|
||||
onClick={() => {
|
||||
setSelectedUserId(user.id)
|
||||
setSearchQuery(user.email)
|
||||
}}
|
||||
>
|
||||
<div className="font-medium">{user.name || 'Unnamed User'}</div>
|
||||
<div className="text-muted-foreground text-xs">{user.email}</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="role">Role</Label>
|
||||
<Select value={role} onValueChange={(val) => setRole(val as any)}>
|
||||
<SelectTrigger id="role">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="MEMBER">Member</SelectItem>
|
||||
<SelectItem value="CHAIR">Chair</SelectItem>
|
||||
<SelectItem value="OBSERVER">Observer</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="role">Group Role</Label>
|
||||
<Select value={role} onValueChange={(val) => setRole(val as typeof role)}>
|
||||
<SelectTrigger id="role">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="MEMBER">Member</SelectItem>
|
||||
<SelectItem value="CHAIR">Chair</SelectItem>
|
||||
<SelectItem value="OBSERVER">Observer</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="maxAssignments">Max Assignments Override (optional)</Label>
|
||||
<Input
|
||||
id="maxAssignments"
|
||||
type="number"
|
||||
min="1"
|
||||
placeholder="Leave empty to use group default"
|
||||
value={maxAssignments}
|
||||
onChange={(e) => setMaxAssignments(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="capMode">Cap Mode</Label>
|
||||
<Select value={capMode || 'DEFAULT'} onValueChange={setCapMode}>
|
||||
<SelectTrigger id="capMode">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="DEFAULT">Group Default</SelectItem>
|
||||
<SelectItem value="HARD">Hard Cap</SelectItem>
|
||||
<SelectItem value="SOFT">Soft Cap</SelectItem>
|
||||
<SelectItem value="NONE">No Cap</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button type="submit" disabled={isPending || !selectedUserId}>
|
||||
{isPending ? 'Adding...' : 'Add Member'}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="maxAssignments">Max Assignments Override (optional)</Label>
|
||||
<Input
|
||||
id="maxAssignments"
|
||||
type="number"
|
||||
min="1"
|
||||
placeholder="Leave empty to use group default"
|
||||
value={maxAssignments}
|
||||
onChange={(e) => setMaxAssignments(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button type="submit" disabled={isPending || !selectedUserId}>
|
||||
{isAdding ? 'Adding...' : 'Add Member'}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</TabsContent>
|
||||
|
||||
{/* Invite new user tab */}
|
||||
<TabsContent value="invite">
|
||||
<form onSubmit={handleInviteSubmit} className="space-y-4 pt-2">
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="inviteName">Full Name</Label>
|
||||
<Input
|
||||
id="inviteName"
|
||||
placeholder="Jane Doe"
|
||||
value={inviteName}
|
||||
onChange={(e) => setInviteName(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="inviteEmail">
|
||||
Email <span className="text-destructive">*</span>
|
||||
</Label>
|
||||
<Input
|
||||
id="inviteEmail"
|
||||
type="email"
|
||||
placeholder="jane@example.com"
|
||||
required
|
||||
value={inviteEmail}
|
||||
onChange={(e) => setInviteEmail(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="inviteGroupRole">Group Role</Label>
|
||||
<Select value={inviteRole} onValueChange={(val) => setInviteRole(val as typeof inviteRole)}>
|
||||
<SelectTrigger id="inviteGroupRole">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="MEMBER">Member</SelectItem>
|
||||
<SelectItem value="CHAIR">Chair</SelectItem>
|
||||
<SelectItem value="OBSERVER">Observer</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="inviteCapMode">Cap Mode</Label>
|
||||
<Select value={inviteCapMode || 'DEFAULT'} onValueChange={setInviteCapMode}>
|
||||
<SelectTrigger id="inviteCapMode">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="DEFAULT">Group Default</SelectItem>
|
||||
<SelectItem value="HARD">Hard Cap</SelectItem>
|
||||
<SelectItem value="SOFT">Soft Cap</SelectItem>
|
||||
<SelectItem value="NONE">No Cap</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="inviteMaxAssignments">Max Assignments Override (optional)</Label>
|
||||
<Input
|
||||
id="inviteMaxAssignments"
|
||||
type="number"
|
||||
min="1"
|
||||
placeholder="Leave empty to use group default"
|
||||
value={inviteMaxAssignments}
|
||||
onChange={(e) => setInviteMaxAssignments(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="inviteExpertise">Expertise Tags (optional)</Label>
|
||||
<Input
|
||||
id="inviteExpertise"
|
||||
placeholder="marine biology, policy, finance"
|
||||
value={inviteExpertise}
|
||||
onChange={(e) => setInviteExpertise(e.target.value)}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Comma-separated tags for smart assignment matching
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="rounded-md border border-blue-200 bg-blue-50 px-3 py-2">
|
||||
<p className="text-xs text-blue-700">
|
||||
<UserPlus className="mr-1 inline h-3 w-3" />
|
||||
This will create a new user account and send an invitation email to join the platform as a jury member.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button type="submit" disabled={isPending || !inviteEmail.trim()}>
|
||||
{isCreating || isAdding ? 'Creating & Inviting...' : 'Create & Invite'}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
|
||||
@@ -36,6 +36,7 @@ interface JuryMember {
|
||||
email: string
|
||||
}
|
||||
maxAssignmentsOverride: number | null
|
||||
capModeOverride: string | null
|
||||
preferredStartupRatio: number | null
|
||||
}
|
||||
|
||||
@@ -82,13 +83,14 @@ export function JuryMembersTable({ juryGroupId, members }: JuryMembersTableProps
|
||||
<TableHead>Email</TableHead>
|
||||
<TableHead className="hidden md:table-cell">Role</TableHead>
|
||||
<TableHead className="hidden sm:table-cell">Max Assignments</TableHead>
|
||||
<TableHead className="hidden lg:table-cell">Cap Mode</TableHead>
|
||||
<TableHead>Actions</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{members.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={5} className="text-center text-muted-foreground">
|
||||
<TableCell colSpan={6} className="text-center text-muted-foreground">
|
||||
No members yet. Add members to get started.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
@@ -109,6 +111,15 @@ export function JuryMembersTable({ juryGroupId, members }: JuryMembersTableProps
|
||||
<TableCell className="hidden sm:table-cell">
|
||||
{member.maxAssignmentsOverride ?? '—'}
|
||||
</TableCell>
|
||||
<TableCell className="hidden lg:table-cell">
|
||||
{member.capModeOverride ? (
|
||||
<Badge variant="outline" className="text-[10px]">
|
||||
{member.capModeOverride}
|
||||
</Badge>
|
||||
) : (
|
||||
<span className="text-muted-foreground text-xs">Group default</span>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
variant="ghost"
|
||||
|
||||
Reference in New Issue
Block a user