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/next.config.js b/next.config.js index 0c1f043..dee1618 100644 --- a/next.config.js +++ b/next.config.js @@ -4,6 +4,10 @@ const nextConfig = { compiler: { styledComponents: true, }, + images: { + domains: ["kluppdevelopment.s3.sa-east-1.amazonaws.com"] + } } module.exports = nextConfig + diff --git a/package.json b/package.json index c60b200..ee05b14 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@mui/material": "^5.6.4", "@mui/x-data-grid": "^5.11.0", "@mui/x-date-pickers": "^5.0.0-alpha.3", + "@react-pdf-viewer/core": "^3.5.0", "@tinymce/tinymce-react": "^4.1.0", "@types/react-csv": "^1.1.2", "@types/yup": "^0.29.14", @@ -54,6 +55,7 @@ "react-hook-form": "^7.32.2", "react-icons": "^4.3.1", "react-input-mask": "^2.0.4", + "react-pdf-thumbnail": "^0.1.0", "styled-components": "^5.3.5", "tinymce": "^6.0.3", "yup": "^0.32.11" diff --git a/src/components/banner/BannerView.ts b/src/components/banner/BannerView.ts index 2598880..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; @@ -23,9 +24,11 @@ export const BannerView = styled.div` } h1 { - font-size: 18px; + font-size: 1.3em; + } + .text { position: relative; margin: 0 0 0 20px; @@ -42,7 +45,7 @@ export const BannerView = styled.div` text-overflow: ellipsis; p { - font-size: 70%; + font-size: 19px; /* height: 43px; */ text-overflow: ellipsis; diff --git a/src/components/buttons/gradientButton/GradientButton.tsx b/src/components/buttons/gradientButton/GradientButton.tsx index 9e8306f..78d9c53 100644 --- a/src/components/buttons/gradientButton/GradientButton.tsx +++ b/src/components/buttons/gradientButton/GradientButton.tsx @@ -14,15 +14,13 @@ interface GradientButtonInterface { onClick?: () => void } -export default function GradientButton({ title, description, orange, purple, green, link, onClick }: GradientButtonInterface) { - const router = useRouter() - - function handleClick() { - onClick() - } +export default function GradientButton({ title, description, orange, purple, green, onClick }: GradientButtonInterface) { + // function handleClick() { + // onClick() + // } return ( - link? router.push('/chartTelemetry') : handleClick()} > +

{title}

{description}

diff --git a/src/components/buttons/gradientButton/GradientButtonView.ts b/src/components/buttons/gradientButton/GradientButtonView.ts index 4954b4f..c324f99 100644 --- a/src/components/buttons/gradientButton/GradientButtonView.ts +++ b/src/components/buttons/gradientButton/GradientButtonView.ts @@ -32,8 +32,6 @@ export const GradientButtonView = styled.button` border-style: none; - cursor: pointer; - * { margin: 0; padding: 0; diff --git a/src/components/graph/DemRegXDemConChart.tsx b/src/components/graph/DemRegXDemConChart.tsx new file mode 100644 index 0000000..127909d --- /dev/null +++ b/src/components/graph/DemRegXDemConChart.tsx @@ -0,0 +1,154 @@ +import React, { useRef, useEffect } from 'react'; +import { + Chart as ChartJS, + LinearScale, + CategoryScale, + BarElement, + PointElement, + LineElement, + Legend, + Tooltip, +} from 'chart.js'; +import { Chart } from 'react-chartjs-2'; +import faker from 'faker'; +import { ChartView } from './ChartView'; +import ChartTitle from './ChartTitle'; +import pattern from 'patternomaly' + +ChartJS.register( + LinearScale, + CategoryScale, + BarElement, + PointElement, + LineElement, + Legend, + Tooltip +); + +// function triggerTooltip(chart: ChartJS | null) { +// const tooltip = chart?.tooltip; + +// if (!tooltip) { +// return; +// } + +// if (tooltip.getActiveElements().length > 0) { +// tooltip.setActiveElements([], { x: 0, y: 0 }); +// } else { +// const { chartArea } = chart; + +// tooltip.setActiveElements( +// [ +// { +// datasetIndex: 0, +// index: 2, +// }, +// { +// datasetIndex: 1, +// index: 2, +// }, +// ], +// { +// x: (chartArea.left + chartArea.right) / 2, +// y: (chartArea.top + chartArea.bottom) / 2, +// } +// ); +// } + +// chart.update(); +// } + +interface LineBarChartInterface { + title: string, + subtitle: string, + data1: any, + data2?: any, + red?: any, + label: any, + dataset1?: string, + dataset2?: string, + dataset3?: string, + barLabel?: boolean | undefined, + hashurado?: boolean | undefined, + reais?: boolean | undefined +} + +export function DemRegXDemConChart({ + title, + subtitle, + data1, + data2, + label, + red, + dataset1, + dataset2, + dataset3, + barLabel + }: LineBarChartInterface) { + const chartRef = useRef(null); + + const currentTime = new Date(); + + const labels = label + + const options: any = { + responsive: true, + plugins: { + datalabels: { + display: true, + color: barLabel? 'black' : "rgba(255, 255, 255, 0)", + // backgroundColor: '#255488', + formatter: Math.round, + anchor: "end", + offset: -20, + align: "start", + font: { + size: 12 + } + }, + legend: { + position: 'bottom' as const, + }, + title: { + display: true, + text: '', + }, + }, + }; + + const data = { + labels, + datasets: [ + { + type: 'line' as const, + label: 'Demanda Contratada', + borderColor: red? + '#f00' : '#0c9200', + borderWidth: 2, + fill: false, + data: data1.map(value => value.dem_cont), + }, + { + type: 'bar' as const, + label: 'Demanda Registrada', + backgroundColor: '#255488', + data: data2.map(value => value.dem_reg), + }, + ], + }; + + useEffect(() => { + const chart = chartRef.current; + + // triggerTooltip(chart); + }, []); + + return ( + + +
+ +
+
+ ) +} diff --git a/src/components/graph/DiscretizedConsumptionChart.tsx b/src/components/graph/DiscretizedConsumptionChart.tsx new file mode 100644 index 0000000..210e868 --- /dev/null +++ b/src/components/graph/DiscretizedConsumptionChart.tsx @@ -0,0 +1,93 @@ +import { BarElement, CategoryScale, Chart as ChartJS, Legend, LinearScale, Title, Tooltip } from 'chart.js'; +import ChartDataLabels from 'chartjs-plugin-datalabels'; +import { draw, generate } from 'patternomaly' +import React from 'react'; +import { Bar } from 'react-chartjs-2'; + +import ChartTitle from './ChartTitle'; +import { ChartView } from './ChartView'; + +ChartJS.register( + CategoryScale, + LinearScale, + BarElement, + Title, + Tooltip, + Legend, + ChartDataLabels +); + +interface SingleBarInterface{ + title: string, + subtitle: string, + dataProps: any, + label: Array, + dataset: string, + barLabel?: boolean | undefined, + year?: boolean | undefined, + month?: boolean | undefined, + dataset1?: string, +} + +export function DiscretizedConsumptionChart({ title, subtitle, dataProps, label, dataset, barLabel, year, month }: SingleBarInterface) { + const currentTime = new Date(); + + const options: object = { + responsive: true, + series: { + downsample: { + threshold: 1000 + } + }, + plugins: { + datalabels: { + formatter: (value, ctx) => { + let sum = 0; + const dataArr = ctx.chart.data.datasets[0].data; + dataArr.map(data => { + sum += data; + }); + const percentage = (dataProps[ctx.dataIndex].econ_percentual*100).toFixed(0)+"%"; + const result = `${parseFloat(value).toFixed(0)}\n ${percentage}` + + return value==null? null : result + }, + display: true, + color: barLabel? 'black' : "rgba(255, 255, 255, 0)", + anchor: "end", + offset: -40, + align: "start", + font: { + size: 10 + } + }, + legend: { + position: 'bottom' as const, + }, + title: { + display: false, + text: '', + }, + }, + }; + + const labels = label; + + const data: any = { + labels, + datasets: [ + { + label: dataset, + data: dataProps.map(value => value.consumo), + backgroundColor: '#255488' + }, + ], + } + + return ( + + + + + ) +} diff --git a/src/components/graph/DiscretizedConsumptionChartLine.tsx b/src/components/graph/DiscretizedConsumptionChartLine.tsx new file mode 100644 index 0000000..896a7dc --- /dev/null +++ b/src/components/graph/DiscretizedConsumptionChartLine.tsx @@ -0,0 +1,91 @@ +import React, { useState, useEffect } from 'react' + +import { Bar, Line } from 'react-chartjs-2'; + +import { ChartView } from './ChartView'; + +import { + Chart as ChartJS, + CategoryScale, + LinearScale, + PointElement, + LineElement, + Title, + Tooltip, + Legend, + ScatterDataPoint, +} from 'chart.js'; +import ChartTitle from './ChartTitle'; + +ChartJS.register( + CategoryScale, + LinearScale, + PointElement, + LineElement, + Title, + Tooltip, + Legend +); + + +interface ChartInterface { + title: string, + subtitle: string, + data1: any, + data2?: any, + data3?: any, + data4?: any, + label: any, + dataset1?: string, + dataset2?: string, + dataset3?: string, + dataset4?: string, + barLabel?: boolean | undefined +} + +export default function DiscretizedConsumptionChartLine({ title, subtitle, data1, data2, data3, data4, label, dataset1, dataset2, dataset3, dataset4, barLabel }: ChartInterface) { + const options: any = { + responsive: true, + plugins: { + datalabels: { + display: true, + color: barLabel? 'black' : "rgba(255, 255, 255, 0)", + formatter: Math.round, + anchor: "end", + offset: -20, + align: "start", + font: { + size: 12 + } + }, + legend: { + position: 'bottom' as const, + }, + title: { + display: true, + text: '', + }, + }, + }; + + const labels = label; + + const data = { + labels, + datasets: [ + { + label: dataset1, + data: data1.map(value => value.reativa), + borderColor: 'rgb(53, 162, 235)', + backgroundColor: 'rgba(53, 162, 235, 0)', + }, + ], + } + + return ( + + + + + ) +} 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 8a48d33..2fec803 100644 --- a/src/components/graph/SingleBar.tsx +++ b/src/components/graph/SingleBar.tsx @@ -24,15 +24,10 @@ interface SingleBarInterface{ label: Array, dataset: string, barLabel?: boolean | undefined, - year?: boolean | undefined, - month?: boolean | undefined, - dataset1?: string, - - - + brutoAnual?: boolean | undefined, } -export function SingleBar({ title, subtitle, dataProps, label, dataset, dataset1, barLabel, year, month }: SingleBarInterface) { +export function SingleBar({ title, subtitle, dataProps, label, dataset, barLabel, brutoAnual }: SingleBarInterface) { const currentTime = new Date(); const options: object = { @@ -79,16 +74,28 @@ export function SingleBar({ title, subtitle, dataProps, label, dataset, dataset1 const data: any = { labels, datasets: [ + { + label: 'Estimado', + data: [], + backgroundColor: '#C2d5fb', + }, { label: dataset, data: dataProps.map((value, index) => { return parseFloat(value.economia_acumulada).toFixed(2) }), backgroundColor: (value, ctx) => { - return dataProps[value.dataIndex].dad_estimado == false ? '#255488' : '#C2d5fb' + return dataProps[value.dataIndex]?.dad_estimado == false ? '#255488' : '#C2d5fb' }, }, - + { + label: '', + data: [dataProps[0]?.economia_acumulada?dataProps[0].economia_acumulada*1.1:1], + backgroundColor: 'transparent', + datalabels: { + display: false + } + }, ], } diff --git a/src/components/graph/fatorPotenciaChart.tsx b/src/components/graph/fatorPotenciaChart.tsx new file mode 100644 index 0000000..ce5af02 --- /dev/null +++ b/src/components/graph/fatorPotenciaChart.tsx @@ -0,0 +1,97 @@ +import React, { useState, useEffect } from 'react' + +import { Bar, Line } from 'react-chartjs-2'; + +import { ChartView } from './ChartView'; + +import { + Chart as ChartJS, + CategoryScale, + LinearScale, + PointElement, + LineElement, + Title, + Tooltip, + Legend, + ScatterDataPoint, +} from 'chart.js'; +import ChartTitle from './ChartTitle'; + +ChartJS.register( + CategoryScale, + LinearScale, + PointElement, + LineElement, + Title, + Tooltip, + Legend +); + + +interface ChartInterface { + title: string, + subtitle: string, + data1: any, + data2?: any, + data3?: any, + data4?: any, + label: any, + dataset1?: string, + dataset2?: string, + dataset3?: string, + dataset4?: string, + barLabel?: boolean | undefined +} + +export default function FatorPotenciaChart({ title, subtitle, data1, data2, label, dataset1, dataset2, dataset3, dataset4, barLabel }: ChartInterface) { + const options: any = { + responsive: true, + plugins: { + datalabels: { + display: true, + color: barLabel? 'black' : "rgba(255, 255, 255, 0)", + formatter: Math.round, + anchor: "end", + offset: -20, + align: "start", + font: { + size: 12 + } + }, + legend: { + position: 'bottom' as const, + }, + title: { + display: true, + text: '', + }, + }, + }; + + const labels = label; + + const data = { + labels, + datasets: [ + { + label: dataset1? dataset1 : 'Dataset 1', + data: data1.map(value => value.fp), + borderColor: 'rgb(53, 162, 235)', + backgroundColor: 'rgba(53, 162, 235, 0)', + }, + { + label: dataset2? dataset2 : '', + data: data2.map(value => value.f_ref), + borderColor: 'rgb(0, 0, 0)' , + backgroundColor: 'rgba(255, 145, 0, 0)' , + }, + ], + } + + return ( + + + + + ) +} diff --git a/src/components/graph/graphCard/ChartCard.tsx b/src/components/graph/graphCard/ChartCard.tsx index 96f2741..262e47e 100644 --- a/src/components/graph/graphCard/ChartCard.tsx +++ b/src/components/graph/graphCard/ChartCard.tsx @@ -70,7 +70,7 @@ export default function ChartCard({ title, subtitle, consumption, className, lin

{title}

- {subtitle} + {subtitle}
{/* */}
diff --git a/src/components/graph/graphCard/ChartCardView.ts b/src/components/graph/graphCard/ChartCardView.ts index 9ebabd2..752ebdb 100644 --- a/src/components/graph/graphCard/ChartCardView.ts +++ b/src/components/graph/graphCard/ChartCardView.ts @@ -37,6 +37,11 @@ export const ChartCardView = styled.article` color: #2F4CDD; } + span{ + display:block; + font-size: 12.8px; + } + .statusDot { max-width: 11px; max-height: 11px; diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index 1fba829..927ae07 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -6,58 +6,64 @@ import TextField from '@mui/material/TextField'; import { HeaderView } from './HeaderView' import { parseCookies } from 'nookies'; - -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(name: string) { - return { - sx: { - bgcolor: stringToColor(name), - }, - children: `${name.split(' ')[0][0]}`, - }; -} +import { GetServerSideProps } from 'next'; +import getAPIClient from '../../services/ssrApi'; interface headerInterface { name: string, admin?: boolean | undefined + logo?: 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 - } */} -
-

- olá, {name} -

-
- -
+
+

+ olá, {name} +

+
+ { + !admin && profile_picture? + + : + null + }
) } + +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 = []; + + await apiClient.get('/user').then(res => { + userData = res.data.data + }).catch(res => { + // console.log(res) + }) + + if (!token) { + return { + redirect: { + destination: '/', + permanent: false + } + } + } + + return { + props: { + userData, + userName, + profile_picture + } + } +} + diff --git a/src/components/header/HeaderView.ts b/src/components/header/HeaderView.ts index d123174..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; @@ -28,11 +14,11 @@ export const HeaderView = styled.header` min-width: 120px; height: 40px; - border-radius: 8px 0 0 8px; + border-radius: 8px; background-color: #254F7F; - transform: translateX(16px); + margin-right: 20px; p{ color: white; diff --git a/src/components/sidebar/Sidebar.tsx b/src/components/sidebar/Sidebar.tsx index d113e95..696ecde 100644 --- a/src/components/sidebar/Sidebar.tsx +++ b/src/components/sidebar/Sidebar.tsx @@ -67,7 +67,7 @@ export default function Sidebar() {
  • {'Sobre Nós'}
  • {'FAQ >'}
  • {'Notificações >'}
  • -
  • {'Info Setorial'}
  • +
  • {'Info Setorial'}
  • Deseja realmente sair ? - + @@ -90,6 +90,7 @@ export default function Sidebar() { +
    setViewModal(!viewModal)} > diff --git a/src/contexts/AuthContext.tsx b/src/contexts/AuthContext.tsx index 74735b8..ab53abb 100644 --- a/src/contexts/AuthContext.tsx +++ b/src/contexts/AuthContext.tsx @@ -31,7 +31,17 @@ export function AuthProvider({children}: {children: React.ReactNode}) { const isAuthenticated = !!user + function signOut() { + destroyCookie(null, 'user-client_id') + destroyCookie(null, 'user-name') + destroyCookie(null, 'user-role') + destroyCookie(null, 'user-id') + destroyCookie(null, '@smartAuth-token') + } + async function signIn({email, password}: SignInData) { + await signOut() + const { token, user, exception }: any = await signInRequest({ email, password @@ -51,6 +61,12 @@ export function AuthProvider({children}: {children: React.ReactNode}) { if (user.name) setCookie(undefined, 'user-name', user.name) + 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) { @@ -65,13 +81,6 @@ export function AuthProvider({children}: {children: React.ReactNode}) { } } - function signOut() { - destroyCookie(null, 'user-name') - destroyCookie(null, 'user-role') - destroyCookie(null, 'user-id') - destroyCookie(null, '@smartAuth-token') - } - return ( {children} 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 53467d9..8de54d6 100644 --- a/src/pages/accumulatedSavings.tsx +++ b/src/pages/accumulatedSavings.tsx @@ -19,11 +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/>
    ) diff --git a/src/pages/administrative/clients/index.tsx b/src/pages/administrative/clients/index.tsx index 32ab35c..0bb0f38 100644 --- a/src/pages/administrative/clients/index.tsx +++ b/src/pages/administrative/clients/index.tsx @@ -1,28 +1,29 @@ -import Box from '@mui/material/Box'; -import Modal from '@mui/material/Modal'; -import TextField from '@mui/material/TextField'; -import Typography from '@mui/material/Typography'; -import React, { useState } from 'react' - -import Snackbar from '@mui/material/Snackbar'; -import MuiAlert, { AlertProps } from '@mui/material/Alert'; -import ClientsTable from '../../../components/administrativeTables/ClientsTable'; +import Box from '@mui/material/Box' +import Modal from '@mui/material/Modal' +import TextField from '@mui/material/TextField' +import Typography from '@mui/material/Typography' +import React, { useState, useEffect } from 'react' +import Image from 'next/image' +import Snackbar from '@mui/material/Snackbar' +import MuiAlert, { AlertProps } from '@mui/material/Alert' +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 FaqButton1 from '../../../components/buttons/faqButton/FaqButton1' +import FaqButton2 from '../../../components/buttons/faqButton/FaqButton2' import Header from '../../../components/header/Header' -import InputUploadImg from '../../../components/inputUploadImg/inputUpload'; -import { ClientsView } from '../../../styles/layouts/clients/ClientsView'; -import PageTitle from '../../../components/pageTitle/PageTitle'; -import ConfirmModal from '../../../components/modal/ConfirmModal'; -import { ConfirmModalView } from '../../../styles/layouts/modals/confirmModalView'; -import { api } from '../../../services/api'; -import { parseCookies } from 'nookies'; -import { GetServerSideProps } from 'next'; -import getAPIClient from '../../../services/ssrApi'; -import FormData from 'form-data'; -import { InputUploadView } from '../../../components/inputUploadImg/inputUploadView'; +import { ClientsView } from '../../../styles/layouts/clients/ClientsView' +import PageTitle from '../../../components/pageTitle/PageTitle' +import ConfirmModal from '../../../components/modal/ConfirmModal' +import { ConfirmModalView } from '../../../styles/layouts/modals/confirmModalView' +import { api } from '../../../services/api' +import { parseCookies } from 'nookies' +import { GetServerSideProps } from 'next' +import getAPIClient from '../../../services/ssrApi' + +import FormData from 'form-data' +import { InputUploadView } from '../../../components/inputUploadImg/inputUploadView' +import { FormControl, InputLabel, MenuItem, Select } from '@mui/material' const style = { position: 'absolute' as const, @@ -36,17 +37,17 @@ const style = { boxShadow: 24, p: 4, overflowY: 'scroll' -}; +} const Alert = React.forwardRef(function Alert( props, - ref, + ref ) { - return ; -}); + return +}) -export default function clients({clients, userName}) { - const formData = new FormData(); +export default function clients({ clients, userName }) { + const formData = new FormData() const [client, setClient] = useState({ name: String, @@ -55,179 +56,341 @@ export default function clients({clients, userName}) { password_confirmation: String, client_id: Number }) - const [logo, setLogo] = useState(false); + const [logo, setLogo] = useState(false) const [selectedClients, setSelectedClients] = useState([]) - const [open, setOpen] = useState(false); + const [imageURLS, setImageURLs] = useState([]) + const [images, setImages] = useState([] as any) + const [open, setOpen] = useState(false) const [openModalInativar, setOpenModalInativar] = useState(false) - const handleOpen = () => setOpen(true); - const handleClose = () => setOpen(false); + const handleOpen = () => setOpen(true) + const handleClose = () => setOpen(false) const [openModal, setOpenModal] = useState(false) + const [nivelAcess, setnivelAcess] = useState(2); + const [openSnackSuccess, setOpenSnackSuccess] = useState(false) + const [openSnackError, setOpenSnackError] = useState(false) + const [openSnackSuccessDelete, setOpenSnackSuccessDelete] = + useState(false) + const [openSnackErrorDelete, setOpenSnackErrorDelete] = + useState(false) - const [openSnackSuccess, setOpenSnackSuccess] = useState(false); - const [openSnackError, setOpenSnackError] = useState(false); - const [openSnackSuccessDelete, setOpenSnackSuccessDelete] = useState(false); - const [openSnackErrorDelete, setOpenSnackErrorDelete] = useState(false); - - const handleCloseSnack = (event?: React.SyntheticEvent | Event, reason?: string) => { + const handleCloseSnack = ( + event?: React.SyntheticEvent | Event, + reason?: string + ) => { if (reason === 'clickaway') { - return; + return } - setOpenSnackError(false); - setOpenSnackSuccess(false); - }; + setOpenSnackError(false) + setOpenSnackSuccess(false) + } - const handleCloseSnackDelete = (event?: React.SyntheticEvent | Event, reason?: string) => { + const handleCloseSnackDelete = ( + event?: React.SyntheticEvent | Event, + reason?: string + ) => { if (reason === 'clickaway') { - return; + return } - setOpenSnackErrorDelete(false); - setOpenSnackSuccessDelete(false); - }; + setOpenSnackErrorDelete(false) + setOpenSnackSuccessDelete(false) + } function onChange(e) { setLogo(e.target.files[0]) } - function handleCreateClient({name, email, password, password_confirmation, client_id}) { + function handleCreateClient({ + name, + email, + password, + password_confirmation, + client_id + }) { formData.append('name', name) formData.append('email', email) formData.append('password', password) formData.append('password_confirmation', password_confirmation) formData.append('client_id', client_id) formData.append('profile_picture', logo) + formData.append('role', nivelAcess) - api.post('/user', formData).then(res => { - setOpenSnackSuccess(true) - setOpenModalInativar(false) - window.location.reload() - }).catch(res => { - setOpenSnackError(true) - }) - } - async function handleDeleteClient(id: any) { - await id.map(client => { - api.delete(`/user/${client}`).then(res => { - setOpenSnackSuccessDelete(true) + api.post('/user', formData) + .then((res) => { + setOpenSnackSuccess(true) setOpenModalInativar(false) window.location.reload() - }).catch(res => setOpenSnackErrorDelete(true)) + }) + .catch((res) => { + setOpenSnackError(true) + }) + } + + async function handleDeleteClient(id: any) { + await id.map((client) => { + api + .delete(`/user/${client}`) + .then((res) => { + setOpenSnackSuccessDelete(true) + setOpenModalInativar(false) + window.location.reload() + }) + .catch((res) => setOpenSnackErrorDelete(true)) }) } + useEffect(() => { + if (images.length < 1) return + const newImageUrls: any = [] + images.forEach((image: any) => + newImageUrls.push(URL.createObjectURL(image)) + ) + setImageURLs(newImageUrls) + }, [images]) + + function onImageChange(e: any) { + setImages([...e.target.files]) + setLogo(e.target.files[0]) + // console.log(e); + } + return ( -
    - - +
    + + Cliente cadastrada com Sucesso! - - + + Cliente não cadastrado! - - + + Cliente excluido com sucesso! - - + + Cliente não excluido! -
    - -
    - - +
    + +
    + +
    - { - setSelectedClients(value) - }}/> + { + setSelectedClients(value) + }} + />
    - -

    Adicionar Cliente

    - - Adicionar Cliente Smart Energia -
    - { - setClient({ - ...client, - name: value.target.value - }) - }} variant="outlined" /> - { - setClient({ - ...client, - email: value.target.value.toLowerCase() - }) - }} variant="outlined" /> - { - setClient({ - ...client, - password: value.target.value - }) - }} variant="outlined" /> - { - setClient({ - ...client, - password_confirmation: value.target.value - }) - }} variant="outlined" /> - { - setClient({ - ...client, - client_id: value.target.value - }) - }} variant="outlined" /> - + +

    Adicionar Cliente

    + + Adicionar Cliente Smart Energia + +
    + { + setClient({ + ...client, + name: value.target.value + }) + }} + variant="outlined" + /> + { + setClient({ + ...client, + email: value.target.value.toLowerCase() + }) + }} + variant="outlined" + /> + { + setClient({ + ...client, + password: value.target.value + }) + }} + variant="outlined" + /> + { + setClient({ + ...client, + password_confirmation: value.target.value + }) + }} + variant="outlined" + /> + { + setClient({ + ...client, + client_id: value.target.value + }) + }} + variant="outlined" + /> + +
    +
    + {imageURLS.map((imageSrc, index) => ( + + ))} +
    +
    +
    +
    +
    + + +
    +
    +
    +
    -
    -
    -
    +
    -
    + + Nivel de acesso + + +
    -
    -
    - - -
    -
    -
    - - -

    - setOpen(false)} /> - handleCreateClient(client)}/> - + setOpen(false)} /> + handleCreateClient(client)} + /> + - {setOpenModalInativar(value)}}> - + { + setOpenModalInativar(value) + }} + > + - handleDeleteClient(selectedClients)}/> - setOpenModalInativar(false)}/> + handleDeleteClient(selectedClients)} + /> + setOpenModalInativar(false)} + />
    @@ -238,15 +401,18 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) - let clients = []; + let clients = [] - await apiClient.get('/user').then(res => { - // console.log(res) - clients = res.data.data - // console.log(clients) - }).catch(res => { - // console.log(res) - }) + await apiClient + .get('/user') + .then((res) => { + // console.log(res) + clients = res.data.data + // console.log(clients) + }) + .catch((res) => { + // console.log(res) + }) if (!token) { return { diff --git a/src/pages/administrative/faq/index.tsx b/src/pages/administrative/faq/index.tsx index b7e428d..ecb3093 100644 --- a/src/pages/administrative/faq/index.tsx +++ b/src/pages/administrative/faq/index.tsx @@ -66,7 +66,6 @@ export default function Sidebar({faqData, userName} : any ) { if (reason === 'clickaway') { return; } - setOpenSnackError(false); setOpenSnackSuccess(false); }; @@ -76,14 +75,13 @@ export default function Sidebar({faqData, userName} : any ) { if (reason === 'clickaway') { return; } - setOpenSnackErrorDelete(false); setOpenSnackSuccessDelete(false); }; async function handleDeleteNotification(id: any) { await id.map((value) => { - api.delete(`/faq/${value.id}`).then(res => { + api.delete(`/faq/${value}`).then(res => { setOpenSnackSuccessDelete(true) setOpenModalInativar(false) window.location.reload() diff --git a/src/pages/administrative/general.tsx b/src/pages/administrative/general.tsx index 1d5b7bf..9b349e8 100644 --- a/src/pages/administrative/general.tsx +++ b/src/pages/administrative/general.tsx @@ -1,21 +1,30 @@ -import FormControl from '@mui/material/FormControl'; -import InputLabel from '@mui/material/InputLabel'; -import MenuItem from '@mui/material/MenuItem'; -import Select, { SelectChangeEvent } from '@mui/material/Select'; -import TextField from '@mui/material/TextField'; +import { SelectChangeEvent } from '@mui/material/Select'; import { Editor } from '@tinymce/tinymce-react' import { GetServerSideProps } from 'next'; import { parseCookies } from 'nookies'; import React, { useRef, useState } from 'react' - +import BasicButton from '../../components/buttons/basicButton/BasicButton'; 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()); @@ -26,13 +35,65 @@ 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: text + }) + .then(res => setOpenSnackSuccess(true)) + .catch(res => setOpenSnackError(false)) + } + return ( + + + Cadastrado com Sucesso! + + + + + Não cadastrado! + +
    +
    + handleRegisterAboutUs()}/> +
    +
    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.

    @@ -70,6 +131,8 @@ export default function index({userName}: any) { content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }' }} /> + + ) } diff --git a/src/pages/administrative/industryInfo/index.tsx b/src/pages/administrative/industryInfo/index.tsx index 5cdf3bb..432fe3d 100644 --- a/src/pages/administrative/industryInfo/index.tsx +++ b/src/pages/administrative/industryInfo/index.tsx @@ -8,6 +8,7 @@ import PageTitle from '../../../components/pageTitle/PageTitle' import { IndustryInfoView } from '../../../styles/layouts/industryInfo/IndustryInfoView' import InputUploadPdf from '../../../components/inputUploadPdf/inputUpload'; import { api } from '../../../services/api' +import PdfThumbnail from 'react-pdf-thumbnail'; import FormData from 'form-data'; @@ -28,6 +29,7 @@ export default function industryInfo({userName}: any) { const [pdf, setPdf] = useState(); function onChange(e) { setPdf(e.target.files[0]) + console.log(pdf) } const [openSnackSuccess, setOpenSnackSuccess] = useState(false); @@ -70,17 +72,10 @@ export default function industryInfo({userName}: any) {
    - -
    -
    -
    - - -
    -
    -
    -
    - {/* */} +
    + + +
    handleCreateClient()} title='Atualizar'/> diff --git a/src/pages/chartTelemetry.tsx b/src/pages/chartTelemetry.tsx index 343af3f..a3fc940 100644 --- a/src/pages/chartTelemetry.tsx +++ b/src/pages/chartTelemetry.tsx @@ -1,7 +1,7 @@ -import React, { useState } from 'react' +import React, { useEffect, useState } from 'react' import { SingleBar } from '../components/graph/SingleBar' import { ChatTelemetryView } from '../styles/layouts/ChatTelemetry/ChatTelemetryView' -import { useRouter } from 'next/router' +// import router, { useRouter } from 'next/router' import { FatorPotencia } from '../services/fatorPotencia' import { ConsumoDecretizadoBar } from '../services/consumoDiscretizadoBar' @@ -18,6 +18,14 @@ import Typography from '@mui/material/Typography'; import Modal from '@mui/material/Modal'; import { GetServerSideProps } from 'next' import { parseCookies } from 'nookies' +import getAPIClient from '../services/ssrApi' +import { api } from '../services/api' +import FatorPotenciaChart from '../components/graph/fatorPotenciaChart' +// import { DemRegXDemConChart } from '../components/graph/demRegXDemConChart' +import { DiscretizedConsumptionChart } from '../components/graph/DiscretizedConsumptionChart' +import DiscretizedConsumptionChartLine from '../components/graph/DiscretizedConsumptionChartLine' +import router, { useRouter } from 'next/router' +import { DemRegXDemConChart } from '../components/graph/DemRegXDemConChart' const style = { display: 'flex', @@ -45,6 +53,70 @@ export default function chartTelemetry({userName}) { const [openDemandaContratada, setOpenDemandaContratada] = useState(false); const handleCloseDemandaContratada = () => setOpenDemandaContratada(false); + const [fatorPotenciaData, setFatorPotenciaData] = useState([]); + const [demRegXDemCon, setDemRegXDemCon] = useState([]); + const [discretizedConsumptionData, setDiscretizedConsumptionData] = useState([]); + const [discretizedConsumptionDataReativa, setDiscretizedConsumptionDataReativa] = useState([]); + + const { ['user-cod_client']: cod_client } = parseCookies() + + const router = useRouter() + + const {startDate, endDate} = router.query + + async function getChartsData() { + console.log(router.query) + await api.post('/telemetry/powerFactor', { + "filters": [ + {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, + {"type" : "between", "field": "dia_num", "value": [startDate, endDate]} + ] + }).then(res => { + setFatorPotenciaData(res.data.data) + }).catch(res => { + console.log(res) + }) + + await api.post('/telemetry/demand', { + "filters": [ + {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, + {"type" : "between", "field": "dia_num", "value": [startDate, endDate]} + ] + }).then(res => { + setDemRegXDemCon(res.data.data) + }).catch(res => { + console.log(res) + }) + + await api.post('/telemetry/discretization', { + "type": "5_min", + "filters": [ + {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, + {"type" : "between", "field": "dia_num", "value": [startDate, endDate]} + ] + }).then(res => { + setDiscretizedConsumptionData(res.data.data) + }).catch(res => { + console.log(res) + }) + + await api.post('/telemetry/discretization', { + "type": "5_min", + "filters": [ + {"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"}, + {"type" : "between", "field": "dia_num", "value": ["2022-01-03", "2022-01-03"]} + ] + }).then(res => { + setDiscretizedConsumptionDataReativa(res.data.data) + }).catch(res => { + console.log(res) + }) + } + + useEffect(() => { + getChartsData() + }, []) + return ( @@ -54,7 +126,7 @@ export default function chartTelemetry({userName}) {
    setOpenFatorPotencia(true)}> - + value.hora)} />
    - +
    setOpenConsumoDiscretizado1(true)}> - + parseFloat(data.reativa).toFixed(3))} />
    - + data.reativa)} />
    setOpenConsumoDiscretizado2(true)}> - + value.minut)} dataset={'Consumo'} dataset1='Estimado' month/>
    - +
    setOpenDemandaContratada(true)}> - + value.hora)} title='Demanda Contratada X Registrada' subtitle='' red/>
    - + value.hora)} title='Demanda Contratada X Registrada' subtitle='' red/>
    @@ -114,8 +186,26 @@ export default function chartTelemetry({userName}) { } export const getServerSideProps: GetServerSideProps = async (ctx) => { + const apiClient = getAPIClient(ctx) + const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) + const { ['user-cod_client']: cod_client } = parseCookies(ctx) + + const fatorPotenciaChart = [] + + console.log('olha os query ai', ctx.query) + + // await apiClient.post('/telemetry/powerFactor', { + // "filters": [ + // {"type" : "=", "field": "med_5min.ponto", "value": cod_client}, + // {"type" : "between", "field": "dia_num", "value": ["2022-01-03", "2022-01-03"]} + // ] + // }).then(res => { + // fatorPotenciaChart = res.data + // }).catch(res => { + // console.log(res) + // }) if (!token) { return { @@ -128,8 +218,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { return { props: { - userName + userName, + fatorPotenciaChart } } } - 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/dashboard.tsx b/src/pages/dashboard.tsx index 3c234a4..c3bdc50 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -44,29 +44,29 @@ export default function Dashboard({grossAnualGraph, grossAnualYears, grossMensal
    - - + + label={grossAnualYears} barLabel/> - - + + barLabel/> - + + title='' subtitle='' barLabel hashurado/> - 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 596c9ef..aee288f 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -36,10 +36,10 @@ export default function Home() { const [state, setstate] = useState(false); const [values, setValues] = useState({ - password: null, showPassword: false, }); + const [email, setEmail] = useState("") const [password, setPassword] = useState() @@ -128,7 +128,7 @@ export default function Home() { setEmail(value.target.value.toLowerCase()) }}/> - Password + Senha } - label="Password" + label="Senha" /> Esqueceu a senha ? diff --git a/src/pages/industryInfo.tsx b/src/pages/industryInfo.tsx index c387fb4..21b569c 100644 --- a/src/pages/industryInfo.tsx +++ b/src/pages/industryInfo.tsx @@ -35,7 +35,7 @@ export default function industryInfo({userName}: any) { function handleDownloadPdf() { api.get('/download').then(res => { - router.replace(res.data.path); + window.open(res.data.path); console.log(res.data); setOpenSnackSuccess(true) }).catch(res => { 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 79a547c..66219bb 100644 --- a/src/pages/pld/index.tsx +++ b/src/pages/pld/index.tsx @@ -10,6 +10,7 @@ import { parseCookies } from 'nookies'; import React, { useEffect, useState } from 'react' import BasicButton from '../../components/buttons/basicButton/BasicButton'; +import { BasicButtonView } from '../../components/buttons/basicButton/BasicButtonView'; import { LineBarChart } from '../../components/graph/LineBarChart'; import LineChart from '../../components/graph/LineChart'; import Header from '../../components/header/Header' @@ -127,6 +128,41 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN return 'dullRed' } + const dateFormated = new Date() + + function downloadCSVFile(csv, filename) { + const csv_file = new Blob([csv], {type: "text/csv"}); + + const download_link = document.createElement("a"); + + download_link.download = filename; + + download_link.href = window.URL.createObjectURL(csv_file); + + download_link.style.display = "none"; + + document.body.appendChild(download_link); + + download_link.click(); + } + + function htmlToCSV(html, filename) { + const data = []; + const rows = document.querySelectorAll("table tr"); + + for (let i = 0; i < rows.length; i++) { + const row = [], cols: any = rows[i].querySelectorAll("td, th"); + + for (let j = 0; j < cols.length; j++) { + row.push(cols[j].innerText); + } + + data.push(row.join(",")); + } + + downloadCSVFile(data.join("\n"), filename); + } + useEffect(() => { getDataByHour() getDataByDay() @@ -157,7 +193,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} @@ -174,7 +215,7 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN if (index === 0) { return <> - Max + Máximo {parseFloat(data.nordeste_max).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} {parseFloat(data.norte_max).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} {parseFloat(data.sudeste_max).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} @@ -184,7 +225,7 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN } else if (index===1) { return <> - Min + Mínimo {parseFloat(data.nordeste_min).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} {parseFloat(data.norte_min).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} {parseFloat(data.sudeste_min).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} @@ -206,7 +247,14 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN } +
    + { + const html = document.querySelector("table").outerHTML; + htmlToCSV(html, "tabela_PLD.csv"); + }} title='Download'/> +
    +
    setPage('perMouth')}>

    Valores Diários

    @@ -244,9 +292,9 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
    + width: '22%', + ml: 1 + }}> Mês setStartDate(value.target.value)} - fullWidth - > - - Nenhum - - 20/05/2022 - 10/06/2022 - 05/06/2021 - 05/06/2021 - 05/06/2021 - - + setStartDate(value.target.value)}/>
    -

    Data Final

    - - Data Final - - +

    Data final

    + + setEndDate(value.target.value)}/>
    @@ -133,10 +95,6 @@ export default function Telemetria({userName}: any) { Nenhum - 07/09/2021 - Filial 3 - Twenty - Thirty
    @@ -147,7 +105,21 @@ export default function Telemetria({userName}: any) {
    - + + {/* */} + + + {/* router.replace('/chartTelemetry')}/> */} setShowChart(!showChart)} green /> diff --git a/src/services/auth.ts b/src/services/auth.ts index 52640dc..9fec2a0 100644 --- a/src/services/auth.ts +++ b/src/services/auth.ts @@ -14,9 +14,10 @@ interface SignInRequestData { type UserObjectType = { name: string; email: string; - client_id: number - id: number, - role: number + client_id: number; + id: number; + role: number; + profile_picture?: string } export async function signInRequest(data: SignInRequestData) { @@ -33,7 +34,8 @@ export async function signInRequest(data: SignInRequestData) { email: res.data.user.email, client_id: res.data.user.client_id, id: res.data.user.id, - role: res.data.user.roles[0].pivot.role_id + role: res.data.user.roles[0].pivot.role_id, + profile_picture: res.data.user.profile_picture } }).catch(res => { exception = res @@ -46,7 +48,8 @@ export async function signInRequest(data: SignInRequestData) { email: user?.email, client_id: user?.client_id, id: user?.id, - role: user?.role + role: user?.role, + profile_picture: user?.profile_picture }, exception } @@ -62,7 +65,8 @@ export default async function recoverUserInformation(id) { email: res.data.user.email, client_id: res.data.user.client_id, id: res.data.user.id, - role: res.data.user.roles[0].pivot.role_id + role: res.data.user.roles[0].pivot.role_id, + profile_picture: res.data.user.profile_picture } }).catch(res => { console.log(res) @@ -73,7 +77,8 @@ export default async function recoverUserInformation(id) { name: user?.name, email: user?.email, client_id: user?.client_id, - id: user?.id + id: user?.id, + profile_picture: user?.profile_picture } } } diff --git a/src/styles/layouts/Telemetria/TelemetriaView.ts b/src/styles/layouts/Telemetria/TelemetriaView.ts index fb3f214..77238d0 100644 --- a/src/styles/layouts/Telemetria/TelemetriaView.ts +++ b/src/styles/layouts/Telemetria/TelemetriaView.ts @@ -12,6 +12,21 @@ export const TelemetriaView = styled.main` margin: 0 0 0 10px; } + input { + width: 15rem; + height: 2.5rem; + + padding: 14px; + + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; + font-weight: 400; + + border-radius: 6px; + border: solid gray 1px; + + background-color: #F9F9F9; + } + span { font-family: 'Inter'; font-style: normal; @@ -65,6 +80,58 @@ export const Buttons = styled.div` padding-left: 100px; padding-right: 100px; + button { + display: flex; + justify-content: center; + align-items: center; + + flex-direction: column; + border-radius: 2px; + + width: 30%; + min-width: 240px; + height: 110px; + min-height: 110px; + margin-bottom: 25px; + + font-family: 'Poppins'; + font-size: 10px; + + color: #FFFFFF; + + :first-child { + background: linear-gradient(200.86deg, #F48665 8.03%, #F48665 91.97%), #FFFFFF; + } + + box-shadow: 0.5px 3px 10px rgba(119, 119, 119, 0.1); + + border-style: none; + + * { + margin: 0; + padding: 0; + } + + p { + :first-child { + font-family: 'Poppins'; + font-style: normal; + font-weight: 700; + font-size: calc(20px); + + text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25); + } + :last-child { + font-family: 'Poppins'; + font-style: normal; + font-weight: 700; + font-size: 12; + + text-transform: uppercase; + } + } + } + @media (max-width: 942px) { align-items: center; justify-content: center; diff --git a/src/styles/layouts/aboutUs/AboutUsView.ts b/src/styles/layouts/aboutUs/AboutUsView.ts index d53880e..76e14a3 100644 --- a/src/styles/layouts/aboutUs/AboutUsView.ts +++ b/src/styles/layouts/aboutUs/AboutUsView.ts @@ -22,21 +22,19 @@ export const AboutUsView = styled.main` } } - section { - article { + article { + display: flex; + justify-content: flex-end; + align-items: center; + + aside { display: flex; - justify-content: flex-end; + justify-content: center; align-items: center; - aside { - display: flex; - justify-content: center; - align-items: center; + width: fit-content; - width: fit-content; - - flex-direction: column; - } + flex-direction: column; } } diff --git a/src/styles/layouts/administerView/faq/faqView.ts b/src/styles/layouts/administerView/faq/faqView.ts index 7680a37..5c2be1b 100644 --- a/src/styles/layouts/administerView/faq/faqView.ts +++ b/src/styles/layouts/administerView/faq/faqView.ts @@ -42,6 +42,23 @@ export const FaqView = styled.nav` margin-left: 19px; } + .MuiBox-root .css-4y2i0o { + :-webkit-scrollbar { + width: 15px!important; + } + :-webkit-scrollbar-track { + background-color: #EFEFEF!important; + } + :-webkit-scrollbar-thumb { + background-color: rgb(37,79,127)!important; + border: 3px solid #EFEFEF!important; + border-radius: 10px!important + } + :-webkit-scrollbar-thumb:hover { + background-color: #1d3e63!important; + } + } + /* .teste{ display: flex; diff --git a/src/styles/layouts/administerView/notification/notificationView.ts b/src/styles/layouts/administerView/notification/notificationView.ts index cc0aca2..b57f4d9 100644 --- a/src/styles/layouts/administerView/notification/notificationView.ts +++ b/src/styles/layouts/administerView/notification/notificationView.ts @@ -77,7 +77,21 @@ export const NotificationView = styled.nav` margin-left: 16px; } - - + .MuiBox-root .css-4y2i0o { + :-webkit-scrollbar { + width: 15px!important; + } + :-webkit-scrollbar-track { + background-color: #EFEFEF!important; + } + :-webkit-scrollbar-thumb { + background-color: rgb(37,79,127)!important; + border: 3px solid #EFEFEF!important; + border-radius: 10px!important + } + :-webkit-scrollbar-thumb:hover { + background-color: #1d3e63!important; + } + } ` diff --git a/src/styles/layouts/industryInfo/IndustryInfoView.ts b/src/styles/layouts/industryInfo/IndustryInfoView.ts index 811d516..624cc92 100644 --- a/src/styles/layouts/industryInfo/IndustryInfoView.ts +++ b/src/styles/layouts/industryInfo/IndustryInfoView.ts @@ -26,4 +26,60 @@ export const IndustryInfoView = styled.main` color: #FFFFFF; } + + form { + label { + display: flex; + align-items: center; + justify-content: center; + position: absolute; + width: 150px; + margin-left: 10px; + transform: translateY(20px); + background-color: #254F7F; + color: white; + border-radius: 8px; + } + } + + input[type="file"] { + padding-top: 20px; + padding-left: 41px; + width: 350px; + height: 60px; + border: 1px solid black; + border-radius: 6px; + } + label { + } + + /* .inputTeste{ + display: flex; + align-items: center; + width: 50%; + height: 50px; + background: white; + border-radius:10px; + } + + input[type="file"] { + display: block; + } + + label { + display: flex; + justify-content: flex-start; + padding: 2px 10px; + width: 200px; + background-color: #333; + color: #FFF; + text-transform: uppercase; + text-align: center; + display: block; + margin-top: 10px; + cursor: pointer; + } */ + + + ` diff --git a/src/styles/layouts/pld/PldView.ts b/src/styles/layouts/pld/PldView.ts index 539ec3f..d9239cf 100644 --- a/src/styles/layouts/pld/PldView.ts +++ b/src/styles/layouts/pld/PldView.ts @@ -149,6 +149,10 @@ export const PldTableView = styled.main` margin: 20px; } } + + .btnDownload{ + margin-top:6px; + } ` export const PldGraphView = styled.main` diff --git a/yarn.lock b/yarn.lock index 388eeb8..65ed182 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1390,6 +1390,11 @@ version "2.11.5" resolved "https://registry.npmjs.org/@popperjs/core/-/core-2.11.5.tgz" +"@react-pdf-viewer/core@^3.5.0": + version "3.5.0" + resolved "https://registry.yarnpkg.com/@react-pdf-viewer/core/-/core-3.5.0.tgz#bb18b87330bfd01d5c31980b820ef58dc1c50a19" + integrity sha512-fu9vi8lzpFtQQqu8XUzSzp5aQYD5YxmJQ0CxOuRrANU7z1kft+TbdyiDOpWoeX2VC0/oyclBxUwleVYv+g1f1w== + "@rushstack/eslint-patch@^1.1.3": version "1.1.3" resolved "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.1.3.tgz" @@ -2240,6 +2245,11 @@ dom-helpers@^5.0.1: "@babel/runtime" "^7.8.7" csstype "^3.0.2" +dommatrix@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/dommatrix/-/dommatrix-1.0.3.tgz#e7c18e8d6f3abdd1fef3dd4aa74c4d2e620a0525" + integrity sha512-l32Xp/TLgWb8ReqbVJAFIvXmY7go4nTxxlWiAFyhoQw9RKEOHBZNnyGvJWqDVSPmq3Y9HlM4npqF/T6VMOXhww== + eastasianwidth@^0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz" @@ -4001,6 +4011,14 @@ patternomaly@^1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/patternomaly/-/patternomaly-1.3.2.tgz#70b8db17d7318ab1471cc43f94011bb866c54d09" +pdfjs-dist@^2.7.570: + version "2.14.305" + resolved "https://registry.yarnpkg.com/pdfjs-dist/-/pdfjs-dist-2.14.305.tgz#ed2ecb439ff8af5446c90a310ebd30bc1a91df62" + integrity sha512-5f7i25J1dKIBczhgfxEgNxfYNIxXEdxqo6Qb4ehY7Ja+p6AI4uUmk/OcVGXfRGm2ys5iaJJhJUwBFwv6Jl/Qww== + dependencies: + dommatrix "^1.0.1" + web-streams-polyfill "^3.2.1" + picocolors@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz" @@ -4140,6 +4158,13 @@ react-is@^16.13.1, react-is@^16.7.0: version "17.0.2" resolved "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz" +react-pdf-thumbnail@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/react-pdf-thumbnail/-/react-pdf-thumbnail-0.1.0.tgz#6b8ddf861252acb2b137dfd42007f545fde52ef9" + integrity sha512-VzkGUmgAheqxQsMTcUjOFrATtEdG2C9YRkMb0GFkf9JyfTDdBjkyu1/gVLk9CYVKWkgyNID34/G0TTX60XJuyA== + dependencies: + pdfjs-dist "^2.7.570" + react-transition-group@^4.4.0, react-transition-group@^4.4.2: version "4.4.2" resolved "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.2.tgz" @@ -4764,6 +4789,11 @@ wcwidth@^1.0.0: dependencies: defaults "^1.0.3" +web-streams-polyfill@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz#71c2718c52b45fd49dbeee88634b3a60ceab42a6" + integrity sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q== + which-boxed-primitive@^1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz"