diff --git a/src/components/administrativeTables/NotificationsTable.tsx b/src/components/administrativeTables/NotificationsTable.tsx index 4d874c6..9b6a5af 100644 --- a/src/components/administrativeTables/NotificationsTable.tsx +++ b/src/components/administrativeTables/NotificationsTable.tsx @@ -41,15 +41,6 @@ function createData( }; } -const rows = [ - createData('Confira tal coisa - Texto da notificação', 'Copel', 'enviada'), - createData('Confira tal coisa - Texto da notificação', 'Copel', 'enviada'), - createData('Confira tal coisa - Texto da notificação', 'Copel', 'enviada'), - createData('Confira tal coisa - Texto da notificação', 'Copel', 'falhou'), - createData('Confira tal coisa - Texto da notificação', 'Copel', 'pendente'), - createData('Confira tal coisa - Texto da notificação', 'Copel', 'enviada'), -]; - function descendingComparator(a: T, b: T, orderBy: keyof T) { if (b[orderBy] < a[orderBy]) { return -1; diff --git a/src/components/buttons/faqButton/FaqButtonView1.ts b/src/components/buttons/faqButton/FaqButtonView1.ts index 31b8458..8d5ca75 100644 --- a/src/components/buttons/faqButton/FaqButtonView1.ts +++ b/src/components/buttons/faqButton/FaqButtonView1.ts @@ -4,9 +4,9 @@ export const FaqButtonView1 = styled.button` display: flex; justify-content: center; align-items: center; - margin-top: 10px; + margin-top: 40px; margin-left: 65px; - width: 350px; + width: 320px; height: 45px; cursor: pointer; background: #DDDDDD; diff --git a/src/components/buttons/faqButton/FaqButtonView2.ts b/src/components/buttons/faqButton/FaqButtonView2.ts index 24a26a7..74ce1fc 100644 --- a/src/components/buttons/faqButton/FaqButtonView2.ts +++ b/src/components/buttons/faqButton/FaqButtonView2.ts @@ -5,8 +5,8 @@ export const FaqButtonView2 = styled.button` justify-content: center; align-items: center; margin-top: -46px; - margin-left: 430px; - width: 350px; + margin-left: 444px; + width: 320px; height: 45px; cursor: pointer; background: #254F7F; @@ -16,7 +16,5 @@ export const FaqButtonView2 = styled.button` font-family: 'Poppins'; font-size: 90%; - - color: #FFFFFF; ` diff --git a/src/components/graph/Chart.tsx b/src/components/graph/Chart.tsx index 4b2a681..941977c 100644 --- a/src/components/graph/Chart.tsx +++ b/src/components/graph/Chart.tsx @@ -54,7 +54,7 @@ export default function Chart({ title, data1, data2, label, subtitle, dataset1, offset: -20, align: "start", font: { - size: 16 + size: 12 } }, legend: { @@ -72,13 +72,13 @@ export default function Chart({ title, data1, data2, label, subtitle, dataset1, datasets: [ { label: dataset1? dataset1 : '2021', - data: data1.map(value => value.custo_unit), + data: data1.map(value => value.custo_unit? value.custo_unit : 0), backgroundColor: '#C2D5FB', }, data2? { label: dataset2? dataset2 : '2022', - data: data2.map(value => value.custo_unit), + data: data2.map(value => value.custo_unit? value.custo_unit : 0), backgroundColor: '#255488', } : null ], diff --git a/src/components/graph/LineBarChart.tsx b/src/components/graph/LineBarChart.tsx index e73ba23..83bbb2f 100644 --- a/src/components/graph/LineBarChart.tsx +++ b/src/components/graph/LineBarChart.tsx @@ -71,9 +71,10 @@ interface LineBarChartInterface { dataset3?: string, barLabel?: boolean | undefined, hashurado?: boolean | undefined, + reais?: boolean | undefined } -export function LineBarChart({ title, subtitle, data1, data2, data3, label, red, dataset1, dataset2, dataset3, barLabel, hashurado }: LineBarChartInterface) { +export function LineBarChart({ title, subtitle, data1, data2, data3, label, red, dataset1, dataset2, dataset3, barLabel, hashurado, reais }: LineBarChartInterface) { const chartRef = useRef(null); const currentTime = new Date(); @@ -93,7 +94,7 @@ export function LineBarChart({ title, subtitle, data1, data2, data3, label, red, offset: -20, align: "start", font: { - size: 16 + size: 12 } }, legend: { @@ -111,7 +112,7 @@ export function LineBarChart({ title, subtitle, data1, data2, data3, label, red, datasets: [ { type: 'line' as const, - label: dataset1? dataset1 : 'Dataset 1', + label: dataset1&&reais==false? parseFloat(dataset1).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2}) : dataset1, borderColor: red? '#f00' : '#0c9200', datalabels: { diff --git a/src/components/graph/LineBarChart2.tsx b/src/components/graph/LineBarChart2.tsx index 2f346ed..ff01607 100644 --- a/src/components/graph/LineBarChart2.tsx +++ b/src/components/graph/LineBarChart2.tsx @@ -93,7 +93,7 @@ export function LineBarChart2({ title, subtitle, data1, data2, data3, label, red offset: -20, align: "start", font: { - size: 16 + size: 12 } }, legend: { diff --git a/src/components/graph/LineChart.tsx b/src/components/graph/LineChart.tsx index 09e27a9..79ffd31 100644 --- a/src/components/graph/LineChart.tsx +++ b/src/components/graph/LineChart.tsx @@ -55,7 +55,7 @@ export default function LineChart({ title, subtitle, data1, data2, data3, data4, offset: -20, align: "start", font: { - size: 16 + size: 12 } }, legend: { diff --git a/src/components/graph/SingleBar.tsx b/src/components/graph/SingleBar.tsx index b1b858f..8a48d33 100644 --- a/src/components/graph/SingleBar.tsx +++ b/src/components/graph/SingleBar.tsx @@ -51,7 +51,7 @@ export function SingleBar({ title, subtitle, dataProps, label, dataset, dataset1 sum += data; }); const percentage = (dataProps[ctx.dataIndex].econ_percentual*100).toFixed(0)+"%"; - const result = `${value}\n ${percentage}` + const result = `${parseFloat(value).toFixed(0)}\n ${percentage}` return value==null? null : result }, @@ -61,7 +61,7 @@ export function SingleBar({ title, subtitle, dataProps, label, dataset, dataset1 offset: -40, align: "start", font: { - size: 16 + size: 10 } }, legend: { diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index 1beb9a8..db21a84 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -35,23 +35,22 @@ function stringAvatar(name: string) { } interface headerInterface { - name: string + name: string, + admin?: boolean | undefined } -export default function Header({ name }: headerInterface) { +export default function Header({ name, admin }: headerInterface) { return (
-
- + { + !admin? + + : + null + }

olá, {name} diff --git a/src/components/sidebar/Sidebar.tsx b/src/components/sidebar/Sidebar.tsx index 48df240..186c956 100644 --- a/src/components/sidebar/Sidebar.tsx +++ b/src/components/sidebar/Sidebar.tsx @@ -7,7 +7,8 @@ import Image from 'next/image' import Link from 'next/link' import { useRouter } from 'next/router' import { parseCookies } from 'nookies'; -import React, { useEffect, useState } from 'react' +import React, { useContext, useEffect, useState } from 'react' +import { AuthContext } from '../../contexts/AuthContext'; import RenderIf from '../../utils/renderIf'; import { SidebarView } from './SidebarView' @@ -25,10 +26,12 @@ const style = { }; export default function Sidebar() { - const [open, setOpen] = React.useState(false); + const [open, setOpen] = useState(false); const handleOpen = () => setOpen(true); const handleClose = () => setOpen(false); + const { signOut } = useContext(AuthContext) + const [ economiaDrawer, setEconomiaDrawer ] = useState(false) const [ viewModal, setViewModal ] = useState(false) @@ -37,8 +40,6 @@ export default function Sidebar() { const { ['user-role']: role } = parseCookies() - // console.log(role) - useEffect(() => { setViewModal(false) }, [router.pathname]) @@ -54,10 +55,10 @@ export default function Sidebar() {

    -
  • {'Clientes >'}
  • +
  • {'Clientes >'}
  • {'Sobre Nós'}
  • {'FAQ >'}
  • -
  • {'Notificações >'}

    25

  • +
  • {'Notificações >'}
  • {'Visão Geral'}
  • setEconomiaDrawer(!economiaDrawer)} className={router.pathname=='/grossSavings' || router.pathname=='/accumulatedSavings' || router.pathname=='/estimatedCost' || router.pathname=='/costIndicator' ? 'actualPath' : null } >{'Economia >'}
  • -
  • Economia Bruta
  • -
  • Economia Acumulada
  • -
  • Custo Estimado
  • +
  • Economia Bruta Anual
  • +
  • Economia Bruta Mensal
  • +
  • Cativo x Livre mensal
  • Custo R/MWh
  • {'Telemetria >'}
  • @@ -117,7 +118,7 @@ export default function Sidebar() { Deseja realmente sair ? - +
    diff --git a/src/contexts/AuthContext.tsx b/src/contexts/AuthContext.tsx index f335f00..f2f2a0a 100644 --- a/src/contexts/AuthContext.tsx +++ b/src/contexts/AuthContext.tsx @@ -1,7 +1,7 @@ import React, { createContext, useState } from "react"; import Router from 'next/router' -import { setCookie } from "nookies"; +import { destroyCookie, setCookie } from "nookies"; import { signInRequest } from "../services/auth"; import { api } from "../services/api"; @@ -21,6 +21,7 @@ type AuthContextType = { isAuthenticated: boolean; user: UserType; signIn: (data: SignInData) => Promise; + signOut: any; } export const AuthContext = createContext({} as AuthContextType) @@ -64,8 +65,15 @@ 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/accumulatedSavings.tsx b/src/pages/accumulatedSavings.tsx index bce6a4c..53467d9 100644 --- a/src/pages/accumulatedSavings.tsx +++ b/src/pages/accumulatedSavings.tsx @@ -16,10 +16,10 @@ export default function AccumulatedSavings({graphData, years, userName}: any) { return ( - Smart Energia - Economia Acumulada + Smart Energia - Economia Bruta Mensal
    - +
    { const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) - let graphData = []; await apiClient.post('/economy/grossMonthly').then(res => { diff --git a/src/pages/administrative/aboutUs/index.tsx b/src/pages/administrative/aboutUs/index.tsx deleted file mode 100644 index ba84ee3..0000000 --- a/src/pages/administrative/aboutUs/index.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import TextField from '@mui/material/TextField'; -import Head from 'next/head' -import Image from 'next/image' -import React from 'react' - -import AdministrativeHeader from '../../../components/administrativeHeader/AdministrativeHeader'; -import Banner from '../../../components/banner/Banner' -import Header from '../../../components/header/Header' -import { AboutUsView } from '../../../styles/layouts/aboutUs/AboutUsView' - -export default function aboutUs() { - return ( - - - Smart Energia - About Us - - - -
    -

    atualizar texto

    - -
    -
    -

    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'}
    • -
    - -
    - -
    -
    -
    - ) -} diff --git a/src/pages/administrative/clients/index.tsx b/src/pages/administrative/clients/index.tsx index 6d3d430..26993c0 100644 --- a/src/pages/administrative/clients/index.tsx +++ b/src/pages/administrative/clients/index.tsx @@ -135,7 +135,7 @@ export default function clients({clients, userName}) { -
    +
    @@ -191,15 +191,15 @@ export default function clients({clients, userName}) { }} variant="outlined" />

    - console.log()} /> + setOpen(false)} /> handleCreateClient(client)}/> {setOpenModalInativar(value)}}> - + handleDeleteClient(selectedClients)}/> - setOpenModalInativar(true)}/> + setOpenModalInativar(false)}/>
    diff --git a/src/pages/administrative/faq/index.tsx b/src/pages/administrative/faq/index.tsx index 0b057d2..b7e428d 100644 --- a/src/pages/administrative/faq/index.tsx +++ b/src/pages/administrative/faq/index.tsx @@ -115,7 +115,7 @@ export default function Sidebar({faqData, userName} : any ) { return ( <> -
    +
    @@ -145,7 +145,6 @@ export default function Sidebar({faqData, userName} : any ) { -
    - setFaq({...faq, question:value.target.value})} sx={{width:710, ml:8}} variant="outlined" />

    - setFaq({...faq, answer:value.target.value})} sx={{width:710, ml:8}} variant="outlined" /> + setFaq({...faq, question:value.target.value})} sx={{width:710, ml:8}} variant="outlined" />

    + setFaq({...faq, answer:value.target.value})} sx={{width:710, ml:8}} variant="outlined" />

    - - handleRegisterNewFaq(faq)} - - /> + setOpen(false)} /> + handleRegisterNewFaq(faq)}/>
    diff --git a/src/pages/administrative/general.tsx b/src/pages/administrative/general.tsx index ec52d81..1d5b7bf 100644 --- a/src/pages/administrative/general.tsx +++ b/src/pages/administrative/general.tsx @@ -28,23 +28,9 @@ export default function index({userName}: any) { return ( -
    - -
    - - - -
    +
    + +
    editorRef.current = editor} 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. @@ -84,7 +70,6 @@ export default function index({userName}: any) { content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }' }} /> - ) } diff --git a/src/pages/administrative/notification/index.tsx b/src/pages/administrative/notification/index.tsx index 736685f..234ea9f 100644 --- a/src/pages/administrative/notification/index.tsx +++ b/src/pages/administrative/notification/index.tsx @@ -41,7 +41,7 @@ const style = { border: '2px solid #000', boxShadow: 24, p: 4, - overflowY: 'scroll' + overflowY: 'scroll', }; const Alert = React.forwardRef(function Alert( @@ -122,7 +122,7 @@ export default function notification({clients, notifications, userName}: any) { Smart Energia - Notificações -

    +
    @@ -178,7 +178,9 @@ export default function notification({clients, notifications, userName}: any) { }} variant="outlined" />

    - + )} - sx={{ml:8}} style={{ width: 700 }} + sx={{ml:8}} renderInput={(params) => ( )} /> : null } - - {setOpen(false)}} /> - { + {setOpen(false)}} /> + { handleRegisterNewNotification(notification)}} /> diff --git a/src/pages/costIndicator.tsx b/src/pages/costIndicator.tsx index 63362a6..e3e2e6d 100644 --- a/src/pages/costIndicator.tsx +++ b/src/pages/costIndicator.tsx @@ -12,15 +12,28 @@ import { dataEconomiaIndicador } from '../services/economiaIndicador' import getAPIClient from '../services/ssrApi' import { CostIndicatorView } from '../styles/layouts/economy/costIndicator/CostIndicatorView' -function addMissingMonths(data) { - // console.log(data[0].mes.slice(1, 1)) -} - function verifyDataByYear(data) { - if (data.length === 12) - return true - else - return false + 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) { @@ -34,9 +47,20 @@ export default function CostIndicator({graphData, userName}: any) {
    - value.mes.slice(3, 7).includes('2021'))} + 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 + + return 0 + })} 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 /> + label={graphData.filter((value, index) => 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 + + return 0 + }).map(value => value.mes)} barLabel />
    ) @@ -51,7 +75,6 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { await apiClient.post('/economy/MWh').then(res => { graphData = res.data.data - console.log(graphData[0].mes) }).catch(res => { console.log(res) }) diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index d66d182..e5dedef 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -23,7 +23,7 @@ import { parseCookies } from 'nookies' import { GetServerSideProps } from 'next' import getAPIClient from '../services/ssrApi' -export default function Dashboard({grossAnualGraph, grossAnualYears, grossMensalGraph, grossMensalYears, acumulatedGraph, mapsInfo, userName} : any) { +export default function Dashboard({grossAnualGraph, grossAnualYears, grossMensalGraph, grossMensalYears, acumulatedGraph, mapsInfo, userName, costIndicator} : any) { return ( @@ -44,14 +44,14 @@ export default function Dashboard({grossAnualGraph, grossAnualYears, grossMensal
    - + - + - + - + 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 + + return 0 + })} + data2={costIndicator.filter((value, index) => value.mes.slice(3, 7).includes('2022'))} + label={costIndicator.filter((value, index) => 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 + + return 0 + }).map(value => value.mes)} barLabel />
    @@ -86,6 +98,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { let grossAnualGraph = []; let grossMensalGraph = []; let acumulatedGraph = []; + let costIndicator = [] let mapsInfo = []; await apiClient.post('/economy/grossAnnual').then(res => { @@ -106,6 +119,12 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { console.log(res) }) + await apiClient.post('/economy/MWh').then(res => { + costIndicator = res.data.data + }).catch(res => { + console.log(res) + }) + await apiClient.post('/pld/overview').then(res => { mapsInfo = res.data.data }).catch(res => { @@ -131,6 +150,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { grossMensalYears, grossMensalGraph, acumulatedGraph, + costIndicator, mapsInfo, userName diff --git a/src/pages/estimatedCost.tsx b/src/pages/estimatedCost.tsx index 3e7e150..e4915eb 100644 --- a/src/pages/estimatedCost.tsx +++ b/src/pages/estimatedCost.tsx @@ -23,7 +23,7 @@ export default function EstimatedCost({graphData, userName}: any) {
    + label={ConsumoEstimado.label} title='Cativo x Livre mensal' subtitle='' barLabel hashurado />
    ) diff --git a/src/pages/grossSavings.tsx b/src/pages/grossSavings.tsx index 9e16689..26fe5dd 100644 --- a/src/pages/grossSavings.tsx +++ b/src/pages/grossSavings.tsx @@ -23,7 +23,6 @@ function verifyDataByYear(data) { return false } - export default function GrossSavings({graphData, years, userName}: any) { return ( @@ -31,7 +30,7 @@ export default function GrossSavings({graphData, years, userName}: any) { Smart Energia - Economia Acumulada
    - +
    ) } + export const getServerSideProps: GetServerSideProps = async (ctx) => { const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) diff --git a/src/pages/pld/index.tsx b/src/pages/pld/index.tsx index 828f79a..98a3b72 100644 --- a/src/pages/pld/index.tsx +++ b/src/pages/pld/index.tsx @@ -115,26 +115,23 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN }).catch(exception => console.log(exception)) } + function handleColorNorte(value, region) { + if (value <= tableData.result[1].norte_min) + return 'green' + else if (value >= tableData.result[0][`${region}_max`]) + return 'red' + else if (tableData.result[0][`${region}_max`] - value > tableData.result[0][`${region}_max`]/2) + return 'dullGreen' + else if (tableData.result[1][`${region}_min`] - value <= tableData.result[1][`${region}_min`]) + return 'dullRed' + } + useEffect(() => { getDataByHour() getDataByDay() console.log(dataByDay) }, [date, day, select]) - function handleCellColor(minimo, mi, ma, maximo) { - if (minimo - mi >= 100 && minimo - mi < 200) { - return 'green' - } else if ( mi*2 >= 200 && mi*2 < 250 ) { - return'dullGreen' - } else if ( (ma-mi)/2 >=250 && (ma-mi)/2 < 300 ) { - return 'white' - } else if ( ma/2 >= 300 && ma/2 < 600 ) { - return 'dullRed' - } else if ( maximo-ma > 600 ) { - return 'red' - } - } - return (
    { - tableData.map(data => { + tableData.data.map(data => { return <> {data.year_month_formatted} - {data.nordeste} - {data.norte} - {data.sudeste} - {data.sul} + {parseFloat(data.nordeste).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} + {parseFloat(data.norte).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} + {parseFloat(data.sudeste).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} + {parseFloat(data.sul).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} }) } - - Mín - xxxx - xxxx - xxxx - xxxx - - - Max - xxxx - xxxx - xxxx - xxxx - - - Desv Pad - xxxx - xxxx - xxxx - xxxx - + { + tableData.result.map((data, index) => { + if (index === 0) { + return <> + + Max + {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})} + {parseFloat(data.sul_max).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} + + + } else if (index===1) { + return <> + + Min + {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})} + {parseFloat(data.sul_min).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} + + + } else if (index===2) { + return <> + + Desv. Padrão + {parseFloat(data.nordeste_desv_pad).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} + {parseFloat(data.norte_desv_pad).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} + {parseFloat(data.sudeste_desv_pad).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} + {parseFloat(data.sul_desv_pad).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} + + + } + }) + }
    @@ -235,7 +246,7 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN width: '22%', ml: 1 }}> - Dia + Mês
    @@ -312,7 +305,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { let tableData = []; await apiClient.post('/pld/list').then(res => { - tableData = res.data.data + tableData = res.data }).catch(res => { console.log(res) }) diff --git a/src/pages/resumoOperacao.tsx b/src/pages/resumoOperacao.tsx index 03a4e57..b56f4dc 100644 --- a/src/pages/resumoOperacao.tsx +++ b/src/pages/resumoOperacao.tsx @@ -20,13 +20,15 @@ import data from '../services/dados.json' import getAPIClient from '../services/ssrApi'; import { Pagination, TableView } from '../styles/layouts/ResumoOperacao/ResumoOperacaoView'; -export default function ResumoOperacao({tableData, userName}: any) { +export default function ResumoOperacao({tableData, clientsData, userName, clientMonth}: any) { const csvData = tableData; const [month, setMonth] = useState(''); const [unidade, setUnidade] = useState(''); const [tableDataState, setTableDataState] = useState([]); + const monthLabels = ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'ago', 'set', 'out', 'nov', 'dez'] + const handleChangeMonth = (event: SelectChangeEvent) => { setMonth(event.target.value); }; @@ -36,7 +38,7 @@ export default function ResumoOperacao({tableData, userName}: any) { useEffect(() => { if (unidade!=='' || month!==''){ - api.post('/operation', { + api.post('/operation/summary', { "filters": [ {"type" : "=", "field": "mes", "value": `${month}/2022`}, {"type" : "=", "field": "dados_te.cod_smart_unidade", "value": unidade} @@ -49,7 +51,6 @@ export default function ResumoOperacao({tableData, userName}: any) { } else { setTableDataState(tableData) } - }, [month, unidade]) return ( @@ -73,7 +74,7 @@ export default function ResumoOperacao({tableData, userName}: any) { > Nenhum { - tableData.map((value) => { + clientsData.map((value) => { return {value.cod_smart_unidade} }) } @@ -90,18 +91,11 @@ export default function ResumoOperacao({tableData, userName}: any) { onChange={handleChangeMonth} > Nenhum - Janeiro - Fevereiro - Março - Abril - Maio - Junho - Julho - Agosto - Setembro - Outubro - Novembro - Dezembro + { + clientMonth.map((value) => { + return {monthLabels[parseFloat(value.mes.slice(3, 4))-1]} + }) + }
    @@ -125,8 +119,8 @@ export default function ResumoOperacao({tableData, userName}: any) { {value.operacao} {value.montante_nf} {value.contraparte} - {value.nf_c_icms} - {value.preco_nf} + {parseFloat(value.nf_c_icms).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} + {parseFloat(value.preco_nf).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})} }) @@ -150,17 +144,36 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const { ['user-name']: userName } = parseCookies(ctx) let tableData = []; + let clientsData = []; + let clientMonth = []; - await apiClient.post('/operation', { + await apiClient.post('/operation/summary', { "filters": [] }).then(res => { - console.log(res.data.data) tableData = res.data.data }).catch(res => { console.log(res) }) - console.log(tableData) + await apiClient.post('/operation', { + "filters": [], + "fields": ["cod_smart_unidade"], + "distinct": true + }).then(res => { + clientsData = res.data.data + }).catch(res => { + console.log(res) + }) + + await apiClient.post('/operation', { + "filters": [], + "fields": ["mes"], + "distinct": true + }).then(res => { + clientMonth = res.data.data + }).catch(res => { + console.log(res) + }) if (!token) { return { @@ -174,6 +187,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { return { props: { tableData, + clientsData, + clientMonth, userName } } diff --git a/src/styles/layouts/pld/PldView.ts b/src/styles/layouts/pld/PldView.ts index 8e6870a..539ec3f 100644 --- a/src/styles/layouts/pld/PldView.ts +++ b/src/styles/layouts/pld/PldView.ts @@ -83,19 +83,23 @@ export const PldTableView = styled.main` } .green { - background-color: #00A934!important; + background-color: #0F9D58!important; + color: black!important; } .dullGreen { background-color: #AED094!important; + color: black!important; } .red { - background-color: #FF5429!important; + background-color: #DB4437!important; + color: black!important; } .dullRed { background-color: #FFAA95!important; + color: black!important; } h3{