Files
pawol.nu/components/sesyon/login-provider.js
T

42 lines
1.0 KiB
JavaScript
Raw Normal View History

2021-06-10 19:25:14 +02:00
import PropTypes from 'prop-types'
import Link from 'next/link'
2022-10-26 00:33:01 +04:00
import Image from 'next/image'
2022-02-03 01:59:49 +04:00
import {signIn} from 'next-auth/react'
2022-10-28 08:28:35 +04:00
import {useTheme} from '@mui/material/styles'
2022-10-31 23:01:33 +04:00
import Button from '@mui/material/Button'
2021-06-10 19:25:14 +02:00
2022-10-26 00:33:01 +04:00
export default function LoginProvider({id, title, width, height, callbackUrl}) {
2022-10-28 08:28:35 +04:00
const theme = useTheme()
2021-06-10 19:25:14 +02:00
const hanleClick = event => {
event.preventDefault()
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'>
2023-07-14 19:23:23 +04:00
<Button variant='outlined' color='info' startIcon={
2022-10-31 23:01:33 +04:00
<Image
width={width}
height={height}
alt={title}
src={`/images/${id === 'github' ? `${id}-${theme.palette.mode}` : id}.svg`}
/>
} onClick={hanleClick}
>
{title}
</Button>
2021-06-10 19:25:14 +02:00
</Link>
)
}
LoginProvider.propTypes = {
id: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
2022-10-26 00:33:01 +04:00
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
callbackUrl: PropTypes.string.isRequired
2021-06-10 19:25:14 +02:00
}