'use client'

import { removeMember } from '../../actions'
import { useState } from 'react'

export function MemberActions({ member, orgId }: { member: { id: string, name: string }, orgId: string }) {
    const [isPending, setIsPending] = useState(false)

    const handleRemove = async () => {
        if (!confirm(`Möchten Sie das Mitglied ${member.name} wirklich entfernen?`)) return
        setIsPending(true)
        await removeMember(member.id, orgId)
        setIsPending(false)
    }

    return (
        <button
            onClick={handleRemove}
            disabled={isPending}
            className="text-xs text-red-600 hover:text-red-700 font-medium transition-colors"
        >
            Entfernen
        </button>
    )
}
