diff --git a/src/components/administrativeTables/ClientsTable.tsx b/src/components/administrativeTables/ClientsTable.tsx index 7216450..a56a973 100644 --- a/src/components/administrativeTables/ClientsTable.tsx +++ b/src/components/administrativeTables/ClientsTable.tsx @@ -45,7 +45,7 @@ function getComparator( : (a, b) => -descendingComparator(a, b, orderBy); } -function stableSort(array: readonly T[], comparator: (a: T, b: T) => number) { +function stableSort(array: any, comparator: (a: T, b: T) => number) { const stabilizedThis = array.map((el, index) => [el, index] as [T, number]); stabilizedThis.sort((a, b) => { const order = comparator(a[0], b[0]); diff --git a/src/components/graph/Chart.tsx b/src/components/graph/Chart.tsx index f532103..4b2a681 100644 --- a/src/components/graph/Chart.tsx +++ b/src/components/graph/Chart.tsx @@ -71,14 +71,14 @@ export default function Chart({ title, data1, data2, label, subtitle, dataset1, labels, datasets: [ { - label: dataset1? dataset1 : '2020', - data: data1.map(value => value), + label: dataset1? dataset1 : '2021', + data: data1.map(value => value.custo_unit), backgroundColor: '#C2D5FB', }, data2? { - label: dataset2? dataset2 : '2021', - data: data2.map(value => value), + label: dataset2? dataset2 : '2022', + data: data2.map(value => value.custo_unit), backgroundColor: '#255488', } : null ], diff --git a/src/components/inputUplaod/inputUpload.tsx b/src/components/inputUplaod/inputUpload.tsx index 5eb22ab..dad71d1 100644 --- a/src/components/inputUplaod/inputUpload.tsx +++ b/src/components/inputUplaod/inputUpload.tsx @@ -16,7 +16,7 @@ export default function InputUpload() { function onImageChange(e: any) { setImages([...e.target.files]); - console.log(e); + // console.log(e); } return ( diff --git a/src/components/sidebar/Sidebar.tsx b/src/components/sidebar/Sidebar.tsx index 1f08998..271bf62 100644 --- a/src/components/sidebar/Sidebar.tsx +++ b/src/components/sidebar/Sidebar.tsx @@ -37,7 +37,7 @@ export default function Sidebar() { const { ['user-role']: role } = parseCookies() - console.log(role) + // console.log(role) useEffect(() => { setViewModal(false) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index ed63084..9a5ef4a 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -59,7 +59,6 @@ function MyApp({ Component, pageProps }: AppProps) { <> - : null diff --git a/src/pages/administrative/clients/index.tsx b/src/pages/administrative/clients/index.tsx index 2d918c9..7a612e6 100644 --- a/src/pages/administrative/clients/index.tsx +++ b/src/pages/administrative/clients/index.tsx @@ -213,9 +213,11 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { let clients = []; await apiClient.get('/user').then(res => { - clients = res.data - }).catch(res => { console.log(res) + clients = res.data.data + console.log(clients) + }).catch(res => { + // console.log(res) }) if (!token) { @@ -233,4 +235,3 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { } } } - diff --git a/src/pages/administrative/faq/index.tsx b/src/pages/administrative/faq/index.tsx index 6f2cae5..3d28598 100644 --- a/src/pages/administrative/faq/index.tsx +++ b/src/pages/administrative/faq/index.tsx @@ -109,16 +109,14 @@ export default function Sidebar({faqData}: any) { export const getServerSideProps: GetServerSideProps = async (ctx) => { const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) - console.log('teste') + let faqData = []; - -await apiClient.get('/faq').then(res => { - faqData = res.data -}).catch(res => { - console.log(res) -}) - console.table(faqData); + await apiClient.get('/faq').then(res => { + faqData = res.data.data + }).catch(res => { + // console.log(res) + }) if (!token) { return { diff --git a/src/pages/administrative/index.tsx b/src/pages/administrative/index.tsx index 9aeb2e6..d270917 100644 --- a/src/pages/administrative/index.tsx +++ b/src/pages/administrative/index.tsx @@ -19,57 +19,6 @@ export default function clients() { return (
- -
- - -
- setOpenModal(true)}/> - setOpenModalInativar(true)}/> -
- -
- {/* */} - -
- - - {setOpenModal(value)}}> - - -
- - - - - console.log()}/> - -
-
-
- - {setOpenModalInativar(value)}}> - - setOpenModalInativar(true)}/> - setOpenModalInativar(true)}/> - -
) } diff --git a/src/pages/administrative/notification/index.tsx b/src/pages/administrative/notification/index.tsx index 0be9966..50751fc 100644 --- a/src/pages/administrative/notification/index.tsx +++ b/src/pages/administrative/notification/index.tsx @@ -252,13 +252,13 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { await apiClient.get('/user').then(res => { clients = res.data }).catch(res => { - console.log(res) + // console.log(res) }) await apiClient.get('/notification').then(res => { - notifications = res.data + notifications = res.data.data }).catch(res => { - console.log(res) + // console.log(res) }) if (!token) { diff --git a/src/pages/costIndicator.tsx b/src/pages/costIndicator.tsx index 8a35d0b..405c453 100644 --- a/src/pages/costIndicator.tsx +++ b/src/pages/costIndicator.tsx @@ -1,4 +1,6 @@ +import { GetServerSideProps } from 'next' import Head from 'next/head' +import { parseCookies } from 'nookies' import React from 'react' import Chart from '../components/graph/Chart' @@ -7,9 +9,23 @@ 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' -export default function CostIndicator() { +function addMissingMonths(data) { + console.log(data[0].mes.slice(1, 1)) +} + +function verifyDataByYear(data) { + if (data.length === 12) + return true + else + return false +} + +export default function CostIndicator({graphData}: any) { + console.log(graphData.filter((value, index) => value.mes.slice(3, 7).includes('2021')).map(value => value.custo_unit)) + return ( @@ -18,8 +34,39 @@ export default function CostIndicator() {
- + value.mes.slice(3, 7).includes('2021'))} + data2={graphData.filter((value, index) => value.mes.slice(3, 7).includes('2022'))} + label={['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'ago', 'set', 'out', 'nov', 'dez']} barLabel />
) } + +export const getServerSideProps: GetServerSideProps = async (ctx) => { + const apiClient = getAPIClient(ctx) + const { ['@smartAuth-token']: token } = parseCookies(ctx) + + let graphData = []; + + await apiClient.post('/economy/MWh').then(res => { + graphData = res.data.data + console.log(graphData[0].mes) + }).catch(res => { + console.log(res) + }) + + if (!token) { + return { + redirect: { + destination: '/', + permanent: false + } + } + } + + return { + props: { + graphData, + } + } +} diff --git a/src/pages/faq.tsx b/src/pages/faq.tsx index c1e3a41..e7b90d4 100644 --- a/src/pages/faq.tsx +++ b/src/pages/faq.tsx @@ -34,16 +34,14 @@ export default function commonQuestions({faqData}) { export const getServerSideProps: GetServerSideProps = async (ctx) => { const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) - console.log('teste') let faqData = []; -await apiClient.get('/faq').then(res => { - faqData = res.data -}).catch(res => { - console.log(res) -}) - console.table(faqData); + await apiClient.get('/faq').then(res => { + faqData = res.data + }).catch(res => { + // console.log(res) + }) if (!token) { return { diff --git a/src/pages/index.tsx b/src/pages/index.tsx index e51acfe..6229b84 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -101,7 +101,6 @@ export default function Home() {

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

- ) } diff --git a/src/pages/notifications.tsx b/src/pages/notifications.tsx index 2c1e8f7..c321efc 100644 --- a/src/pages/notifications.tsx +++ b/src/pages/notifications.tsx @@ -34,16 +34,14 @@ export default function Notifications({notificationData}: any) { export const getServerSideProps: GetServerSideProps = async (ctx) => { const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) - console.log('teste') + let notificationData = []; - -await apiClient.get('/notification').then(res => { - notificationData = res.data -}).catch(res => { - console.log(res) -}) - console.table(notificationData); + await apiClient.get('/notification').then(res => { + notificationData = res.data + }).catch(res => { + // console.log(res) + }) if (!token) { return { diff --git a/src/pages/pld/index.tsx b/src/pages/pld/index.tsx index 75b29fb..7284c72 100644 --- a/src/pages/pld/index.tsx +++ b/src/pages/pld/index.tsx @@ -1,8 +1,10 @@ import MenuItem from '@mui/material/MenuItem'; import Select, { SelectChangeEvent } from '@mui/material/Select'; +import { GetServerSideProps } from 'next'; import Head from 'next/head'; import Link from 'next/link'; import { useRouter } from 'next/router' +import { parseCookies } from 'nookies'; import React, { useEffect, useState } from 'react' import BasicButton from '../../components/buttons/basicButton/BasicButton'; @@ -13,10 +15,17 @@ import Header from '../../components/header/Header' import PageTitle from '../../components/pageTitle/PageTitle'; import { EconomiaAcumulada } from '../../services/economiaAcumulada'; import { EvolucaoPld } from '../../services/evolucaoPld'; +import getAPIClient from '../../services/ssrApi'; import { GoBack, PldGraphView, PldTableView } from '../../styles/layouts/pld/PldView' import RenderIf from '../../utils/renderIf' -export default function region() { +interface pldInterface { + tableData: any, + graphByHourData: any, + graphByMonthData: any +} + +export default function pld({tableData, graphByHourData, graphByMonthData}: pldInterface) { const router = useRouter() const { region } = router.query @@ -68,97 +77,19 @@ export default function region() { - - 2101 - xxxx - xxxx - xxxx - xxxx - - - 2102 - xxxx - xxxx - xxxx - xxxx - - - 2103 - xxxx - xxxx - xxxx - xxxx - - - 2104 - xxxx - xxxx - xxxx - xxxx - - - 2105 - xxxx - xxxx - xxxx - xxxx - - - 2106 - xxxx - xxxx - xxxx - xxxx - - - 2107 - xxxx - xxxx - xxxx - xxxx - - - 2108 - xxxx - xxxx - xxxx - xxxx - - - 2109 - xxxx - xxxx - xxxx - xxxx - - - 2110 - xxxx - xxxx - xxxx - xxxx - - - 2111 - xxxx - xxxx - xxxx - xxxx - - - 2112 - xxxx - xxxx - xxxx - xxxx - - - 2021 - xxxx - xxxx - xxxx - xxxx - + { + tableData.map(data => { + return <> + + {data.year_month_formatted} + {data.nordeste} + {data.norte} + {data.sudeste} + {data.sul} + + + }) + } Mín xxxx @@ -234,3 +165,31 @@ export default function region() { ) } + +export const getServerSideProps: GetServerSideProps = async (ctx) => { + const apiClient = getAPIClient(ctx) + const { ['@smartAuth-token']: token } = parseCookies(ctx) + + let tableData = []; + + await apiClient.post('/pld/list').then(res => { + tableData = res.data + }).catch(res => { + console.log(res) + }) + + if (!token) { + return { + redirect: { + destination: '/', + permanent: false + } + } + } + + return { + props: { + tableData, + } + } +} diff --git a/src/pages/resumoOperacao.tsx b/src/pages/resumoOperacao.tsx index a64cb7b..43eadd5 100644 --- a/src/pages/resumoOperacao.tsx +++ b/src/pages/resumoOperacao.tsx @@ -49,7 +49,7 @@ export default function ResumoOperacao() { // data.unidades.map((value) => { // console.log(`olha o valor ${value.name}`) // }) - console.log(unidade) + // console.log(unidade) console.log(data.unidades.filter((value, index)=> value.value.includes(unidade))) }, [month, unidade])