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

interface DeleteUserProps {
  user: User
  title?: string
}

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

export default DeleteUserButton