diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7b6080f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cSpell.language": "pt-BR,en" +} diff --git a/src/components/banner/BannerView.ts b/src/components/banner/BannerView.ts index 8b7d46c..8c654c2 100644 --- a/src/components/banner/BannerView.ts +++ b/src/components/banner/BannerView.ts @@ -8,6 +8,7 @@ export const BannerView = styled.div` width: 100%; height: 20%; + max-height: 200px; margin-bottom: 30px; diff --git a/src/components/graph/LineBarChart2.tsx b/src/components/graph/LineBarChart2.tsx index ff01607..273fe77 100644 --- a/src/components/graph/LineBarChart2.tsx +++ b/src/components/graph/LineBarChart2.tsx @@ -125,7 +125,7 @@ export function LineBarChart2({ title, subtitle, data1, data2, data3, label, red type: 'bar' as const, label: dataset2? dataset2 : 'Dataset 2', backgroundColor: (value, ctx) => { - return hashurado? data1[value.dataIndex].dad_estimado == false? '#C2D5FB' : pattern.draw('diagonal', '#C2D5FB') : '#C2D5FB' + return hashurado? data1[value.dataIndex]?.dad_estimado == false? '#C2D5FB' : pattern.draw('diagonal', '#C2D5FB') : '#C2D5FB' }, data: data3.map(value => value.custo_cativo), }, @@ -134,7 +134,7 @@ export function LineBarChart2({ title, subtitle, data1, data2, data3, label, red label: dataset3? dataset3 : 'Dataset 2', // backgroundColor: '#255488', backgroundColor: (value, ctx) => { - return hashurado? data1[value.dataIndex].dad_estimado == false? '#255488' : pattern.draw('diagonal', '#255488') : '#255488' + return hashurado? data1[value.dataIndex]?.dad_estimado == false? '#255488' : pattern.draw('diagonal', '#255488') : '#255488' }, data: data2.map(value => value.custo_livre), }, diff --git a/src/components/graph/SingleBar.tsx b/src/components/graph/SingleBar.tsx index f73e27d..2fec803 100644 --- a/src/components/graph/SingleBar.tsx +++ b/src/components/graph/SingleBar.tsx @@ -75,9 +75,9 @@ export function SingleBar({ title, subtitle, dataProps, label, dataset, barLabel labels, datasets: [ { - label: '', + label: 'Estimado', data: [], - backgroundColor: 'transparent', + backgroundColor: '#C2d5fb', }, { label: dataset, diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index aadb528..927ae07 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -9,59 +9,28 @@ import { parseCookies } from 'nookies'; import { GetServerSideProps } from 'next'; import getAPIClient from '../../services/ssrApi'; -function stringToColor(string: string) { - let hash = 0; - let i; - - for (i = 0; i < string.length; i += 1) { - hash = string.charCodeAt(i) + ((hash << 5) - hash); - } - - let color = '#'; - - for (i = 0; i < 3; i += 1) { - const value = (hash >> (i * 8)) & 0xff; - color += `00${value.toString(16)}`.slice(-2); - } - - return color; -} - -function stringAvatar(profile_picture: string) { - return { - - children: `${profile_picture}`, - }; -} - - interface headerInterface { name: string, admin?: boolean | undefined logo?: string - profile_picture: string } -export default function Header({ name, admin, }: headerInterface) { +export default function Header({name, admin}: headerInterface) { + const { ['user-profile_picture']: profile_picture } = parseCookies() + return ( -
-
-
- { - !admin? - // - null - : - null - } -
-

- olá, {name} -

-
- -
+
+

+ olá, {name} +

+
+ { + !admin && profile_picture? + + : + null + }
) } @@ -70,6 +39,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) + const { ['user-profile_picture']: profile_picture } = parseCookies() let userData = []; @@ -91,7 +61,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { return { props: { userData, - userName + userName, + profile_picture } } } diff --git a/src/components/header/HeaderView.ts b/src/components/header/HeaderView.ts index c3a4f2e..bdeeb85 100644 --- a/src/components/header/HeaderView.ts +++ b/src/components/header/HeaderView.ts @@ -2,24 +2,10 @@ import styled from "styled-components"; export const HeaderView = styled.header` display: flex; - justify-content: space-between; - - margin: 0 0 75px 0; + justify-content: flex-end; width: 100%; - section { - width: 30%; - - :last-child { - display: flex; - justify-content: flex-end; - align-items: center; - - height: fit-content; - } - } - .icon { display: flex; align-items: center; @@ -32,6 +18,8 @@ export const HeaderView = styled.header` background-color: #254F7F; + margin-right: 20px; + p{ color: white; margin-left: 15%; diff --git a/src/contexts/AuthContext.tsx b/src/contexts/AuthContext.tsx index 4dd6c8f..ab53abb 100644 --- a/src/contexts/AuthContext.tsx +++ b/src/contexts/AuthContext.tsx @@ -64,6 +64,9 @@ export function AuthProvider({children}: {children: React.ReactNode}) { if (user.client_id) setCookie(undefined, 'user-client_id', user.client_id) + if (user.profile_picture) + setCookie(undefined, 'user-profile_picture', user.profile_picture) + api.defaults.headers['Authorization'] = `Bearer ${token}` if (!exception) { diff --git a/src/pages/aboutUs.tsx b/src/pages/aboutUs.tsx index d0eb0a0..722e9a3 100644 --- a/src/pages/aboutUs.tsx +++ b/src/pages/aboutUs.tsx @@ -5,58 +5,46 @@ import { parseCookies } from 'nookies' import React from 'react' import Banner from '../components/banner/Banner' import Header from '../components/header/Header' +import getAPIClient from '../services/ssrApi' import { AboutUsView } from '../styles/layouts/aboutUs/AboutUsView' -export default function aboutUs({userName}) { +export default function aboutUs({userName, text}) { return ( Smart Energia - About Us -
+ + {/*
*/} -
-

A SMART ENERGIA é uma consultoria independente especializada em Gestão de Energia Elétrica, consolidada como uma das três maiores consultorias do Brasil. - Devido à grande experiência em operações na CCEE – Câmara de Comercialização de Energia Elétrica e ANEEL, entrega resultados que superam as expectativas.

- -

Nasceu para gerenciar a compra de energia com inovação, transparência e imparcialidade sendo o elo forte e necessário entre os Consumidores e os - Vendedores de energia.

- -

Baseada em sua experiência no setor elétrico adquirida desde 2001 e em mais de 900 unidades migradas, atua na negociação de contratos de compra e venda de - energia, na Gestão de Energia no Mercado Livre e criação de produtos diferenciados para atender as necessidades específicas dos consumidores.

- -

Apoiada pela sólida experiência de seus gestores, conhecendo as premissas dos agentes de Comercialização e Geração para a compra e venda de energia, - aplicamos as mesmas premissas a favor dos Consumidores, disponibilizando assim um diferencial único para a tomada de decisão e elaboração das estratégias de - contratação de energia.

-
    -
  • {'Informação'}
  • -
  • {'Economia'}
  • -
  • {'Gestão de Energia'}
  • -
  • {'Imparcialidade'}
  • -
  • {'Previsão de Custos'}
  • -
  • {'Experiência'}
  • -
  • {'Relacionamento'}
  • -
- -
- -
-
+
+
+ +
) } export const getServerSideProps: GetServerSideProps = async (ctx) => { + const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) + let text = [] + + await apiClient.get('/aboutUs').then(res => { + text = res.data.data + }).catch(res => { + console.log(res) + }) + if (!token) { return { redirect: { @@ -68,7 +56,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { return { props: { - userName + userName, + text } } } diff --git a/src/pages/accumulatedSavings.tsx b/src/pages/accumulatedSavings.tsx index 7fffbce..8de54d6 100644 --- a/src/pages/accumulatedSavings.tsx +++ b/src/pages/accumulatedSavings.tsx @@ -19,16 +19,16 @@ export default function AccumulatedSavings({graphData, years, userName}: any) { Smart Energia - Economia Bruta Mensal
- +
- { + { if (parseFloat(a.mes.slice(0,2)) > parseFloat(b.mes.slice(1,2))) return 1 if (parseFloat(a.mes.slice(0,2)) < parseFloat(b.mes.slice(1,2))) return -1 return 0 })} - label={years} barLabel month/> + label={years} barLabel/>
) diff --git a/src/pages/administrative/general.tsx b/src/pages/administrative/general.tsx index f8caf6f..9b349e8 100644 --- a/src/pages/administrative/general.tsx +++ b/src/pages/administrative/general.tsx @@ -8,12 +8,23 @@ import Header from '../../components/header/Header'; import PageTitle from '../../components/pageTitle/PageTitle'; import { api } from '../../services/api'; import { GeneralView } from '../../styles/layouts/general/GeneralView' +import MuiAlert, { AlertProps } from '@mui/material/Alert' +import Snackbar from '@mui/material/Snackbar'; +const Alert = React.forwardRef(function Alert( + props, + ref +) { + return +}) export default function index({userName}: any) { const editorRef = useRef(null); const [text, setText] = useState(''); + const [openSnackSuccess, setOpenSnackSuccess] = useState(false) + const [openSnackError, setOpenSnackError] = useState(false) + const log = () => { if (editorRef.current) { console.log(editorRef.current.getContent()); @@ -24,16 +35,54 @@ export default function index({userName}: any) { setText(event.target.value); }; + const handleCloseSnack = ( + event?: React.SyntheticEvent | Event, + reason?: string + ) => { + if (reason === 'clickaway') { + return + } + + setOpenSnackError(false) + setOpenSnackSuccess(false) + } + async function handleRegisterAboutUs() { await api.post('/aboutUs', { - about: editorRef.current.value - }).then(res => { - console.log(res) - }).catch(res => console.log(res)) + about: text + }) + .then(res => setOpenSnackSuccess(true)) + .catch(res => setOpenSnackError(false)) } return ( + + + Cadastrado com Sucesso! + + + + + Não cadastrado! + +
@@ -43,6 +92,8 @@ export default function index({userName}: any) {
editorRef.current = editor} + onChange={value => console.log(value)} + onEditorChange={(newText) => setText(newText)} initialValue='

A SMART ENERGIA é uma consultoria independente especializada em Gestão de Energia Elétrica, consolidada como uma das três maiores consultorias do Brasil. Devido à grande experiência em operações na CCEE – Câmara de Comercialização de Energia Elétrica e ANEEL, entrega resultados que superam as expectativas.

diff --git a/src/pages/costIndicator.tsx b/src/pages/costIndicator.tsx index e3e2e6d..776e711 100644 --- a/src/pages/costIndicator.tsx +++ b/src/pages/costIndicator.tsx @@ -4,50 +4,21 @@ import { parseCookies } from 'nookies' import React from 'react' import Chart from '../components/graph/Chart' -import { SingleBar } from '../components/graph/SingleBar' import Header from '../components/header/Header' import PageTitle from '../components/pageTitle/PageTitle' -import { dataEconomiaBruta } from '../services/economiaBruta' -import { dataEconomiaIndicador } from '../services/economiaIndicador' import getAPIClient from '../services/ssrApi' import { CostIndicatorView } from '../styles/layouts/economy/costIndicator/CostIndicatorView' -function verifyDataByYear(data) { - const currentYear = [] - const currentYearAux = data.filter(value => value.mes.slice(3, 7).includes('2021')) - console.log(currentYear.length) - console.log(currentYearAux.length) - - currentYearAux.sort((a, b) => { - if (parseFloat(a.mes.slice(0,2)) > parseFloat(b.mes.slice(1,2))) return 1 - if (parseFloat(a.mes.slice(0,2)) < parseFloat(b.mes.slice(1,2))) return -1 - - return 0 - }) - - // for (let i=0; currentYear.length <= currentYearAux.length; i++) { - // console.log(i, 'dentro do for') - // // console.log(currentYearAux.length, 'tamanho aux') - // if (currentYearAux[i].mes.slice(1,2)==i) { - // currentYear.push(currentYearAux[i]) - // console.log(currentYear.length, 'tamanho') - // } - // } - console.log(currentYearAux) -} - export default function CostIndicator({graphData, userName}: any) { - // console.log(graphData.filter((value, index) => value.mes.slice(3, 7).includes('2021')).map(value => value.custo_unit)) - return ( Smart Energia - Indicador de Custos
- +
- value.mes.slice(3, 7).includes('2021')).sort((a, b) => { if (parseFloat(a.mes.slice(0,2)) > parseFloat(b.mes.slice(1,2))) return 1 if (parseFloat(a.mes.slice(0,2)) < parseFloat(b.mes.slice(1,2))) return -1 diff --git a/src/pages/estimatedCost.tsx b/src/pages/estimatedCost.tsx index e4915eb..7cc1d66 100644 --- a/src/pages/estimatedCost.tsx +++ b/src/pages/estimatedCost.tsx @@ -19,11 +19,11 @@ export default function EstimatedCost({graphData, userName}: any) { Smart Energia - Custos Estimados
- +
+ label={ConsumoEstimado.label} title='' subtitle='' barLabel hashurado />
) diff --git a/src/pages/grossSavings.tsx b/src/pages/grossSavings.tsx index b7413d5..6612304 100644 --- a/src/pages/grossSavings.tsx +++ b/src/pages/grossSavings.tsx @@ -19,13 +19,13 @@ export default function GrossSavings({graphData, years, userName}: any) { Smart Energia - Economia Acumulada
- +
- + label={years} barLabel/>
diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 981df29..09dd6e2 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -146,7 +146,7 @@ export default function Home() { } - label="Password" + label="Senha" /> Esqueceu a senha ? diff --git a/src/pages/news.tsx b/src/pages/news.tsx index 6393ab4..b436af2 100644 --- a/src/pages/news.tsx +++ b/src/pages/news.tsx @@ -12,44 +12,38 @@ import getAPIClient from '../services/ssrApi'; import { Button, NewsView } from '../styles/layouts/news/NewsView' export default function aboutUs({userName, news}: any) { - console.log(news) + console.log(news.channel.item) + return ( Smart Energia - Noticias -
- + {/*
*/} + -
-

19 Abril 2022

- ANEEL APROVA REAJUSTE TARIFÁRIO ANUAL DA ENERGISA SERGIPE DE 16,46 % PARA O CONSUMIDOR RESIDENCIAL -
-
-

A Agência Nacional de Energia Elétrica (ANEEL) aprovou, nesta terça-feira (19/04) o reajuste tarifário anual da Energisa Sergipe – Distribuidora de Energia S.A (ESE). - As novas tarifas da empresa, que atende cerca de e 825 mil unidades consumidoras no Sergipe, entram em vigor nesta sexta, 22/04, com reajuste de 16,46 % para - o consumidor residencial.
- Os itens que mais impactaram a correção foram os encargos setoriais, os custos de distribuição, a retirada dos componentes financeiros..

- + { + news.channel.item.map(data => { -

19 Abril 2022

- NEEL APROVA REAJUSTE MÉDIO DE 20,36% NA TARIFA DE ENERGIA NO RN -
-
-

A Agência Nacional de Energia Elétrica (ANEEL) aprovou, nesta terça-feira (19/04) o reajuste tarifário anual da Energisa Sergipe – Distribuidora de Energia S.A (ESE). - As novas tarifas da empresa, que atende cerca de e 825 mil unidades consumidoras no Sergipe, entram em vigor nesta sexta, 22/04, com reajuste de 16,46 % para - o consumidor residencial.
- Os itens que mais impactaram a correção foram os encargos setoriais, os custos de distribuição, a retirada dos componentes financeiros..

- -
+ return <> +
+

+ + ANEEL APROVA REAJUSTE TARIFÁRIO ANUAL DA ENERGISA SERGIPE DE 16,46 % PARA O CONSUMIDOR RESIDENCIAL +
+
+ { +

+ } + +

+ + }) + } { const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) - let news; + let news = []; - await axios.get('https://www.energiasmart.com.br/noticias/feed/').then(res => { - news = res.data + await apiClient.get('/news').then(res => { + news = res.data.data }).catch(res => { console.log(res) }) diff --git a/src/pages/notifications.tsx b/src/pages/notifications.tsx index 0871470..7728130 100644 --- a/src/pages/notifications.tsx +++ b/src/pages/notifications.tsx @@ -16,15 +16,18 @@ export default function Notifications({notificationData, userName}: any) { Smart Energia - Notificações
- +
{ + notificationData? notificationData.map((value, index ) => { return <>
}) + : +

Você não tem notificações!

}
diff --git a/src/pages/pld/index.tsx b/src/pages/pld/index.tsx index 492e1d2..1fa7fc8 100644 --- a/src/pages/pld/index.tsx +++ b/src/pages/pld/index.tsx @@ -160,7 +160,12 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN { - tableData.data.map(data => { + tableData.data.sort((a, b) => { + if (parseFloat(a.year_month_formatted.slice(0,2)) > parseFloat(b.year_month_formatted.slice(1,2))) return 1 + if (parseFloat(a.year_month_formatted.slice(0,2)) < parseFloat(b.year_month_formatted.slice(1,2))) return -1 + + return 0 + }).map(data => { return <> {data.year_month_formatted} @@ -210,7 +215,7 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
- + console.log()} title='Download'/>
@@ -251,9 +256,9 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
+ width: '22%', + ml: 1 + }}> Mês