diff --git a/src/app/(admin)/admin/rounds/[roundId]/page.tsx b/src/app/(admin)/admin/rounds/[roundId]/page.tsx index e3da6d1..b1926bc 100644 --- a/src/app/(admin)/admin/rounds/[roundId]/page.tsx +++ b/src/app/(admin)/admin/rounds/[roundId]/page.tsx @@ -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() { + {isMentoring && } )} diff --git a/src/components/admin/round/send-mentorship-welcome-button.tsx b/src/components/admin/round/send-mentorship-welcome-button.tsx new file mode 100644 index 0000000..d023a84 --- /dev/null +++ b/src/components/admin/round/send-mentorship-welcome-button.tsx @@ -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() + + 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 ( + <> + + + sendMutation.mutate({ roundId, customNote: msg })} + isSending={sendMutation.isPending} + onRefreshPreview={(msg) => setCustomMessage(msg)} + /> + + ) +}