starting clients charts
This commit is contained in:
parent
93309759d3
commit
b045a2e541
@ -45,7 +45,7 @@ function getComparator<Key extends keyof any>(
|
||||
: (a, b) => -descendingComparator(a, b, orderBy);
|
||||
}
|
||||
|
||||
function stableSort<T>(array: readonly T[], comparator: (a: T, b: T) => number) {
|
||||
function stableSort<T>(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]);
|
||||
|
||||
@ -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
|
||||
],
|
||||
|
||||
@ -16,7 +16,7 @@ export default function InputUpload() {
|
||||
|
||||
function onImageChange(e: any) {
|
||||
setImages([...e.target.files]);
|
||||
console.log(e);
|
||||
// console.log(e);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -37,7 +37,7 @@ export default function Sidebar() {
|
||||
|
||||
const { ['user-role']: role } = parseCookies()
|
||||
|
||||
console.log(role)
|
||||
// console.log(role)
|
||||
|
||||
useEffect(() => {
|
||||
setViewModal(false)
|
||||
|
||||
@ -59,7 +59,6 @@ function MyApp({ Component, pageProps }: AppProps) {
|
||||
<>
|
||||
<Sidebar />
|
||||
<Component {...pageProps} />
|
||||
|
||||
</>
|
||||
:
|
||||
null
|
||||
|
||||
@ -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) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -19,57 +19,6 @@ export default function clients() {
|
||||
|
||||
return (
|
||||
<div style={{display: 'flex', flexDirection: 'column', width: '100%'}}>
|
||||
<ClientsView>
|
||||
<Header name='' />
|
||||
<PageTitle title='Clientes' subtitle='Clientes Smart Energia'/>
|
||||
|
||||
<section>
|
||||
<BasicButton title='Adicionar' onClick={() => setOpenModal(true)}/>
|
||||
<BasicButton title='Inativar' onClick={() => setOpenModalInativar(true)}/>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
{/* <DataGrid
|
||||
rows={rows}
|
||||
columns={columns}
|
||||
pageSize={6}
|
||||
rowsPerPageOptions={[6]}
|
||||
checkboxSelection
|
||||
/> */}
|
||||
<ClientsTable />
|
||||
</section>
|
||||
</ClientsView>
|
||||
|
||||
<Modal open={openModal} handleIsClose={(value) => {setOpenModal(value)}}>
|
||||
<ClientsModalView>
|
||||
<PageTitle title='Adicionar Cliente' subtitle='Adicionar Cliente Smart Energia'/>
|
||||
<article>
|
||||
<TextField id="outlined-basic" label="Nome" variant="outlined" style={{width: '90%', marginRight: '20px'}}/>
|
||||
<TextField id="outlined-basic" label="email" variant="outlined" style={{width: '90%', marginRight: '20px'}}/>
|
||||
<TextField id="outlined-basic" label="senha" variant="outlined" style={{width: '90%', marginRight: '20px'}}/>
|
||||
<TextField id="outlined-basic" label="código" variant="outlined" style={{width: '90%', marginRight: '20px'}}/>
|
||||
<BasicButton title='Criar Cliente' onClick={() => console.log()}/>
|
||||
<Button
|
||||
variant="contained"
|
||||
component="label"
|
||||
style={{width: '300px'}}
|
||||
>
|
||||
Logo
|
||||
<input
|
||||
type="file"
|
||||
hidden
|
||||
/>
|
||||
</Button>
|
||||
</article>
|
||||
</ClientsModalView>
|
||||
</Modal>
|
||||
|
||||
<ConfirmModal open={openModalInativar} handleIsClose={(value) => {setOpenModalInativar(value)}}>
|
||||
<ConfirmModalView>
|
||||
<BasicButton title='Confirmar' onClick={() => setOpenModalInativar(true)}/>
|
||||
<BasicButton title='Cancelar' onClick={() => setOpenModalInativar(true)}/>
|
||||
</ConfirmModalView>
|
||||
</ConfirmModal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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 (
|
||||
<CostIndicatorView>
|
||||
<Head>
|
||||
@ -18,8 +34,39 @@ export default function CostIndicator() {
|
||||
<Header name='' />
|
||||
<PageTitle title='Indicador de Custo' subtitle='Valores em R$/MWh'/>
|
||||
<section>
|
||||
<Chart title='Indicador de Custo' subtitle='(Valores em R$/MWh)' data1={dataEconomiaIndicador.data1} data2={dataEconomiaIndicador.data2} label={dataEconomiaIndicador.labels} barLabel />
|
||||
<Chart title='Indicador de Custo' subtitle='(Valores em R$/MWh)' data1={graphData.filter((value, index) => 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 />
|
||||
</section>
|
||||
</CostIndicatorView>
|
||||
)
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 => {
|
||||
await apiClient.get('/faq').then(res => {
|
||||
faqData = res.data
|
||||
}).catch(res => {
|
||||
console.log(res)
|
||||
})
|
||||
console.table(faqData);
|
||||
}).catch(res => {
|
||||
// console.log(res)
|
||||
})
|
||||
|
||||
if (!token) {
|
||||
return {
|
||||
|
||||
@ -101,7 +101,6 @@ export default function Home() {
|
||||
|
||||
<p><a href='tel:+55(41) 3012-5900' >+55(41) 3012-5900</a><br/><a href='https://www.energiasmart.com.br' target="_blank" rel="noreferrer" >www.energiasmart.com.br</a></p>
|
||||
</LoginContainer>
|
||||
|
||||
</LoginView>
|
||||
)
|
||||
}
|
||||
|
||||
@ -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 => {
|
||||
await apiClient.get('/notification').then(res => {
|
||||
notificationData = res.data
|
||||
}).catch(res => {
|
||||
console.log(res)
|
||||
})
|
||||
console.table(notificationData);
|
||||
}).catch(res => {
|
||||
// console.log(res)
|
||||
})
|
||||
|
||||
if (!token) {
|
||||
return {
|
||||
|
||||
@ -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() {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
tableData.map(data => {
|
||||
return <>
|
||||
<tr>
|
||||
<td className='tg-gceh'>2101</td>
|
||||
<td className='tg-uulg red'>xxxx</td>
|
||||
<td className='tg-gceh dullRed'>xxxx</td>
|
||||
<td className='tg-gceh dullGreen'>xxxx</td>
|
||||
<td className='tg-uulg red'>xxxx</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='tg-hq65'>2102</td>
|
||||
<td className='tg-0tzy dullGreen'>xxxx</td>
|
||||
<td className='tg-hq65 dullRed'>xxxx</td>
|
||||
<td className='tg-hq65 dullGreen'>xxxx</td>
|
||||
<td className='tg-0tzy dullGreen'>xxxx</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="tg-gceh">2103</td>
|
||||
<td className="tg-uulg red">xxxx</td>
|
||||
<td className="tg-gceh dullGreen">xxxx</td>
|
||||
<td className="tg-gceh dullRed">xxxx</td>
|
||||
<td className="tg-gceh dullGreen">xxxx</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='tg-hq65'>2104</td>
|
||||
<td className='tg-0tzy dullGreen'>xxxx</td>
|
||||
<td className='tg-hq65 dullRed'>xxxx</td>
|
||||
<td className='tg-hq65 dullRed'>xxxx</td>
|
||||
<td className='tg-0tzy dullGreen'>xxxx</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='tg-gceh'>2105</td>
|
||||
<td className='tg-uulg red'>xxxx</td>
|
||||
<td className='tg-gceh dullGreen'>xxxx</td>
|
||||
<td className='tg-gceh dullGreen'>xxxx</td>
|
||||
<td className='tg-uulg red'>xxxx</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='tg-hq65'>2106</td>
|
||||
<td className='tg-0tzy dullGreen'>xxxx</td>
|
||||
<td className='tg-hq65 dullRed'>xxxx</td>
|
||||
<td className='tg-hq65 red'>xxxx</td>
|
||||
<td className='tg-0tzy green'>xxxx</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='tg-gceh'>2107</td>
|
||||
<td className='tg-uulg red'>xxxx</td>
|
||||
<td className='tg-gceh green'>xxxx</td>
|
||||
<td className='tg-gceh dullRed'>xxxx</td>
|
||||
<td className='tg-uulg red'>xxxx</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='tg-hq65'>2108</td>
|
||||
<td className='tg-0tzy dullGreen'>xxxx</td>
|
||||
<td className='tg-hq65 dullGreen'>xxxx</td>
|
||||
<td className='tg-hq65 green'>xxxx</td>
|
||||
<td className='tg-0tzy dullRed'>xxxx</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='tg-gceh'>2109</td>
|
||||
<td className='tg-uulg red'>xxxx</td>
|
||||
<td className='tg-gceh green'>xxxx</td>
|
||||
<td className='tg-gceh dullRed'>xxxx</td>
|
||||
<td className='tg-uulg red'>xxxx</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='tg-hq65'>2110</td>
|
||||
<td className='tg-0tzy red'>xxxx</td>
|
||||
<td className='tg-hq65 green'>xxxx</td>
|
||||
<td className='tg-hq65 red'>xxxx</td>
|
||||
<td className='tg-0tzy red'>xxxx</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='tg-gceh'>2111</td>
|
||||
<td className='tg-uulg red'>xxxx</td>
|
||||
<td className='tg-gceh dullGreen'>xxxx</td>
|
||||
<td className='tg-gceh green'>xxxx</td>
|
||||
<td className='tg-uulg red'>xxxx</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='tg-hq65'>2112</td>
|
||||
<td className='tg-0tzy green'>xxxx</td>
|
||||
<td className='tg-hq65 dullGreen'>xxxx</td>
|
||||
<td className='tg-hq65 dullRed'>xxxx</td>
|
||||
<td className='tg-0tzy dullGreen'>xxxx</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='tg-gceh'>2021</td>
|
||||
<td className='tg-uulg red'>xxxx</td>
|
||||
<td className='tg-gceh dullRed'>xxxx</td>
|
||||
<td className='tg-gceh dullGreen'>xxxx</td>
|
||||
<td className='tg-uulg red'>xxxx</td>
|
||||
<td className='tg-gceh'>{data.year_month_formatted}</td>
|
||||
<td className='tg-uulg red'>{data.nordeste}</td>
|
||||
<td className='tg-gceh dullRed'>{data.norte}</td>
|
||||
<td className='tg-gceh dullGreen'>{data.sudeste}</td>
|
||||
<td className='tg-uulg red'>{data.sul}</td>
|
||||
</tr>
|
||||
</>
|
||||
})
|
||||
}
|
||||
<tr>
|
||||
<td className='tg-gceh'>Mín</td>
|
||||
<td className='tg-uulg'>xxxx</td>
|
||||
@ -234,3 +165,31 @@ export default function region() {
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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])
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user