Merge branch 'administativePages' into 'dev'

Administative pages

See merge request kluppsoftware/smart-energia-web!89
This commit is contained in:
José Corte 2022-06-29 15:32:45 +00:00
commit d61d212617
8 changed files with 44 additions and 38 deletions

View File

@ -41,7 +41,6 @@ interface ChartInterface {
export default function Chart({ title, data1, data2, label, subtitle, dataset1, dataset2, barLabel }: ChartInterface) { export default function Chart({ title, data1, data2, label, subtitle, dataset1, dataset2, barLabel }: ChartInterface) {
const labels = label; const labels = label;
const empty = []
const options: any = { const options: any = {
responsive: true, responsive: true,

View File

@ -13,18 +13,20 @@ export const HeaderView = styled.header`
align-items: center; align-items: center;
justify-content: flex-start; justify-content: flex-start;
min-width: 120px;
height: 40px; height: 40px;
border-radius: 8px; border-radius: 8px;
background-color: #254F7F; background-color: #254F7F;
padding: 14px;
margin-right: 20px; margin-right: 20px;
p{ p{
color: white; color: white;
margin-left: 15%;
white-space: nowrap;
} }
} }
` `

View File

@ -10,6 +10,7 @@ import { api } from '../../services/api';
import { GeneralView } from '../../styles/layouts/general/GeneralView' import { GeneralView } from '../../styles/layouts/general/GeneralView'
import MuiAlert, { AlertProps } from '@mui/material/Alert' import MuiAlert, { AlertProps } from '@mui/material/Alert'
import Snackbar from '@mui/material/Snackbar'; import Snackbar from '@mui/material/Snackbar';
import getAPIClient from '../../services/ssrApi';
const Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert( const Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert(
props, props,
@ -18,13 +19,15 @@ const Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert(
return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} /> return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} />
}) })
export default function index({userName}: any) { export default function index({userName, initialText}: any) {
const editorRef = useRef(null); const editorRef = useRef(null);
const [text, setText] = useState(''); const [text, setText] = useState('');
const [openSnackSuccess, setOpenSnackSuccess] = useState<boolean>(false) const [openSnackSuccess, setOpenSnackSuccess] = useState<boolean>(false)
const [openSnackError, setOpenSnackError] = useState<boolean>(false) const [openSnackError, setOpenSnackError] = useState<boolean>(false)
console.log(initialText)
const log = () => { const log = () => {
if (editorRef.current) { if (editorRef.current) {
console.log(editorRef.current.getContent()); console.log(editorRef.current.getContent());
@ -94,27 +97,7 @@ export default function index({userName}: any) {
onInit={(evt, editor) => editorRef.current = editor} onInit={(evt, editor) => editorRef.current = editor}
onChange={value => console.log(value)} onChange={value => console.log(value)}
onEditorChange={(newText) => setText(newText)} onEditorChange={(newText) => setText(newText)}
initialValue=' <p>A <strong>SMART ENERGIA</strong> é uma consultoria independente especializada em Gestão de Energia Elétrica, consolidada como uma das três maiores consultorias do Brasil. initialValue={initialText[0].about}
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.</p>
<p>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. </p>
<p>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.</p>
<p>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.</p>
<ul>
<li>Informação</li>
<li>Economia</li>
<li>Gestão de Energia</li>
<li>Imparcialidade</li>
<li>Previsão de Custos</li>
<li>Experiência</li>
<li>Relacionamento</li>
</ul>'
init={{ init={{
height: 500, height: 500,
width: '100%', width: '100%',
@ -136,9 +119,19 @@ export default function index({userName}: any) {
} }
export const getServerSideProps: GetServerSideProps = async (ctx) => { export const getServerSideProps: GetServerSideProps = async (ctx) => {
const apiClient = getAPIClient(ctx)
const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx)
const { ['user-name']: userName } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx)
let initialText = []
await apiClient.get('/aboutUs').then(res => {
initialText = res.data.data
console.log(res.data.data)
}).catch(res => {
console.log(res)
})
if (!token) { if (!token) {
return { return {
redirect: { redirect: {
@ -150,7 +143,10 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
return { return {
props: { props: {
userName userName,
initialText
} }
} }
} }

View File

@ -78,7 +78,7 @@ export default function chartTelemetry({userName}) {
}) })
await api.post('/telemetry/discretization', { await api.post('/telemetry/discretization', {
"type": discretization, "type": discretization? discretization : "5_min",
"filters": [ "filters": [
{"type" : "=", "field": "med_5min.ponto", "value": unity}, {"type" : "=", "field": "med_5min.ponto", "value": unity},
{"type" : "between", "field": "dia_num", "value": [startDate, endDate]} {"type" : "between", "field": "dia_num", "value": [startDate, endDate]}
@ -90,7 +90,7 @@ export default function chartTelemetry({userName}) {
}) })
await api.post('/telemetry/discretization', { await api.post('/telemetry/discretization', {
"type": discretization, "type": discretization? discretization : "5_min",
"filters": [ "filters": [
{"type" : "=", "field": "med_5min.ponto", "value": unity}, {"type" : "=", "field": "med_5min.ponto", "value": unity},
{"type" : "between", "field": "dia_num", "value": [startDate, endDate]} {"type" : "between", "field": "dia_num", "value": [startDate, endDate]}
@ -103,7 +103,7 @@ export default function chartTelemetry({userName}) {
await api.post('/telemetry/demand', { await api.post('/telemetry/demand', {
"filters": [ "filters": [
{"type" : "=", "field": 'med_5min.ponto', "value": unity}, {"type" : "=", "field": "med_5min.ponto", "value": unity},
{"type" : "between", "field": "dia_num", "value": [startDate, endDate]} {"type" : "between", "field": "dia_num", "value": [startDate, endDate]}
] ]
}).then(res => { }).then(res => {

View File

@ -10,6 +10,21 @@ import getAPIClient from '../../services/ssrApi'
import { CostIndicatorView } from '../../styles/layouts/economy/costIndicator/CostIndicatorView' import { CostIndicatorView } from '../../styles/layouts/economy/costIndicator/CostIndicatorView'
export default function CostIndicator({graphData, userName}: any) { export default function CostIndicator({graphData, userName}: any) {
const months = [
'Jan',
'Fev',
'Mar',
'Abr',
'Mai',
'Jun',
'Jul',
'Ago',
'Set',
'Out',
'Nov',
'Dez'
]
return ( return (
<CostIndicatorView> <CostIndicatorView>
<Head> <Head>

View File

@ -267,7 +267,7 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
<RenderIf isTrue={page==='perMouth'? true : false}> <RenderIf isTrue={page==='perMouth'? true : false}>
<GoBack onClick={() => setPage('table')}>{'< Voltar para tabela PLD'}</GoBack> <GoBack onClick={() => setPage('table')}>{'< Voltar para tabela PLD'}</GoBack>
<PageTitle title='Resumo PLD - Diários' subtitle=''/> <PageTitle title='Resumo PLD - Diários' subtitle='Evolução PLD (R$/MWh)'/>
<PldGraphView> <PldGraphView>
<section className='toolsbar'> <section className='toolsbar'>
<div className='select'> <div className='select'>
@ -321,7 +321,7 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
data1={dataByDay} data3={dataByDay} data1={dataByDay} data3={dataByDay}
dataset1={'Economia'} dataset2={'barra1'} dataset3={'2021'} dataset1={'Economia'} dataset2={'barra1'} dataset3={'2021'}
label={EvolucaoPld.label} label={EvolucaoPld.label}
title='Evolução PLD (R$/MWh)' subtitle='' /> title='' subtitle='' />
</PldGraphView> </PldGraphView>
</RenderIf> </RenderIf>
@ -335,8 +335,7 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
</section> </section>
<LineChart data1={nordeste} data2={norte} data3={sudeste} data4={sul} <LineChart data1={nordeste} data2={norte} data3={sudeste} data4={sul}
dataset1='NORDESTE' dataset2='NORTE' dataset3='SUDESTE' dataset4='SUL' dataset1='NORDESTE' dataset2='NORTE' dataset3='SUDESTE' dataset4='SUL'
title={new Date(date).toLocaleString('pt-br').split(" ")[0]!='Invalid' && new Date(date).toLocaleString('pt-br').split(" ")[0]!='NaN' title={date? `Período - ${date.toString().split("-")[2]}/${date.toString().split("-")[1]}/${date.toString().split("-")[0]}` : null}
? 'Período - ' + new Date(date).toLocaleString('pt-br').split(" ")[0] : 'Período - '}
subtitle='' label={['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24']} /> subtitle='' label={['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24']} />
</PldGraphView> </PldGraphView>
</RenderIf> </RenderIf>

View File

@ -3,8 +3,6 @@ import styled from 'styled-components'
export const AppView = styled.main` export const AppView = styled.main`
display: flex; display: flex;
height: calc(20rem[] - 65px);
margin: 0 0 0 0; margin: 0 0 0 0;
padding: 0; padding: 0;

View File

@ -1,9 +1,6 @@
import { createGlobalStyle } from 'styled-components' import { createGlobalStyle } from 'styled-components'
export const GlobalStyle = createGlobalStyle` export const GlobalStyle = createGlobalStyle`
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap');
body::-webkit-scrollbar { body::-webkit-scrollbar {
width: 15px; width: 15px;
} }