Change LoginProvider component & props
This commit is contained in:
@@ -15,12 +15,12 @@ import Snackbar from '@mui/material/Snackbar'
|
|||||||
import Tab from '@mui/material/Tab'
|
import Tab from '@mui/material/Tab'
|
||||||
import Tabs from '@mui/material/Tabs'
|
import Tabs from '@mui/material/Tabs'
|
||||||
import Typography from '@mui/material/Typography'
|
import Typography from '@mui/material/Typography'
|
||||||
|
import Grid from '@mui/material/Grid'
|
||||||
import Visibility from '@mui/icons-material/Visibility'
|
import Visibility from '@mui/icons-material/Visibility'
|
||||||
import VisibilityOff from '@mui/icons-material/VisibilityOff'
|
import VisibilityOff from '@mui/icons-material/VisibilityOff'
|
||||||
import MuiAlert from '@mui/material/Alert'
|
import MuiAlert from '@mui/material/Alert'
|
||||||
import LoginIcon from '@mui/icons-material/Login'
|
import LoginIcon from '@mui/icons-material/Login'
|
||||||
import AppRegistrationRoundedIcon from '@mui/icons-material/AppRegistrationRounded'
|
import AppRegistrationRoundedIcon from '@mui/icons-material/AppRegistrationRounded'
|
||||||
import TwitterIcon from '@mui/icons-material/Twitter'
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
import {validateEmail} from '../../lib/utils/emails'
|
import {validateEmail} from '../../lib/utils/emails'
|
||||||
@@ -28,14 +28,21 @@ import ResetPassword from '../password/reset-password'
|
|||||||
import ResetDialog from '../password/reset-dialog'
|
import ResetDialog from '../password/reset-dialog'
|
||||||
import LoginProvider from './login-provider'
|
import LoginProvider from './login-provider'
|
||||||
|
|
||||||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000'
|
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3001'
|
||||||
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:1337'
|
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:1337'
|
||||||
|
|
||||||
const PROVIDERS = [
|
const PROVIDERS = [
|
||||||
|
{
|
||||||
|
id: 'google',
|
||||||
|
title: 'Google',
|
||||||
|
width: 46,
|
||||||
|
height: 46
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'twitter',
|
id: 'twitter',
|
||||||
title: 'Twitter',
|
title: 'Twitter',
|
||||||
icon: <TwitterIcon />
|
width: 56,
|
||||||
|
height: 46
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -244,12 +251,14 @@ function Koneksyon({chimen}) {
|
|||||||
<TabPanel value={value} index={0}>
|
<TabPanel value={value} index={0}>
|
||||||
|
|
||||||
<Box sx={{textAlign: 'center', marginBottom: 3}}>
|
<Box sx={{textAlign: 'center', marginBottom: 3}}>
|
||||||
<Typography>Se connecter avec</Typography>
|
<Typography gutterBottom textAlign='center'>Connectez-vous avec</Typography>
|
||||||
{PROVIDERS.map(({id, title, icon}) => (
|
<Grid container alignItems='center' justifyContent='center' spacing={5}>
|
||||||
<Box key={id} marginTop={1}>
|
{PROVIDERS.map(({id, title, width, height}) => (
|
||||||
<LoginProvider id={id} title={title} icon={icon} callbackUrl={`${siteUrl}${chimen}`} />
|
<Grid key={id} item marginTop={1}>
|
||||||
</Box>
|
<LoginProvider id={id} title={title} width={width} height={height} callbackUrl={`${siteUrl}${chimen}`} />
|
||||||
|
</Grid>
|
||||||
))}
|
))}
|
||||||
|
</Grid>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box sx={{textAlign: 'center', marginBottom: 3}}>
|
<Box sx={{textAlign: 'center', marginBottom: 3}}>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
import Image from 'next/image'
|
||||||
import {signIn} from 'next-auth/react'
|
import {signIn} from 'next-auth/react'
|
||||||
import {Button} from '@mui/material'
|
|
||||||
|
|
||||||
export default function LoginProvider({id, title, icon, callbackUrl}) {
|
export default function LoginProvider({id, title, width, height, callbackUrl}) {
|
||||||
const hanleClick = event => {
|
const hanleClick = event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
signIn(id, {
|
signIn(id, {
|
||||||
@@ -13,15 +13,14 @@ export default function LoginProvider({id, title, icon, callbackUrl}) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Link passHref href='/api/auth/signin'>
|
<Link passHref href='/api/auth/signin'>
|
||||||
<Button
|
<Image
|
||||||
variant='outlined'
|
style={{cursor: 'pointer'}}
|
||||||
size='large'
|
width={width}
|
||||||
color='primary'
|
height={height}
|
||||||
startIcon={icon}
|
alt={title}
|
||||||
|
src={`/images/${id}.svg`}
|
||||||
onClick={hanleClick}
|
onClick={hanleClick}
|
||||||
>
|
/>
|
||||||
{title}
|
|
||||||
</Button>
|
|
||||||
</Link>
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -29,6 +28,7 @@ export default function LoginProvider({id, title, icon, callbackUrl}) {
|
|||||||
LoginProvider.propTypes = {
|
LoginProvider.propTypes = {
|
||||||
id: PropTypes.string.isRequired,
|
id: PropTypes.string.isRequired,
|
||||||
title: PropTypes.string.isRequired,
|
title: PropTypes.string.isRequired,
|
||||||
icon: PropTypes.node.isRequired,
|
width: PropTypes.number.isRequired,
|
||||||
|
height: PropTypes.number.isRequired,
|
||||||
callbackUrl: PropTypes.string.isRequired
|
callbackUrl: PropTypes.string.isRequired
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user