import PropTypes from 'prop-types'
import Link from 'next/link'
import {signIn} from 'next-auth/client'
import {Button} from '@material-ui/core'

export default function LoginProvider({id, title, icon, callbackUrl}) {
  const hanleClick = event => {
    event.preventDefault()
    signIn(id, {
      callbackUrl
    })
  }

  return (
    <Link href='/api/auth/signin'>
      <Button
        variant='contained'
        color='primary'
        startIcon={icon}
        onClick={hanleClick}
      >
        {title} koneksyon
      </Button>
    </Link>
  )
}

LoginProvider.propTypes = {
  id: PropTypes.string.isRequired,
  title: PropTypes.string.isRequired,
  icon: PropTypes.node.isRequired,
  callbackUrl: PropTypes.string.isRequired
}
