Economia Bruta
diff --git a/src/components/sidebar/SidebarView.ts b/src/components/sidebar/SidebarView.ts
index 5bc5aba..7ab88a9 100644
--- a/src/components/sidebar/SidebarView.ts
+++ b/src/components/sidebar/SidebarView.ts
@@ -182,7 +182,7 @@ export const SidebarView = styled.nav
`
z-index: 2;
- height: 5rem;
+ height: 3.5rem;
}
.imageNext {
display: none;
@@ -194,8 +194,8 @@ export const SidebarView = styled.nav`
background-color: #FFF;
li {
- height: 7rem;
- font-size: 170%;
+ height: 5rem;
+ font-size: 150%;
}
}
aside {
@@ -207,15 +207,17 @@ export const SidebarView = styled.nav`
font-size: 14px;
ul {
li {
- height: 2rem;
+ height: 3rem;
+ font-size: 100%;
}
}
}
@media (max-width: 1008px) {
- font-size: 14px;
+ font-size: 26px;
ul {
li {
- height: 6rem;
+ height: 7rem;
+ font-size: 99.98%;
}
}
}
diff --git a/src/contexts/AuthContext.tsx b/src/contexts/AuthContext.tsx
new file mode 100644
index 0000000..00093ae
--- /dev/null
+++ b/src/contexts/AuthContext.tsx
@@ -0,0 +1,55 @@
+import React, { createContext, useState } from "react";
+import Router from 'next/router'
+
+import { setCookie } from "nookies";
+
+import { signInRequest } from "../services/auth";
+import api from "../services/api";
+
+type UserType = {
+ name: string;
+ email: string;
+ avatar_url: string;
+}
+
+type SignInData = {
+ email: string;
+ password: string;
+}
+
+type AuthContextType = {
+ isAuthenticated: boolean;
+ user: UserType;
+ signIn: (data: SignInData) => Promise;
+}
+
+export const AuthContext = createContext({} as AuthContextType)
+
+export function AuthProvider({children}: {children: React.ReactNode}) {
+ const [user, setUser] = useState(null)
+
+ const isAuthenticated = !!user
+
+ async function signIn({email, password}: SignInData) {
+ const { token, user }: any = await signInRequest({
+ email,
+ password
+ })
+
+ setCookie(undefined, '@smartAuth-token', token, {
+ maxAge: 60 * 60 * 1, // 1 hour
+ })
+
+ api.defaults.headers['Authorization'] = `Bearer ${token}`
+
+ setUser(user)
+
+ Router.push('/dashboard')
+ }
+
+ return (
+
+ {children}
+
+ )
+}
diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx
index 79e4051..ed63084 100644
--- a/src/pages/_app.tsx
+++ b/src/pages/_app.tsx
@@ -1,19 +1,23 @@
-import React, { useState, useEffect } from 'react'
-import { useRouter } from 'next/router'
import { AppProps } from 'next/app'
+import Head from 'next/head'
+import { useRouter } from 'next/router'
import NProgress from 'nprogress'
-
-// import Footer from '../components/footer/Footer'
-import Sidebar from '../components/sidebar/Sidebar'
-import { GlobalStyle } from '../styles/globals'
-import { AppView } from '../styles/app/AppView'
-import '../styles/nprogress/nprogress.css'
-import '../styles/globals.ts'
+import React, { useContext, useEffect, useState } from 'react'
import Home from '.'
-import Head from 'next/head'
-import VerifyEmail from './verifyEmail'
+// import Footer from '../components/footer/Footer'
+import Sidebar from '../components/sidebar/Sidebar'
+import { AuthContext, AuthProvider } from '../contexts/AuthContext'
+import { AppView } from '../styles/app/AppView'
+import { GlobalStyle } from '../styles/globals'
import ForgotPassword from './forgotPassword'
+import VerifyEmail from './verifyEmail'
+
+import '../styles/globals.ts'
+import '../styles/nprogress/nprogress.css'
+import { GetServerSideProps } from 'next'
+import { parseCookies } from 'nookies'
+import getAPIClient from '../services/ssrApi'
function MyApp({ Component, pageProps }: AppProps) {
const router = useRouter()
@@ -40,7 +44,7 @@ function MyApp({ Component, pageProps }: AppProps) {
}, [router])
return (
- <>
+
@@ -61,8 +65,7 @@ function MyApp({ Component, pageProps }: AppProps) {
null
}
- {/* */}
- >
+
)
}
diff --git a/src/pages/administrative/clients.tsx b/src/pages/administrative/clients.tsx
new file mode 100644
index 0000000..7f2d1c3
--- /dev/null
+++ b/src/pages/administrative/clients.tsx
@@ -0,0 +1,91 @@
+import Box from '@mui/material/Box';
+import Button from '@mui/material/Button';
+import Modal from '@mui/material/Modal';
+import TextField from '@mui/material/TextField';
+import Typography from '@mui/material/Typography';
+import { DataGrid, GridColDef, GridValueGetterParams } from '@mui/x-data-grid';
+import React, { useState } from 'react'
+
+import AdministrativeHeader from '../../components/administrativeHeader/AdministrativeHeader';
+import ClientsTable from '../../components/administrativeTables/ClientsTable';
+import BasicButton from '../../components/buttons/basicButton/BasicButton'
+import FaqButton1 from '../../components/buttons/faqButton/FaqButton1';
+import FaqButton2 from '../../components/buttons/faqButton/FaqButton2';
+import Header from '../../components/header/Header'
+import ConfirmModal from '../../components/modal/ConfirmModal';
+import PageTitle from '../../components/pageTitle/PageTitle'
+import { ClientsView, ConfirmModalView } from '../../styles/layouts/clients/ClientsView'
+
+const style = {
+ position: 'absolute' as const,
+ top: '50%',
+ left: '50%',
+ transform: 'translate(-50%, -50%)',
+ width: 900,
+ height: 500,
+ bgcolor: 'background.paper',
+ border: '2px solid #000',
+ boxShadow: 24,
+ p: 4,
+ overflowY: 'scroll'
+};
+
+
+
+export default function clients() {
+ const [open, setOpen] = React.useState(false);
+ const [openModalInativar, setOpenModalInativar] = useState(false)
+ const handleOpen = () => setOpen(true);
+ const handleClose = () => setOpen(false);
+
+ const [openModal, setOpenModal] = useState(false)
+
+
+
+ return (
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+ Adicionar Cliente
+
+ Adicionar Cliente Smart Energia
+
+
+
+
+
+
+
+
+ console.log()} />
+ console.log()}/>
+
+
+
+
+
+
{setOpenModalInativar(value)}}>
+
+ setOpenModalInativar(true)}/>
+ setOpenModalInativar(true)}/>
+
+
+
+
+ )
+}
diff --git a/src/pages/administrative/faq/faqView.ts b/src/pages/administrative/faq/faqView.ts
new file mode 100644
index 0000000..7680a37
--- /dev/null
+++ b/src/pages/administrative/faq/faqView.ts
@@ -0,0 +1,54 @@
+import styled from 'styled-components'
+
+
+
+export const FaqView = styled.nav`
+ display: flex;
+ align-items: center;
+ flex-direction: column;
+ width: 100%;
+
+
+ .btn{
+ background: #254F7F;
+ border-radius: 8px;
+ color: white;
+ width: 164px;
+ height: 40px;
+ border: none;
+
+ }
+ .btn2{
+ background: #FFBC10;
+ border-radius: 8px;
+ color: white;
+ width: 164px;
+ height: 40px;
+ border: none;
+ margin-left: 3px;
+ }
+ .buttons{
+ display: flex;
+ margin-top:50px ;
+ justify-content: space-between;
+ align-self:flex-start ;
+ margin-left: 20px;
+ }
+ .title{
+ display: flex;
+ justify-content: flex-start;
+ align-self:flex-start ;
+ flex-direction: column;
+ margin-left: 19px;
+ }
+
+/*
+ .teste{
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ margin-left: 100px;
+ } */
+
+
+`
diff --git a/src/pages/administrative/faq/index.tsx b/src/pages/administrative/faq/index.tsx
index 4a41b98..91ae987 100644
--- a/src/pages/administrative/faq/index.tsx
+++ b/src/pages/administrative/faq/index.tsx
@@ -1,24 +1,81 @@
+import Box from '@mui/material/Box';
+import Button from '@mui/material/Button';
+import Modal from '@mui/material/Modal';
+import Stack from '@mui/material/Stack';
import TextField from '@mui/material/TextField';
+import Typography from '@mui/material/Typography';
import Head from 'next/head'
-import React from 'react'
+import Image from 'next/image'
+import Link from 'next/link'
+import { useRouter } from 'next/router'
+import React, { useEffect, useState } from 'react'
-import AdministrativeHeader from '../../../components/administrativeHeader/AdministrativeHeader';
import FaqTable from '../../../components/administrativeTables/FaqTable';
import BasicButton from '../../../components/buttons/basicButton/BasicButton';
-import CommonQuestionsCard from '../../../components/faqQuestionsCard/FaqQuestionsCard'
+import FaqButton1 from '../../../components/buttons/faqButton/FaqButton1';
+import FaqButton2 from '../../../components/buttons/faqButton/FaqButton2';
import Header from '../../../components/header/Header'
+import PageTitle from '../../../components/pageTitle/PageTitle'
import { FaqView } from '../../../styles/layouts/commonQuestions/FaqView'
-export default function commonQuestions() {
+const style = {
+ position: 'absolute' as const,
+ top: '50%',
+ left: '50%',
+ transform: 'translate(-50%, -50%)',
+ width: 900,
+ height: 500,
+ bgcolor: 'background.paper',
+ border: '2px solid #000',
+ boxShadow: 24,
+ p: 4,
+};
+
+export default function Sidebar() {
+
+ const [open, setOpen] = React.useState(false);
+ const handleOpen = () => setOpen(true);
+ const handleClose = () => setOpen(false);
+
return (
<>
-
- Smart Energia - FAQ
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+ Adicionar/Editar Pergunta
+
+ Adicionar/Editar Pergunta
+
+
+
+
+
+
+
+
+
+
+
+
+
>
)
}
diff --git a/src/pages/administrative/notification/index.tsx b/src/pages/administrative/notification/index.tsx
new file mode 100644
index 0000000..c608fe7
--- /dev/null
+++ b/src/pages/administrative/notification/index.tsx
@@ -0,0 +1,139 @@
+import CheckBoxIcon from '@mui/icons-material/CheckBox';
+import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
+import RadioButtonCheckedIcon from '@mui/icons-material/RadioButtonChecked';
+import RadioButtonUncheckedIcon from '@mui/icons-material/RadioButtonUnchecked';
+import Autocomplete from '@mui/material/Autocomplete';
+import Box from '@mui/material/Box';
+import Checkbox from '@mui/material/Checkbox';
+import FormControl from '@mui/material/FormControl';
+import InputLabel from '@mui/material/InputLabel';
+import MenuItem from '@mui/material/MenuItem';
+import Modal from '@mui/material/Modal';
+import Select, { SelectChangeEvent } from '@mui/material/Select';
+import TextField from '@mui/material/TextField';
+import Typography from '@mui/material/Typography';
+import Head from 'next/head'
+import React from 'react'
+
+import NotificationsTable from '../../../components/administrativeTables/NotificationsTable'
+import BasicButton from '../../../components/buttons/basicButton/BasicButton';
+import FaqButton1 from '../../../components/buttons/faqButton/FaqButton1';
+import FaqButton2 from '../../../components/buttons/faqButton/FaqButton2';
+import Header from '../../../components/header/Header'
+import PageTitle from '../../../components/pageTitle/PageTitle'
+import api from '../../../services/api';
+import { FaqView } from '../../../styles/layouts/commonQuestions/FaqView'
+import { NotificationView } from './notificationView'
+
+const style = {
+ position: 'absolute' as const,
+ top: '50%',
+ left: '50%',
+ transform: 'translate(-50%, -50%)',
+ width: 900,
+ height: 500,
+ bgcolor: 'background.paper',
+ border: '2px solid #000',
+ boxShadow: 24,
+ p: 4,
+ overflowY: 'scroll'
+};
+
+const icon = ;
+const checkedIcon = ;
+
+export default function commonQuestions() {
+
+ const [open, setOpen] = React.useState(false);
+ const handleOpen = () => setOpen(true);
+ const handleClose = () => setOpen(false);
+
+ return (
+
+
+ Smart Energia - Notificações
+
+
+
+
+
+
+
+
+
+
+ Disparar Notificações
+
+ Pode ser que todas as notificaçõs demorem alguns minutos para estarem disponíveis
+
+
+
+ option.title}
+ renderOption={(props, option, { selected }) => (
+
+
+ {option.title}
+
+ )}
+ sx={{ml:8}}
+ style={{ width: 700 }}
+ renderInput={(params) => (
+
+ )}
+ />
+
+ }
+ checkedIcon={}
+ />
+
+ Disparar para todos os clientes
+ }
+ checkedIcon={}
+ />
+
+ Disparar somente para alguns clientes
+
+
+
+
+
+
+
+
+ )
+}
+
+const top100Films = [
+ { title: 'The Shawshank Redemption', year: 1994 },
+ { title: 'The Godfather', year: 1972 },
+ { title: 'The Godfather: Part II', year: 1974 },
+ { title: 'The Dark Knight', year: 2008 },
+ { title: '12 Angry Men', year: 1957 },
+ { title: "Schindler's List", year: 1993 },
+ { title: 'Pulp Fiction', year: 1994 },
+ {
+ title: 'The Lord of the Rings: The Return of the King',
+ year: 2003,
+ },
+];
diff --git a/src/pages/administrative/notification/notificationView.ts b/src/pages/administrative/notification/notificationView.ts
new file mode 100644
index 0000000..eef7f16
--- /dev/null
+++ b/src/pages/administrative/notification/notificationView.ts
@@ -0,0 +1,83 @@
+import styled from 'styled-components'
+
+
+
+export const NotificationView = styled.nav`
+ display: flex;
+ align-items: center;
+
+ flex-direction: column;
+
+ width: 100%;
+
+ h1 {
+ font-weight: 700;
+ font-size: calc(90% + 2rem);
+ line-height: 72px;
+ text-align: center;
+ letter-spacing: 0.5px;
+ }
+
+ p {
+ font-weight: 400;
+ font-size: 99.98%;
+ line-height: 21px;
+ text-align: center;
+ letter-spacing: 0.5px;
+
+ color: #AAAAAA;
+ }
+
+ .CommonQuestionsSection {
+ width: 80%;
+ }
+
+ hr {
+ border: 1px solid #DDDDDD;
+ }
+
+ /* .modal{
+ display: flex;
+ justify-self: flex-end;
+ align-self: center;
+ margin-left: 100px;
+
+ } */
+ .btn2{
+ background: #254F7F;
+ border-radius: 8px;
+ color: white;
+ width: 164px;
+ height: 45px;
+ border: none;
+ margin-top: 10px;
+ }
+ .btn1{
+ background:#FFBC10;
+ border-radius: 8px;
+ color: white;
+ width: 164px;
+ height: 45px;
+ border: none;
+ margin-top: 10px;
+ margin-left: 6px;
+ }
+ .buttons{
+ display: flex;
+ justify-content: flex-start;
+ align-self: flex-start;
+ margin-top: 45px;
+ margin-left: 16px;
+
+ }
+ .title{
+ display: flex;
+ justify-content: flex-start;
+ align-self: flex-start;
+ margin-left: 16px;
+ }
+
+
+
+
+`
diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx
index 999cacb..1615fab 100644
--- a/src/pages/dashboard.tsx
+++ b/src/pages/dashboard.tsx
@@ -17,6 +17,10 @@ import Chart from '../components/graph/Chart'
import { LineBarChart } from '../components/graph/LineBarChart'
import { ConsumoEstimado } from '../services/consumoEstimado'
import Head from 'next/head'
+import recoverUserInformation from '../services/auth'
+import { parseCookies } from 'nookies'
+import { GetServerSideProps } from 'next'
+import getAPIClient from '../services/ssrApi'
export default function Dashboard() {
@@ -53,9 +57,28 @@ export default function Dashboard() {
+
-
-
-
)
}
+
+export const getServerSideProps: GetServerSideProps = async (ctx) => {
+ const apiClient = getAPIClient(ctx)
+ const { ['@smartAuth-token']: token } = parseCookies(ctx)
+
+ if (!token) {
+ return {
+ redirect: {
+ destination: '/',
+ permanent: false
+ }
+ }
+ }
+
+ return {
+ props: {}
+ }
+}
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index fb138c3..dbfbe9a 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -1,33 +1,38 @@
-import React, { useState } from 'react'
+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 OutlinedInput from '@mui/material/OutlinedInput';
-import InputLabel from '@mui/material/InputLabel';
-import InputAdornment from '@mui/material/InputAdornment';
+import React, { useContext, useState } from 'react'
+import { AiOutlineEye, AiOutlineEyeInvisible } from 'react-icons/ai';
+
import LoginButton from '../components/buttons/loginButton/LoginButton';
-import FormControl from '@mui/material/FormControl';
-import IconButton from '@mui/material/IconButton';
-import TextField from '@mui/material/TextField';
-
-import {AiOutlineEyeInvisible, AiOutlineEye} from 'react-icons/ai';
-
-import { LoginView, LoginContainer } from '../styles/layouts/login/LoginView';
-import Head from 'next/head';
+import { AuthContext } from '../contexts/AuthContext';
+import { api } from '../services/api';
+import { LoginContainer, LoginView } from '../styles/layouts/login/LoginView';
+import Dashboard from './dashboard';
export default function Home() {
- const [state, setstate]=useState(false);
+ const [state, setstate] = useState(false);
- const [values, setValues] = React.useState({
+ const [values, setValues] = useState({
password: '',
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 = () => {
@@ -41,6 +46,12 @@ export default function Home() {
event.preventDefault();
};
+ const { signIn } = useContext(AuthContext)
+
+ async function handleSignIn() {
+ await signIn({email, password})
+ }
+
return (
@@ -48,14 +59,16 @@ export default function Home() {
-
+
Bem-Vindo
Estratégias Inteligentes em
Gestão de Energia
-
+ {
+ setEmail(value.target.value)
+ }}/>
Password
Esqueceu a senha ?
-
+ handleSignIn()}/>
+55(41) 3012-5900
www.energiasmart.com.br
-
diff --git a/src/pages/pld/index.tsx b/src/pages/pld/index.tsx
index ee633ef..75b29fb 100644
--- a/src/pages/pld/index.tsx
+++ b/src/pages/pld/index.tsx
@@ -34,7 +34,7 @@ export default function region() {
function handleGreen(minimo, mi, ma, maximo) {
if (minimo - mi >= 100 && minimo - mi < 200) {
return 'green'
- } else if ( mi*2 >= 200 && mi*2 <250 ) {
+ } else if ( mi*2 >= 200 && mi*2 < 250 ) {
return'dullGreen'
} else if ( (ma-mi)/2 >=250 && (ma-mi)/2 < 300 ) {
return 'white'
@@ -195,7 +195,7 @@ export default function region() {
setPage('table')}>{'< voltar para tabela PLD'}
-
+
diff --git a/src/pages/telemetria.tsx b/src/pages/telemetria.tsx
index eb351f6..c20530f 100644
--- a/src/pages/telemetria.tsx
+++ b/src/pages/telemetria.tsx
@@ -56,12 +56,14 @@ export default function Telemetria() {
fullWidth
>
-
-
-
-
+
+
+
+
+
+
@@ -79,12 +81,13 @@ export default function Telemetria() {
fullWidth
>
-
-
-
-
+
+
+
+
+
@@ -102,12 +105,13 @@ export default function Telemetria() {
fullWidth
>