From 940c2f0a87d3a6c0d80b16a3ea83121538b8fd66 Mon Sep 17 00:00:00 2001 From: joseCorte-exe Date: Mon, 27 Jun 2022 16:47:26 -0300 Subject: [PATCH] fixing --- .vscode/settings.json | 3 ++ src/components/graph/SingleBar.tsx | 4 +- src/components/header/Header.tsx | 65 +++++++---------------------- src/components/header/HeaderView.ts | 18 ++------ src/contexts/AuthContext.tsx | 3 ++ src/pages/accumulatedSavings.tsx | 4 +- src/pages/costIndicator.tsx | 29 ------------- src/pages/estimatedCost.tsx | 4 +- src/pages/index.tsx | 2 +- src/pages/notifications.tsx | 2 +- src/pages/pld/index.tsx | 16 ++++--- src/pages/resumoOperacao.tsx | 2 +- src/services/auth.ts | 19 +++++---- 13 files changed, 54 insertions(+), 117 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7b6080f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cSpell.language": "pt-BR,en" +} diff --git a/src/components/graph/SingleBar.tsx b/src/components/graph/SingleBar.tsx index f73e27d..2fec803 100644 --- a/src/components/graph/SingleBar.tsx +++ b/src/components/graph/SingleBar.tsx @@ -75,9 +75,9 @@ export function SingleBar({ title, subtitle, dataProps, label, dataset, barLabel labels, datasets: [ { - label: '', + label: 'Estimado', data: [], - backgroundColor: 'transparent', + backgroundColor: '#C2d5fb', }, { label: dataset, diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index dba6dd7..c78683c 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -9,65 +9,28 @@ import { parseCookies } from 'nookies'; import { GetServerSideProps } from 'next'; import getAPIClient from '../../services/ssrApi'; -function stringToColor(string: string) { - let hash = 0; - let i; - - for (i = 0; i < string.length; i += 1) { - hash = string.charCodeAt(i) + ((hash << 5) - hash); - } - - let color = '#'; - - for (i = 0; i < 3; i += 1) { - const value = (hash >> (i * 8)) & 0xff; - color += `00${value.toString(16)}`.slice(-2); - } - - return color; -} - -function stringAvatar(profile_picture: string) { - return { - - children: `${profile_picture}`, - }; -} - - interface headerInterface { name: string, admin?: boolean | undefined logo?: string - profile_picture: string } -export default function Header({ name, admin, profile_picture }: headerInterface) { +export default function Header({name, admin}: headerInterface) { + const { ['user-profile_picture']: profile_picture } = parseCookies() + return ( -
-
-
- { - !admin? - // - null - : - null - } -
-

- olá, {name} -

-
- { - !admin? - teste - : - null - } - -
+
+

+ olá, {name} +

+
+ { + !admin? + + : + null + }
) } diff --git a/src/components/header/HeaderView.ts b/src/components/header/HeaderView.ts index c3a4f2e..bdeeb85 100644 --- a/src/components/header/HeaderView.ts +++ b/src/components/header/HeaderView.ts @@ -2,24 +2,10 @@ import styled from "styled-components"; export const HeaderView = styled.header` display: flex; - justify-content: space-between; - - margin: 0 0 75px 0; + justify-content: flex-end; width: 100%; - section { - width: 30%; - - :last-child { - display: flex; - justify-content: flex-end; - align-items: center; - - height: fit-content; - } - } - .icon { display: flex; align-items: center; @@ -32,6 +18,8 @@ export const HeaderView = styled.header` background-color: #254F7F; + margin-right: 20px; + p{ color: white; margin-left: 15%; diff --git a/src/contexts/AuthContext.tsx b/src/contexts/AuthContext.tsx index 4dd6c8f..ab53abb 100644 --- a/src/contexts/AuthContext.tsx +++ b/src/contexts/AuthContext.tsx @@ -64,6 +64,9 @@ export function AuthProvider({children}: {children: React.ReactNode}) { if (user.client_id) setCookie(undefined, 'user-client_id', user.client_id) + if (user.profile_picture) + setCookie(undefined, 'user-profile_picture', user.profile_picture) + api.defaults.headers['Authorization'] = `Bearer ${token}` if (!exception) { diff --git a/src/pages/accumulatedSavings.tsx b/src/pages/accumulatedSavings.tsx index 7fffbce..894de4c 100644 --- a/src/pages/accumulatedSavings.tsx +++ b/src/pages/accumulatedSavings.tsx @@ -22,13 +22,13 @@ export default function AccumulatedSavings({graphData, years, userName}: any) {
{ + dataProps={graphData.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 })} - label={years} barLabel month/> + label={years} barLabel/>
) diff --git a/src/pages/costIndicator.tsx b/src/pages/costIndicator.tsx index e3e2e6d..72cd245 100644 --- a/src/pages/costIndicator.tsx +++ b/src/pages/costIndicator.tsx @@ -4,41 +4,12 @@ import { parseCookies } from 'nookies' import React from 'react' import Chart from '../components/graph/Chart' -import { SingleBar } from '../components/graph/SingleBar' import Header from '../components/header/Header' import PageTitle from '../components/pageTitle/PageTitle' -import { dataEconomiaBruta } from '../services/economiaBruta' -import { dataEconomiaIndicador } from '../services/economiaIndicador' import getAPIClient from '../services/ssrApi' import { CostIndicatorView } from '../styles/layouts/economy/costIndicator/CostIndicatorView' -function verifyDataByYear(data) { - 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) { - // console.log(graphData.filter((value, index) => value.mes.slice(3, 7).includes('2021')).map(value => value.custo_unit)) - return ( diff --git a/src/pages/estimatedCost.tsx b/src/pages/estimatedCost.tsx index e4915eb..7cc1d66 100644 --- a/src/pages/estimatedCost.tsx +++ b/src/pages/estimatedCost.tsx @@ -19,11 +19,11 @@ export default function EstimatedCost({graphData, userName}: any) { Smart Energia - Custos Estimados
- +
+ label={ConsumoEstimado.label} title='' subtitle='' barLabel hashurado />
) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 981df29..09dd6e2 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -146,7 +146,7 @@ export default function Home() { } - label="Password" + label="Senha" /> Esqueceu a senha ? diff --git a/src/pages/notifications.tsx b/src/pages/notifications.tsx index 0871470..c9fa136 100644 --- a/src/pages/notifications.tsx +++ b/src/pages/notifications.tsx @@ -16,7 +16,7 @@ export default function Notifications({notificationData, userName}: any) { Smart Energia - Notificações
- +
{ notificationData.map((value, index ) => { diff --git a/src/pages/pld/index.tsx b/src/pages/pld/index.tsx index 492e1d2..1fa7fc8 100644 --- a/src/pages/pld/index.tsx +++ b/src/pages/pld/index.tsx @@ -160,7 +160,12 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN { - tableData.data.map(data => { + tableData.data.sort((a, b) => { + if (parseFloat(a.year_month_formatted.slice(0,2)) > parseFloat(b.year_month_formatted.slice(1,2))) return 1 + if (parseFloat(a.year_month_formatted.slice(0,2)) < parseFloat(b.year_month_formatted.slice(1,2))) return -1 + + return 0 + }).map(data => { return <> {data.year_month_formatted} @@ -210,7 +215,7 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
- + console.log()} title='Download'/>
@@ -251,9 +256,9 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN + width: '22%', + ml: 1 + }}> Mês