feat(admin): send mentorship welcome/reminder button on mentoring rounds
Adds a sky-accented "Send Welcome / Reminder" button to the Notifications grid in the round page, visible only on MENTORING rounds. Wires into trpc.mentor.previewMentorshipWelcome / sendMentorshipWelcome via the shared EmailPreviewDialog with optional custom note support. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -125,6 +125,7 @@ import { ConfigSectionHeader } from '@/components/admin/rounds/config/config-sec
|
||||
import { NotifyAdvancedButton } from '@/components/admin/round/notify-advanced-button'
|
||||
import { NotifyRejectedButton } from '@/components/admin/round/notify-rejected-button'
|
||||
import { BulkInviteButton } from '@/components/admin/round/bulk-invite-button'
|
||||
import { SendMentorshipWelcomeButton } from '@/components/admin/round/send-mentorship-welcome-button'
|
||||
import { AdvancementSummaryCard } from '@/components/admin/round/advancement-summary-card'
|
||||
import { FinalizationTab } from '@/components/admin/round/finalization-tab'
|
||||
|
||||
@@ -1442,6 +1443,7 @@ export default function RoundDetailPage() {
|
||||
<NotifyAdvancedButton roundId={roundId} />
|
||||
<NotifyRejectedButton roundId={roundId} />
|
||||
<BulkInviteButton roundId={roundId} />
|
||||
{isMentoring && <SendMentorshipWelcomeButton roundId={roundId} />}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { trpc } from '@/lib/trpc/client'
|
||||
import { toast } from 'sonner'
|
||||
import { Mail } from 'lucide-react'
|
||||
import { EmailPreviewDialog } from './email-preview-dialog'
|
||||
|
||||
interface SendMentorshipWelcomeButtonProps {
|
||||
roundId: string
|
||||
}
|
||||
|
||||
export function SendMentorshipWelcomeButton({ roundId }: SendMentorshipWelcomeButtonProps) {
|
||||
const [open, setOpen] = useState(false)
|
||||
const [customMessage, setCustomMessage] = useState<string | undefined>()
|
||||
|
||||
const preview = trpc.mentor.previewMentorshipWelcome.useQuery(
|
||||
{ roundId, customNote: customMessage },
|
||||
{ enabled: open },
|
||||
)
|
||||
|
||||
const sendMutation = trpc.mentor.sendMentorshipWelcome.useMutation({
|
||||
onSuccess: (data) => {
|
||||
toast.success(
|
||||
`Sent ${data.sent} email${data.sent !== 1 ? 's' : ''}${data.failed ? ` (${data.failed} failed)` : ''}`,
|
||||
)
|
||||
setOpen(false)
|
||||
},
|
||||
onError: (err) => toast.error(err.message),
|
||||
})
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
onClick={() => setOpen(true)}
|
||||
className="flex items-start gap-3 p-4 rounded-lg border border-l-4 border-l-sky-500 hover:-translate-y-0.5 hover:shadow-md transition-all text-left w-full"
|
||||
>
|
||||
<Mail className="h-5 w-5 text-sky-600 mt-0.5 shrink-0" />
|
||||
<div>
|
||||
<p className="text-sm font-medium">Send Welcome / Reminder</p>
|
||||
<p className="text-xs text-muted-foreground mt-0.5">
|
||||
Email all mentors & teams how to use mentorship
|
||||
</p>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<EmailPreviewDialog
|
||||
open={open}
|
||||
onOpenChange={setOpen}
|
||||
title="Send Mentorship Welcome / Reminder"
|
||||
description="Emails every mentor and team member in this round with their assignment and how to use the mentorship features. You can add an optional note below."
|
||||
recipientCount={preview.data?.recipientCount ?? 0}
|
||||
previewHtml={preview.data?.html}
|
||||
isPreviewLoading={preview.isLoading}
|
||||
onSend={(msg) => sendMutation.mutate({ roundId, customNote: msg })}
|
||||
isSending={sendMutation.isPending}
|
||||
onRefreshPreview={(msg) => setCustomMessage(msg)}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user