'use client'

import { trpc } from '@/lib/trpc-client'
import { useRouter } from 'next/navigation'

export function DeactivateButton({ id }: { id: string }) {
  const router = useRouter()
  const mutation = trpc.stellen.deactivate.useMutation({
    onSuccess: () => router.refresh(),
  })

  return (
    <button
      onClick={() => mutation.mutate({ id })}
      disabled={mutation.isPending}
      className="text-sm text-red-600 hover:underline disabled:opacity-50"
    >
      Deaktivieren
    </button>
  )
}
