import FormControl from '@mui/material/FormControl' import IconButton from '@mui/material/IconButton' import InputAdornment from '@mui/material/InputAdornment' import InputLabel from '@mui/material/InputLabel' import OutlinedInput from '@mui/material/OutlinedInput' import TextField from '@mui/material/TextField' import Head from 'next/head' import Image from 'next/image' import Link from 'next/link' import { useRouter } from 'next/router' import { useContext, useState, useEffect, useCallback, useRef, forwardRef } from 'react' import { AiOutlineEye, AiOutlineEyeInvisible } from 'react-icons/ai' import RenderIf from '../utils/renderIf' import Snackbar from '@mui/material/Snackbar' import LoginButton from '../components/buttons/loginButton/LoginButton' import { AuthContext } from '../contexts/AuthContext' import { api } from '../services/api' import { LoginContainer, LoginView } from '../styles/layouts/login/LoginView' import Dashboard from './dashboard' import MuiAlert, { AlertProps } from '@mui/material/Alert' import { GetServerSideProps } from 'next' import { parseCookies } from 'nookies' import { AxiosError } from 'axios' const Alert = forwardRef(function Alert( props, ref ) { return }) export default function Home() { const [openSnackSuccess, setOpenSnackSuccess] = useState(false) const [openSnackError, setOpenSnackError] = useState(false) const field = useRef(null) const [state, setstate] = useState(false) const [focus, setFocus] = useState('email') const [values, setValues] = useState({ password: null, showPassword: false }) const [email, setEmail] = useState('') const [password, setPassword] = useState() const router = useRouter() const rota = router.pathname const handleChange = (prop) => (event) => { setValues({ ...values, [prop]: event.target.value }) setPassword(event.target.value) } const handleClickShowPassword = () => { setValues({ ...values, showPassword: !values.showPassword }) } const handleMouseDownPassword = (event) => { event.preventDefault() } const { signIn } = useContext(AuthContext) async function handleSignIn() { try { if ([email, password].some(v => !v.trim())) return setOpenSnackError(true); await signIn({ email, password }) } catch (ex) { setOpenSnackError(true) } } const handleCloseSnack = ( event?: React.SyntheticEvent | Event, reason?: string ) => { if (reason === 'clickaway') { return } setOpenSnackError(false) setOpenSnackSuccess(false) } useEffect(() => { setValues({ password: '', showPassword: null }) setEmail('') }, [rota]) return ( Smart Energia notificação cadastrada com sucesso! Preencha os campos corretamente!

Bem-Vindo

Estratégias Inteligentes em
Gestão de Energia

e.key === 'Enter' && field.current.children[0].focus()} onChange={(value) => setEmail(value.target.value.trim())} /> Senha (e.key === 'Enter' ? handleSignIn() : null)} endAdornment={ {values.showPassword ? ( ) : ( )} } label="Senha" /> Esqueceu a senha ? handleSignIn()} />
Ou

+55(41) 3012-5900
www.energiasmart.com.br

) } // export const getServerSideProps: GetServerSideProps = async (ctx) => { // const { ['@smartAuth-token']: token } = parseCookies(ctx) // if (token) { // return { // redirect: { // destination: '/dashboard', // permanent: false // } // } // } // } /*export const getServerSideProps: GetServerSideProps = async (ctx) => { const { ['@smartAuth-token']: token } = parseCookies(ctx) // if (token) { // return { // redirect: { // destination: '/dashboard', // permanent: false // } // } // } return { props: {} }; } */