2021-06-10 19:25:14 +02:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import Link from 'next/link'
|
2022-02-03 01:59:49 +04:00
|
|
|
import {signIn} from 'next-auth/react'
|
2022-01-19 07:06:26 +04:00
|
|
|
import {Button} from '@mui/material'
|
2021-06-10 19:25:14 +02:00
|
|
|
|
2021-06-26 12:20:16 +02:00
|
|
|
export default function LoginProvider({id, title, icon, callbackUrl}) {
|
2021-06-10 19:25:14 +02:00
|
|
|
const hanleClick = event => {
|
|
|
|
|
event.preventDefault()
|
2021-06-26 12:20:16 +02:00
|
|
|
signIn(id, {
|
|
|
|
|
callbackUrl
|
|
|
|
|
})
|
2021-06-10 19:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2022-01-18 09:08:26 +04:00
|
|
|
<Link passHref href='/api/auth/signin'>
|
2021-06-10 19:25:14 +02:00
|
|
|
<Button
|
|
|
|
|
variant='contained'
|
|
|
|
|
color='primary'
|
|
|
|
|
startIcon={icon}
|
|
|
|
|
onClick={hanleClick}
|
|
|
|
|
>
|
2022-01-27 22:51:49 +04:00
|
|
|
{title} connexion
|
2021-06-10 19:25:14 +02:00
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LoginProvider.propTypes = {
|
|
|
|
|
id: PropTypes.string.isRequired,
|
|
|
|
|
title: PropTypes.string.isRequired,
|
2021-06-26 12:20:16 +02:00
|
|
|
icon: PropTypes.node.isRequired,
|
|
|
|
|
callbackUrl: PropTypes.string.isRequired
|
2021-06-10 19:25:14 +02:00
|
|
|
}
|