Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

1.1 KB
Raw Blame
'use client';

import { MailCheck } from 'lucide-react';
import { toast } from 'sonner';
import { useTranslations } from 'next-intl';
import { Button } from '@/components/ui/button';
import { useVerifyInstanceUserEmail } from '../../services/god.service';

// Confirms an account's email address on the owner's behalf, for a user who cannot
// open the confirmation link (no mail provider, a lost message, a manual signup).
export default function GodUserVerifyButton({ userId }: { userId: string }) {
  const t = useTranslations('god.userPanel');
  const verify = useVerifyInstanceUserEmail();

  async function run() {
    try {
      await verify.mutateAsync(userId);
      toast.success(t('verifyDone'));
    } catch {
      // The failure already surfaced through the global mutation error toast.
    }
  }

  return (
    <Button
      variant="outline"
      size="sm"
      disabled={verify.isPending}
      onClick={(e) => {
        e.stopPropagation();
        void run();
      }}
    >
      <MailCheck />
      {verify.isPending ? t('verifying') : t('verify')}
    </Button>
  );
}