fixing
This commit is contained in:
parent
e5bc75c60e
commit
940c2f0a87
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"cSpell.language": "pt-BR,en"
|
||||
}
|
||||
@ -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,
|
||||
|
||||
@ -9,52 +9,17 @@ 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 (
|
||||
<HeaderView>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
{
|
||||
!admin?
|
||||
// <Image src={logo} width={170} height={50} />
|
||||
null
|
||||
:
|
||||
null
|
||||
}
|
||||
<div className='icon' >
|
||||
<p>
|
||||
olá, {name}
|
||||
@ -62,12 +27,10 @@ export default function Header({ name, admin, profile_picture }: headerInterface
|
||||
</div>
|
||||
{
|
||||
!admin?
|
||||
<Image src={profile_picture} alt='teste' height={45} width={50} />
|
||||
<Image src={profile_picture} height={50} width={75}/>
|
||||
:
|
||||
null
|
||||
}
|
||||
|
||||
</section>
|
||||
</HeaderView>
|
||||
)
|
||||
}
|
||||
|
||||
@ -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%;
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -22,13 +22,13 @@ export default function AccumulatedSavings({graphData, years, userName}: any) {
|
||||
<PageTitle title='Economia Bruta Mensal' subtitle='Economia Bruta Estimada e Acumulada mensal (Valores em R$ mil)' />
|
||||
<section>
|
||||
<SingleBar title='Economia Bruta Estimada e Acumulada' subtitle='(Valores em R$ mil)' dataset='Consolidada'
|
||||
dataset1='Estimada' dataProps={graphData.sort((a, b) => {
|
||||
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/>
|
||||
</section>
|
||||
</AccumulatedSavingsView>
|
||||
)
|
||||
|
||||
@ -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 (
|
||||
<CostIndicatorView>
|
||||
<Head>
|
||||
|
||||
@ -19,11 +19,11 @@ export default function EstimatedCost({graphData, userName}: any) {
|
||||
<title>Smart Energia - Custos Estimados</title>
|
||||
</Head>
|
||||
<Header name={userName} />
|
||||
<PageTitle title='Cativo x Livre mensal' subtitle='Comparativo de Custo Estimado' />
|
||||
<PageTitle title='Cativo x Livre mensal' subtitle='Comparativo de custo Estimado - Valores em R$' />
|
||||
<section>
|
||||
<LineBarChart2 data1={graphData} data2={graphData} data3={graphData}
|
||||
dataset1="Economia (R$)" dataset2='Cativo' dataset3='Livre'
|
||||
label={ConsumoEstimado.label} title='Cativo x Livre mensal' subtitle='' barLabel hashurado />
|
||||
label={ConsumoEstimado.label} title='' subtitle='' barLabel hashurado />
|
||||
</section>
|
||||
</EstimatedCostView>
|
||||
)
|
||||
|
||||
@ -146,7 +146,7 @@ export default function Home() {
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
}
|
||||
label="Password"
|
||||
label="Senha"
|
||||
/>
|
||||
</FormControl>
|
||||
<Link href='verifyEmail'>Esqueceu a senha ?</Link>
|
||||
|
||||
@ -16,7 +16,7 @@ export default function Notifications({notificationData, userName}: any) {
|
||||
<title>Smart Energia - Notificações</title>
|
||||
</Head>
|
||||
<Header name={userName} />
|
||||
<PageTitle title='Notificações' subtitle='Aqui estão as notificaões publicadas para voce!' />
|
||||
<PageTitle title='Notificações' subtitle='Aqui estão as notificações publicadas para você!' />
|
||||
<section className='CommonQuestionsSection' >
|
||||
{
|
||||
notificationData.map((value, index ) => {
|
||||
|
||||
@ -160,7 +160,12 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
|
||||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
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 <>
|
||||
<tr>
|
||||
<td className='tg-gceh'>{data.year_month_formatted}</td>
|
||||
@ -210,7 +215,7 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
|
||||
</tbody>
|
||||
</table>
|
||||
<div className='btnDownload'>
|
||||
<BasicButton onClick={''} title='Download'/>
|
||||
<BasicButton onClick={() => console.log()} title='Download'/>
|
||||
</div>
|
||||
<section>
|
||||
|
||||
@ -261,7 +266,6 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
|
||||
displayEmpty
|
||||
placeholder='dia'
|
||||
label="Age"
|
||||
|
||||
>
|
||||
<MenuItem value={'0'}>Nenhum</MenuItem>
|
||||
{
|
||||
|
||||
@ -163,7 +163,7 @@ export default function ResumoOperacao({tableData, clientsData, userName, client
|
||||
<tr>
|
||||
<td key={index} className='tg-gceh'>{value.cod_smart_unidade}</td>
|
||||
<td key={index} className='tg-uulg'>{value.operacao}</td>
|
||||
<td key={index} className='tg-gceh'>{value.montante_nf}</td>
|
||||
<td key={index} className='tg-gceh'>{parseFloat(value.montante_nf).toLocaleString('pt-br')}</td>
|
||||
<td key={index} className='tg-gceh'>{value.contraparte}</td>
|
||||
<td key={index} className='tg-uulg'>{parseFloat(value.nf_c_icms).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})}</td>
|
||||
<td key={index} className='tg-gceh'>{parseFloat(value.preco_nf).toLocaleString('pt-br',{style: 'currency', currency: 'BRL', minimumFractionDigits: 2})}</td>
|
||||
|
||||
@ -14,9 +14,10 @@ interface SignInRequestData {
|
||||
type UserObjectType = {
|
||||
name: string;
|
||||
email: string;
|
||||
client_id: number
|
||||
id: number,
|
||||
role: number
|
||||
client_id: number;
|
||||
id: number;
|
||||
role: number;
|
||||
profile_picture?: string
|
||||
}
|
||||
|
||||
export async function signInRequest(data: SignInRequestData) {
|
||||
@ -33,7 +34,8 @@ export async function signInRequest(data: SignInRequestData) {
|
||||
email: res.data.user.email,
|
||||
client_id: res.data.user.client_id,
|
||||
id: res.data.user.id,
|
||||
role: res.data.user.roles[0].pivot.role_id
|
||||
role: res.data.user.roles[0].pivot.role_id,
|
||||
profile_picture: res.data.user.profile_picture
|
||||
}
|
||||
}).catch(res => {
|
||||
exception = res
|
||||
@ -46,7 +48,8 @@ export async function signInRequest(data: SignInRequestData) {
|
||||
email: user?.email,
|
||||
client_id: user?.client_id,
|
||||
id: user?.id,
|
||||
role: user?.role
|
||||
role: user?.role,
|
||||
profile_picture: user?.profile_picture
|
||||
},
|
||||
exception
|
||||
}
|
||||
@ -62,7 +65,8 @@ export default async function recoverUserInformation(id) {
|
||||
email: res.data.user.email,
|
||||
client_id: res.data.user.client_id,
|
||||
id: res.data.user.id,
|
||||
role: res.data.user.roles[0].pivot.role_id
|
||||
role: res.data.user.roles[0].pivot.role_id,
|
||||
profile_picture: res.data.user.profile_picture
|
||||
}
|
||||
}).catch(res => {
|
||||
console.log(res)
|
||||
@ -73,7 +77,8 @@ export default async function recoverUserInformation(id) {
|
||||
name: user?.name,
|
||||
email: user?.email,
|
||||
client_id: user?.client_id,
|
||||
id: user?.id
|
||||
id: user?.id,
|
||||
profile_picture: user?.profile_picture
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user