import { useUserDeleteMutation, User } from '../../gql'

interface DeleteUserProps {
  user: User
  title?: string
}

const DeleteUserButton = ({ title, user: { id } }: DeleteUserProps) => {
  const [deleteUser, { loading, error }] = useUserDeleteMutation()
  return (
    <button
      onClick={(event: React.SyntheticEvent) => {
        deleteUser({ variables: { id } })
      }}
    >
      {title || 'Delete user'}
    </button>
  )
}

export default DeleteUserButton
