diff --git a/package.json b/package.json index cf6bbec..c60b200 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@date-io/date-fns": "^2.14.0", "@emotion/react": "^11.9.0", "@emotion/styled": "^11.8.1", + "@hookform/resolvers": "^2.9.1", "@material-ui/core": "^4.12.4", "@material-ui/icons": "^4.11.3", "@mui/icons-material": "^5.8.2", @@ -28,6 +29,7 @@ "@mui/x-date-pickers": "^5.0.0-alpha.3", "@tinymce/tinymce-react": "^4.1.0", "@types/react-csv": "^1.1.2", + "@types/yup": "^0.29.14", "@typescript-eslint/eslint-plugin": "^5.22.0", "@typescript-eslint/parser": "^5.22.0", "axios": "^0.27.2", @@ -49,9 +51,12 @@ "react-chartjs-2": "^4.1.0", "react-csv": "^2.2.2", "react-dom": "18.1.0", + "react-hook-form": "^7.32.2", "react-icons": "^4.3.1", + "react-input-mask": "^2.0.4", "styled-components": "^5.3.5", - "tinymce": "^6.0.3" + "tinymce": "^6.0.3", + "yup": "^0.32.11" }, "devDependencies": { "@babel/preset-env": "^7.17.10", diff --git a/public/assets/iconePDF.png b/public/assets/iconePDF.png new file mode 100644 index 0000000..38e28b2 Binary files /dev/null and b/public/assets/iconePDF.png differ diff --git a/public/assets/marca1.png b/public/assets/marca1.png new file mode 100644 index 0000000..6eada8c Binary files /dev/null and b/public/assets/marca1.png differ diff --git a/public/assets/marca1.svg b/public/assets/marca1.svg deleted file mode 100644 index 1af4cd6..0000000 --- a/public/assets/marca1.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/components/NotificationQuestionsCard/NotificationQuestionsCard.tsx b/src/components/NotificationQuestionsCard/NotificationQuestionsCard.tsx index b2e4438..9938a23 100644 --- a/src/components/NotificationQuestionsCard/NotificationQuestionsCard.tsx +++ b/src/components/NotificationQuestionsCard/NotificationQuestionsCard.tsx @@ -13,7 +13,7 @@ export default function NotificationQuestionsCard({title, body}: CommonsQuestion const [ showCardBody, setShowCardBody ] = useState(false) return ( - + setShowCardBody(!showCardBody)}>

{title}

setShowCardBody(!showCardBody)} /> diff --git a/src/components/NotificationQuestionsCard/NotificationQuestionsCardView.ts b/src/components/NotificationQuestionsCard/NotificationQuestionsCardView.ts index 91d16dd..4e12edb 100644 --- a/src/components/NotificationQuestionsCard/NotificationQuestionsCardView.ts +++ b/src/components/NotificationQuestionsCard/NotificationQuestionsCardView.ts @@ -13,6 +13,7 @@ export const FaqQuestionsCardHeader = styled.div` margin-top: 53px; width: 100%; + cursor: pointer; img { cursor: pointer; diff --git a/src/components/administrativeTables/ClientsTable.tsx b/src/components/administrativeTables/ClientsTable.tsx index a56a973..90ccfaf 100644 --- a/src/components/administrativeTables/ClientsTable.tsx +++ b/src/components/administrativeTables/ClientsTable.tsx @@ -12,7 +12,34 @@ import TableSortLabel from '@mui/material/TableSortLabel'; import { visuallyHidden } from '@mui/utils'; import React, { useState, useEffect } from 'react'; +import Snackbar from '@mui/material/Snackbar'; +import MuiAlert, { AlertProps } from '@mui/material/Alert'; + +import Modal from '@mui/material/Modal'; + + import { TableView, StyledStatus } from './TableView'; +import { api } from '../../services/api'; + +const style = { + position: 'absolute' as const, + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: 900, + height: 500, + bgcolor: 'background.paper', + border: '2px solid #000', + boxShadow: 24, + p: 4, + overflowY: 'scroll' +}; +const Alert = React.forwardRef(function Alert( + props, + ref, +) { + return ; +}); interface Data { clientCode: number, @@ -161,6 +188,37 @@ export default function ClientTable({clients, onChange}: ClientsTableInterface) const [dense, setDense] = useState(false); const [rowsPerPage, setRowsPerPage] = useState(5); + const [openSnackError, setOpenSnackError] = useState(false); + + const [open, setOpen] = useState(false); + const [openModalInativar, setOpenModalInativar] = useState(false) + const handleOpen = () => setOpen(true); + const handleClose = () => setOpen(false); + + const [cod_client, setCod_client] = useState() + const [units, setUnits] = useState([]) + + function getClientUnits(client_id: number) { + api.post('/units', { + "filters": [ + {"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": client_id} + ], + "fields": ["unidade"], + "distinct": true + }).then(res => setUnits(res.data.data)).catch(res => { + setOpenSnackError(true) + }) + + return units + } + + const handleCloseSnack = (event?: React.SyntheticEvent | Event, reason?: string) => { + if (reason === 'clickaway') { + return; + } + setOpenSnackError(false); + }; + const handleRequestSort = ( event: React.MouseEvent, property: keyof Data, @@ -220,6 +278,11 @@ export default function ClientTable({clients, onChange}: ClientsTableInterface) return ( + + + Não foi possivel encontrar unidades do client! + + {row.name} - clique aqui para ver as unidades + { + setOpen(true) + getClientUnits(row.client_id) + }}>clique aqui para ver as unidades {row.deleted_at? 'inativo' : 'ativo'} ); @@ -297,6 +363,25 @@ export default function ClientTable({clients, onChange}: ClientsTableInterface) onRowsPerPageChange={handleChangeRowsPerPage} /> + + + { + units.map((units, index) => { + return <> +
  • {units.unidade}
  • +
    + + }) + } +
    +
    ); } diff --git a/src/components/administrativeTables/FaqTable.tsx b/src/components/administrativeTables/FaqTable.tsx index a7014bb..9a6a0d7 100644 --- a/src/components/administrativeTables/FaqTable.tsx +++ b/src/components/administrativeTables/FaqTable.tsx @@ -283,7 +283,7 @@ export default function FaqTable({questionData, onChange}: FaqTableInterface) { {row.question} {row.answer} - {row.deleted_at? 'ativo' : 'inativo'} + {'ativo'} ); })} diff --git a/src/components/administrativeTables/NotificationsTable.tsx b/src/components/administrativeTables/NotificationsTable.tsx index 4d874c6..345be97 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; @@ -299,7 +290,7 @@ export default function NotificationsTable({notifications, onChange}: Notificati {row.title} {'copel'} - {row.deleted_at===null? 'ativo' : 'inativo'} + {'ativo'} ); })} 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/faqQuestionsCard/FaqQuestionsCard.tsx b/src/components/faqQuestionsCard/FaqQuestionsCard.tsx index 5ceda20..3bdd341 100644 --- a/src/components/faqQuestionsCard/FaqQuestionsCard.tsx +++ b/src/components/faqQuestionsCard/FaqQuestionsCard.tsx @@ -13,9 +13,10 @@ export default function CommonsQuestionsCard({question, answer}: CommonsQuestion const [ showCardBody, setShowCardBody ] = useState(false) return ( - - -

    {question}

    + setShowCardBody(!showCardBody)}> + +

    {question}

    + setShowCardBody(!showCardBody)} />
    diff --git a/src/components/faqQuestionsCard/FaqQuestionsCardView.ts b/src/components/faqQuestionsCard/FaqQuestionsCardView.ts index 91d16dd..4e12edb 100644 --- a/src/components/faqQuestionsCard/FaqQuestionsCardView.ts +++ b/src/components/faqQuestionsCard/FaqQuestionsCardView.ts @@ -13,6 +13,7 @@ export const FaqQuestionsCardHeader = styled.div` margin-top: 53px; width: 100%; + cursor: pointer; img { cursor: pointer; 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..1fba829 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/inputUplaod/inputUpload.tsx b/src/components/inputUploadImg/inputUpload.tsx similarity index 96% rename from src/components/inputUplaod/inputUpload.tsx rename to src/components/inputUploadImg/inputUpload.tsx index dad71d1..34daa86 100644 --- a/src/components/inputUplaod/inputUpload.tsx +++ b/src/components/inputUploadImg/inputUpload.tsx @@ -3,7 +3,7 @@ import React,{ useState, useEffect } from 'react' import { InputUploadView } from './inputUploadView' -export default function InputUpload() { +export default function InputUploadPdf() { const [images, setImages] = useState([] as any); const [imageURLS, setImageURLs] = useState([]); @@ -34,6 +34,7 @@ export default function InputUpload() {

    +
    diff --git a/src/components/inputUplaod/inputUploadView.ts b/src/components/inputUploadImg/inputUploadView.ts similarity index 100% rename from src/components/inputUplaod/inputUploadView.ts rename to src/components/inputUploadImg/inputUploadView.ts diff --git a/src/components/inputUploadPdf/inputUpload.tsx b/src/components/inputUploadPdf/inputUpload.tsx new file mode 100644 index 0000000..96866c0 --- /dev/null +++ b/src/components/inputUploadPdf/inputUpload.tsx @@ -0,0 +1,49 @@ +import React,{ useState, useEffect } from 'react' +import Image from 'next/image'; + + +import { InputUploadView } from './inputUploadView' + + +export default function InputUploadPdf() { + const [images, setImages] = useState([] as any); + const [imageURLS, setImageURLs] = useState([]); + + 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]); + // console.log(e); + } + + return ( + + +
    + + {imageURLS.map((imageSrc, index) => ( + + ))} + + + + +
    + +
    + + +
    + + +
    + +
    +
    + ) +} diff --git a/src/components/inputUploadPdf/inputUploadView.ts b/src/components/inputUploadPdf/inputUploadView.ts new file mode 100644 index 0000000..fed659c --- /dev/null +++ b/src/components/inputUploadPdf/inputUploadView.ts @@ -0,0 +1,51 @@ +import styled from 'styled-components' + +export const InputUploadView = styled.div` + +border-radius: 4px; +border:1px solid gray ; +background-color: white; +width: 300px; +height: 50px; + +input[type="file"] { + display: none; + + } + +label { + width: 140px; + height: 30px; + margin-top: -30px; + border-radius: 4px; + margin-left: 69px; + background-color: #254F7F; + color: white; + font-size: 13px; + font-weight: 600; + text-transform: uppercase; + display: flex; + text-align: center; + cursor: pointer; + } + .TitleButton{ + margin-top: 4px; + margin-left: 30px; + } + + .testess{ + margin-left: 80px; + position: absolute; + + } + + .imgContainer{ + max-width: 40px; + margin-top: 9px; + margin-left: 4px; + height: 30px; +} + + + +` diff --git a/src/components/sidebar/Sidebar.tsx b/src/components/sidebar/Sidebar.tsx index 48df240..3e777ff 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,11 @@ export default function Sidebar() {
      -
    • {'Clientes >'}
    • +
    • {'Clientes >'}
    • {'Sobre Nós'}
    • {'FAQ >'}
    • -
    • {'Notificações >'}

      25

    • +
    • {'Notificações >'}
    • +
    • {'Info Setorial'}
    • {'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 +119,7 @@ export default function Sidebar() { Deseja realmente sair ? - +
      diff --git a/src/contexts/AuthContext.tsx b/src/contexts/AuthContext.tsx index f335f00..74735b8 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) @@ -60,12 +61,19 @@ export function AuthProvider({children}: {children: React.ReactNode}) { } return; } else { - return + return exception } } + 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..d1a0fc2 100644 --- a/src/pages/administrative/clients/index.tsx +++ b/src/pages/administrative/clients/index.tsx @@ -1,5 +1,4 @@ import Box from '@mui/material/Box'; -import Button from '@mui/material/Button'; import Modal from '@mui/material/Modal'; import TextField from '@mui/material/TextField'; import Typography from '@mui/material/Typography'; @@ -12,7 +11,7 @@ import BasicButton from '../../../components/buttons/basicButton/BasicButton' import FaqButton1 from '../../../components/buttons/faqButton/FaqButton1'; import FaqButton2 from '../../../components/buttons/faqButton/FaqButton2'; import Header from '../../../components/header/Header' -import InputUpload from '../../../components/inputUplaod/inputUpload'; +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'; @@ -22,6 +21,8 @@ import { parseCookies } from 'nookies'; import { GetServerSideProps } from 'next'; import getAPIClient from '../../../services/ssrApi'; +import FormData from 'form-data'; + const style = { position: 'absolute' as const, top: '50%', @@ -44,6 +45,8 @@ const Alert = React.forwardRef(function Alert( }); export default function clients({clients, userName}) { + const formData = new FormData(); + const [client, setClient] = useState({ name: String, email: String, @@ -51,6 +54,7 @@ export default function clients({clients, userName}) { password_confirmation: String, client_id: Number }) + const [logo, setLogo] = useState(false); const [selectedClients, setSelectedClients] = useState([]) const [open, setOpen] = useState(false); @@ -60,7 +64,6 @@ export default function clients({clients, userName}) { const [openModal, setOpenModal] = useState(false) - // const [openSnackSuccess, setOpenSnackSuccess] = useState(false); const [openSnackError, setOpenSnackError] = useState(false); const [openSnackSuccessDelete, setOpenSnackSuccessDelete] = useState(false); @@ -83,16 +86,20 @@ export default function clients({clients, userName}) { setOpenSnackErrorDelete(false); setOpenSnackSuccessDelete(false); }; - // + + function onChange(e) { + setLogo(e.target.files[0]) + } function handleCreateClient({name, email, password, password_confirmation, client_id}) { - api.post('/user', { - name, - email, - password, - password_confirmation, - client_id - }).then(res => { + 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) + + api.post('/user', formData).then(res => { setOpenSnackSuccess(true) setOpenModalInativar(false) window.location.reload() @@ -114,28 +121,28 @@ export default function clients({clients, userName}) {
      - Usuario cadastrada com sucesso! + Cliente cadastrada com Sucesso! - Usuario não cadastrada! + Cliente não cadastrado! - Usuario excluida com sucesso! + Cliente excluido com sucesso! - Usuario não excluida! + Cliente não excluido! -
      +
      @@ -189,17 +196,19 @@ export default function clients({clients, userName}) { client_id: value.target.value }) }} variant="outlined" /> - + + {/* */}

      - console.log()} /> + setOpen(false)} /> handleCreateClient(client)}/> + {setOpenModalInativar(value)}}> - + handleDeleteClient(selectedClients)}/> - setOpenModalInativar(true)}/> + setOpenModalInativar(false)}/>
      @@ -210,7 +219,6 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) - let clients = []; await apiClient.get('/user').then(res => { 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/industryInfo/index.tsx b/src/pages/administrative/industryInfo/index.tsx new file mode 100644 index 0000000..82b55c6 --- /dev/null +++ b/src/pages/administrative/industryInfo/index.tsx @@ -0,0 +1,48 @@ +import { GetServerSideProps } from 'next' +import Head from 'next/head' +import { parseCookies } from 'nookies' +import React from 'react' +import BasicButton from '../../../components/buttons/basicButton/BasicButton' +import Header from '../../../components/header/Header' +import PageTitle from '../../../components/pageTitle/PageTitle' +import { IndustryInfoView } from '../../../styles/layouts/industryInfo/IndustryInfoView' +import InputUploadPdf from '../../../components/inputUploadPdf/inputUpload'; + +export default function industryInfo({userName}: any) { + return ( + + + Smart Energia - Info de Setor + +

      +
      + + +
      + + console.log()} title='Atualizar'/> + + + ) +} + +export const getServerSideProps: GetServerSideProps = async (ctx) => { + const { ['@smartAuth-token']: token } = parseCookies(ctx) + const { ['user-name']: userName } = parseCookies(ctx) + + if (!token) { + return { + redirect: { + destination: '/', + permanent: false + } + } + } + + return { + props: { + userName + } + } +} + 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/index.tsx b/src/pages/index.tsx index 6229b84..a95fd64 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -8,23 +8,39 @@ import Head from 'next/head'; import Image from 'next/image'; import Link from 'next/link'; import { useRouter } from 'next/router' -import React, { useContext, useState } from 'react' +import React, { useContext, useState, useEffect,useCallback } from 'react' import { AiOutlineEye, AiOutlineEyeInvisible } from 'react-icons/ai'; +import RenderIf from '../utils/renderIf'; +import Snackbar from '@mui/material/Snackbar'; import LoginButton from '../components/buttons/loginButton/LoginButton'; import { AuthContext } from '../contexts/AuthContext'; import { api } from '../services/api'; import { LoginContainer, LoginView } from '../styles/layouts/login/LoginView'; import Dashboard from './dashboard'; +import MuiAlert, { AlertProps } from '@mui/material/Alert'; + +const Alert = React.forwardRef(function Alert( + props, + ref, +) { + return ; +}); export default function Home() { + const [openSnackSuccess, setOpenSnackSuccess] = useState(false); + const [openSnackError, setOpenSnackError] = useState(false); + const [openSnackSuccessDelete, setOpenSnackSuccessDelete] = useState(false); + const [openSnackErrorDelete, setOpenSnackErrorDelete] = useState(false); + const [state, setstate] = useState(false); const [values, setValues] = useState({ - password: '', + + password: null, showPassword: false, }); - const [email, setEmail] = useState() + const [email, setEmail] = useState("") const [password, setPassword] = useState() const router = useRouter() @@ -42,6 +58,7 @@ export default function Home() { }); }; + const handleMouseDownPassword = (event) => { event.preventDefault(); }; @@ -49,25 +66,77 @@ export default function Home() { const { signIn } = useContext(AuthContext) async function handleSignIn() { - await signIn({email, password}) + if (email === "" || password === ""){ + setOpenSnackError(true) + }else{ + try { + await signIn({email, password}).then((res: any) => { + if (res.response.status === 422) { + setOpenSnackError(true) + } + }) + } catch (exception){ + console.log(exception) + } + } } + const handleCloseSnack = (event?: React.SyntheticEvent | Event, reason?: string) => { + if (reason === 'clickaway') { + return; + } + + setOpenSnackError(false); + setOpenSnackSuccess(false); + }; + + useEffect(() => { + setValues({ + password: null, + showPassword: false, + }); + setEmail("") + }, [rota]) + return ( - + Smart Energia + + + notificação cadastrada com sucesso! + + + + + Prencha os Campos corretamente! + + + {/* + + notificação excluida com sucesso! + + */} + {/* + + Notificação não excluida! + + */}
      - +

      Bem-Vindo

      Estratégias Inteligentes em
      Gestão de Energia

      - { - setEmail(value.target.value) + + { + setEmail(value.target.value) }}/> Password diff --git a/src/pages/industryInfo.tsx b/src/pages/industryInfo.tsx index fd0a898..ae55ada 100644 --- a/src/pages/industryInfo.tsx +++ b/src/pages/industryInfo.tsx @@ -15,7 +15,7 @@ export default function industryInfo({userName}: any) {
      - +
      diff --git a/src/pages/pld/index.tsx b/src/pages/pld/index.tsx index 828f79a..79a547c 100644 --- a/src/pages/pld/index.tsx +++ b/src/pages/pld/index.tsx @@ -26,9 +26,10 @@ interface pldInterface { graphByHourData: any, graphByMonthData: any userName: string, + clientMonth: any } -export default function pld({tableData, graphByHourData, graphByMonthData, userName}: pldInterface) { +export default function pld({tableData, graphByHourData, graphByMonthData, userName, clientMonth}: pldInterface) { const router = useRouter() const { region } = router.query @@ -115,26 +116,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 <> - - - - + + + + }) } - - - - - - - - - - - - - - - - - - - - - + { + tableData.result.map((data, index) => { + if (index === 0) { + return <> + + + + + + + + + } else if (index===1) { + return <> + + + + + + + + + } else if (index===2) { + 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ínxxxxxxxxxxxxxxxx
    Maxxxxxxxxxxxxxxxxx
    Desv Padxxxxxxxxxxxxxxxx
    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})}
    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})}
    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 +247,7 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN width: '22%', ml: 1 }}> - Dia + Mês
    @@ -295,7 +288,7 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN @@ -308,11 +301,21 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) - let tableData = []; + let clientMonth = []; await apiClient.post('/pld/list').then(res => { - tableData = res.data.data + tableData = res.data + }).catch(res => { + console.log(res) + }) + + await apiClient.post('/pld', { + "filters": [], + "fields": ["mes_ref"], + "distinct": true + }).then(res => { + clientMonth = res.data.data }).catch(res => { console.log(res) }) @@ -329,7 +332,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { return { props: { tableData, - userName + userName, + clientMonth } } } 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/pages/verifyEmail.tsx b/src/pages/verifyEmail.tsx index b4612bc..99591f9 100644 --- a/src/pages/verifyEmail.tsx +++ b/src/pages/verifyEmail.tsx @@ -46,7 +46,7 @@ export default function VerifyEmail() { Smart Energia - Verificar Email - + router.push('/')} />

    Bem-Vindo

    Estratégias Inteligentes em
    Gestão de Energia

    @@ -56,7 +56,9 @@ export default function VerifyEmail() { setSent(true)} /> + + setCode(value.target.value)} /> {verifyConfirmationCode()}} /> diff --git a/src/styles/layouts/forgotPassword/verifyEmail.ts b/src/styles/layouts/forgotPassword/verifyEmail.ts index d6ca2ab..8891e62 100644 --- a/src/styles/layouts/forgotPassword/verifyEmail.ts +++ b/src/styles/layouts/forgotPassword/verifyEmail.ts @@ -4,7 +4,7 @@ import styled from 'styled-components'; export const VerifyEmailView = styled.main<{auth: string}>` display: flex; display: ${props => props.auth == '/verifyEmail'? null : 'none'}; - justify-content: flex-end; + justify-content:center; align-items: center; width: 100%; 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{ diff --git a/yarn.lock b/yarn.lock index ed043f2..388eeb8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -771,6 +771,13 @@ dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.15.4": + version "7.18.3" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.18.3.tgz#c7b654b57f6f63cf7f8b418ac9ca04408c4579f4" + integrity sha512-38Y8f7YUhce/K7RMwTp7m0uCumpv9hZkitCbBClqQIow1qSbCvGkcegKOXpEWCQLfWmevgRiWokZ1GkpfhbZug== + dependencies: + regenerator-runtime "^0.13.4" + "@babel/template@^7.16.7": version "7.16.7" resolved "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz" @@ -944,6 +951,11 @@ version "1.1.3" resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6" +"@hookform/resolvers@^2.9.1": + version "2.9.1" + resolved "https://registry.yarnpkg.com/@hookform/resolvers/-/resolvers-2.9.1.tgz#59121e38d8fc95d2fd1f41c9631393cd21e10b65" + integrity sha512-80lyFFcExEB7A09PFnl8k7A3obQyDF6MyO/FThtwetk+MTedYMs08Aqf7mgWnOawFGyz5QF+TZXJSYiIZW2tEg== + "@humanwhocodes/config-array@^0.9.2": version "0.9.5" resolved "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.5.tgz" @@ -1459,6 +1471,11 @@ version "1.0.2" resolved "https://registry.yarnpkg.com/@types/keygrip/-/keygrip-1.0.2.tgz#513abfd256d7ad0bf1ee1873606317b33b1b2a72" +"@types/lodash@^4.14.175": + version "4.14.182" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.182.tgz#05301a4d5e62963227eaafe0ce04dd77c54ea5c2" + integrity sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q== + "@types/mime@^1": version "1.3.2" resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a" @@ -1536,6 +1553,11 @@ "@types/react" "*" csstype "^3.0.2" +"@types/yup@^0.29.14": + version "0.29.14" + resolved "https://registry.yarnpkg.com/@types/yup/-/yup-0.29.14.tgz#754f1dccedcc66fc2bbe290c27f5323b407ceb00" + integrity sha512-Ynb/CjHhE/Xp/4bhHmQC4U1Ox+I2OpfRYF3dnNgQqn1cHa6LK3H1wJMNPT02tSVZA6FYuXE2ITORfbnb6zBCSA== + "@typescript-eslint/eslint-plugin@^5.22.0": version "5.22.0" resolved "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.22.0.tgz" @@ -2921,6 +2943,13 @@ internal-slot@^1.0.3: has "^1.0.3" side-channel "^1.0.4" +invariant@^2.2.4: + version "2.2.4" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" + integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== + dependencies: + loose-envify "^1.0.0" + ip-regex@^4.1.0: version "4.3.0" resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-4.3.0.tgz#687275ab0f57fa76978ff8f4dddc8a23d5990db5" @@ -3344,6 +3373,11 @@ locate-path@^2.0.0: p-locate "^2.0.0" path-exists "^3.0.0" +lodash-es@^4.17.21: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee" + integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw== + lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" @@ -3356,7 +3390,7 @@ lodash.once@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" -lodash@^4.17.11: +lodash@^4.17.11, lodash@^4.17.21: version "4.17.21" resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz" @@ -3369,7 +3403,7 @@ log-update@^4.0.0: slice-ansi "^4.0.0" wrap-ansi "^6.2.0" -loose-envify@^1.1.0, loose-envify@^1.4.0: +loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0: version "1.4.0" resolved "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz" dependencies: @@ -3537,6 +3571,11 @@ mute-stream@~0.0.4: version "0.0.8" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" +nanoclone@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/nanoclone/-/nanoclone-0.2.1.tgz#dd4090f8f1a110d26bb32c49ed2f5b9235209ed4" + integrity sha512-wynEP02LmIbLpcYw8uBKpcfF6dmg2vcpKqxeH5UcoKEYdExslsdUA4ugFauuaeYdTB76ez6gJW8XAZ6CgkXYxA== + nanoid@^3.1.30: version "3.3.4" resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz" @@ -4035,6 +4074,11 @@ prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1: object-assign "^4.1.1" react-is "^16.13.1" +property-expr@^2.0.4: + version "2.0.5" + resolved "https://registry.yarnpkg.com/property-expr/-/property-expr-2.0.5.tgz#278bdb15308ae16af3e3b9640024524f4dc02cb4" + integrity sha512-IJUkICM5dP5znhCckHSv30Q4b5/JA5enCtkRHYaOVOAocnH/1BQEYTC5NMfT3AVl/iXKdr3aqQbQn9DxyWknwA== + punycode@^2.1.0: version "2.1.1" resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz" @@ -4071,10 +4115,23 @@ react-dom@18.1.0: loose-envify "^1.1.0" scheduler "^0.22.0" +react-hook-form@^7.32.2: + version "7.32.2" + resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.32.2.tgz#58ec2ab0239ce97969baa2faa03ced13fae913ac" + integrity sha512-F1A6n762xaRhvtQH5SkQQhMr19cCkHZYesTcKJJeNmrphiZp/cYFTIzC05FnQry0SspM54oPJ9tXFXlzya8VNQ== + react-icons@^4.3.1: version "4.3.1" resolved "https://registry.npmjs.org/react-icons/-/react-icons-4.3.1.tgz" +react-input-mask@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/react-input-mask/-/react-input-mask-2.0.4.tgz#9ade5cf8196f4a856dbf010820fe75a795f3eb14" + integrity sha512-1hwzMr/aO9tXfiroiVCx5EtKohKwLk/NT8QlJXHQ4N+yJJFyUuMT+zfTpLBwX/lK3PkuMlievIffncpMZ3HGRQ== + dependencies: + invariant "^2.2.4" + warning "^4.0.2" + react-is@^16.13.1, react-is@^16.7.0: version "16.13.1" resolved "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz" @@ -4569,6 +4626,11 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +toposort@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/toposort/-/toposort-2.0.2.tgz#ae21768175d1559d48bef35420b2f4962f09c330" + integrity sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg== + treeverse@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/treeverse/-/treeverse-2.0.0.tgz#036dcef04bc3fd79a9b79a68d4da03e882d8a9ca" @@ -4689,6 +4751,13 @@ walk-up-path@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/walk-up-path/-/walk-up-path-1.0.0.tgz#d4745e893dd5fd0dbb58dd0a4c6a33d9c9fec53e" +warning@^4.0.2: + version "4.0.3" + resolved "https://registry.yarnpkg.com/warning/-/warning-4.0.3.tgz#16e9e077eb8a86d6af7d64aa1e05fd85b4678ca3" + integrity sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w== + dependencies: + loose-envify "^1.0.0" + wcwidth@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" @@ -4755,3 +4824,16 @@ yallist@^4.0.0: yaml@^1.10.2, yaml@^1.7.2: version "1.10.2" resolved "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz" + +yup@^0.32.11: + version "0.32.11" + resolved "https://registry.yarnpkg.com/yup/-/yup-0.32.11.tgz#d67fb83eefa4698607982e63f7ca4c5ed3cf18c5" + integrity sha512-Z2Fe1bn+eLstG8DRR6FTavGD+MeAwyfmouhHsIUgaADz8jvFKbO/fXc2trJKZg+5EBjh4gGm3iU/t3onKlXHIg== + dependencies: + "@babel/runtime" "^7.15.4" + "@types/lodash" "^4.14.175" + lodash "^4.17.21" + lodash-es "^4.17.21" + nanoclone "^0.2.1" + property-expr "^2.0.4" + toposort "^2.0.2"