feat: add bulk invite to jury group page + widen member search role filter
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m48s
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m48s
Adds bulkInviteMembers procedure to juryGroup router and integrates BulkInviteForm into the jury group members tab. Also removes the JURY_MEMBER-only filter from the user search — any user can now be added to a jury group. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { use, useState } from 'react'
|
||||
import { BulkInviteForm } from '@/components/shared/bulk-invite-form'
|
||||
import Link from 'next/link'
|
||||
import type { Route } from 'next'
|
||||
import { useRouter } from 'next/navigation'
|
||||
@@ -94,7 +95,6 @@ export default function JuryGroupDetailPage({ params }: JuryGroupDetailPageProps
|
||||
|
||||
const { data: userSearchResults, isLoading: loadingUsers } = trpc.user.list.useQuery(
|
||||
{
|
||||
role: 'JURY_MEMBER',
|
||||
search: userSearch,
|
||||
page: 1,
|
||||
perPage: 20,
|
||||
@@ -120,6 +120,14 @@ export default function JuryGroupDetailPage({ params }: JuryGroupDetailPageProps
|
||||
onError: (err) => toast.error(err.message),
|
||||
})
|
||||
|
||||
const bulkInviteMutation = trpc.juryGroup.bulkInviteMembers.useMutation({
|
||||
onSuccess: (data) => {
|
||||
utils.juryGroup.getById.invalidate({ id: groupId })
|
||||
toast.success(`${data.created} invited, ${data.existing} already existed${data.errors > 0 ? `, ${data.errors} failed` : ''}`)
|
||||
},
|
||||
onError: (err) => toast.error(err.message),
|
||||
})
|
||||
|
||||
const removeMemberMutation = trpc.juryGroup.removeMember.useMutation({
|
||||
onSuccess: () => {
|
||||
utils.juryGroup.getById.invalidate({ id: groupId })
|
||||
@@ -339,6 +347,28 @@ export default function JuryGroupDetailPage({ params }: JuryGroupDetailPageProps
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Invite New Members by Email</CardTitle>
|
||||
<CardDescription>
|
||||
Invite new users who don't have accounts yet. They'll receive an invitation email and be added to this jury group.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<BulkInviteForm
|
||||
onSubmit={async (rows) => {
|
||||
await bulkInviteMutation.mutateAsync({
|
||||
juryGroupId: groupId,
|
||||
role: 'MEMBER',
|
||||
invitees: rows.map((r) => ({ name: r.name || undefined, email: r.email })),
|
||||
})
|
||||
}}
|
||||
isPending={bulkInviteMutation.isPending}
|
||||
submitLabel="Invite & Add Members"
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
|
||||
{/* Settings Tab */}
|
||||
|
||||
Reference in New Issue
Block a user