diff --git a/components/kont/dekoneksyon.js b/components/kont/dekoneksyon.js new file mode 100644 index 0000000..1c1a5ca --- /dev/null +++ b/components/kont/dekoneksyon.js @@ -0,0 +1,44 @@ +import Link from 'next/link' +import {signOut} from 'next-auth/client' +import {withStyles, makeStyles, Tooltip, Fab, Zoom} from '@material-ui/core' +import ExitToAppIcon from '@material-ui/icons/ExitToApp' + +const useStyles = makeStyles(() => ({ + dekoneksyon: { + position: 'absolute', + right: 5 + } +})) + +const DekoneksonTooltip = withStyles(() => ({ + tooltip: { + fontSize: 18 + } +}))(Tooltip) + +function Dekoneksyon() { + const classes = useStyles() + + const handleLogout = event => { + event.preventDefault() + signOut() + } + + return ( + + + handleLogout(event)} + > + + + + + ) +} + +export default Dekoneksyon diff --git a/components/kont/koneksyon.js b/components/kont/koneksyon.js new file mode 100644 index 0000000..951c009 --- /dev/null +++ b/components/kont/koneksyon.js @@ -0,0 +1,129 @@ +import {useEffect, useState} from 'react' +import {signIn} from 'next-auth/client' +import {useRouter} from 'next/router' +import { + Button, + Container, + FormControl, + IconButton, + Input, + InputAdornment, + InputLabel, + Snackbar, + Typography +} from '@material-ui/core' +import {Alert} from '@material-ui/lab' +import Slide from '@material-ui/core/Slide' +import {Visibility, VisibilityOff} from '@material-ui/icons' + +import {validateEmail} from '../../lib/utils/emails' + +function Koneksyon() { + const [loginError, setError] = useState('') + const [credentials, setCredentials] = useState({username: '', password: ''}) + const [showPassword, setShowPassword] = useState(false) + const [open, setOpen] = useState(true) + const router = useRouter() + + const handleUpdate = update => { + setCredentials({...credentials, ...update}) + } + + const handleClick = async () => { + const response = await signIn('credentials', { + redirect: false, + ...credentials + }) + if (response.error) { + setError(response.error) + } else if (response.ok) { + router.push('/kont') + } + } + + const handleClose = (event, reason) => { + if (reason === 'clickaway') { + return + } + + setOpen(false) + setError('') + } + + useEffect(() => { + if (loginError) { + setOpen(true) + } + }, [loginError]) + + const handleClickShowPassword = () => { + setShowPassword(!showPassword) + } + + const handleMouseDownPassword = event => { + event.preventDefault() + } + + return ( + + + Email + handleUpdate({username: event.target.value})} + /> + + + + Mot de passe + + + {showPassword ? : } + + + } + onChange={event => handleUpdate({password: event.target.value})} + /> + + + + + {loginError && ( + + {loginError} + + )} + + ) +} + +export default Koneksyon