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,
|
labels,
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
label: '',
|
label: 'Estimado',
|
||||||
data: [],
|
data: [],
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: '#C2d5fb',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: dataset,
|
label: dataset,
|
||||||
|
|||||||
@ -9,65 +9,28 @@ import { parseCookies } from 'nookies';
|
|||||||
import { GetServerSideProps } from 'next';
|
import { GetServerSideProps } from 'next';
|
||||||
import getAPIClient from '../../services/ssrApi';
|
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 {
|
interface headerInterface {
|
||||||
name: string,
|
name: string,
|
||||||
admin?: boolean | undefined
|
admin?: boolean | undefined
|
||||||
logo?: string
|
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 (
|
return (
|
||||||
<HeaderView>
|
<HeaderView>
|
||||||
<section>
|
<div className='icon' >
|
||||||
</section>
|
<p>
|
||||||
<section>
|
olá, {name}
|
||||||
{
|
</p>
|
||||||
!admin?
|
</div>
|
||||||
// <Image src={logo} width={170} height={50} />
|
{
|
||||||
null
|
!admin?
|
||||||
:
|
<Image src={profile_picture} height={50} width={75}/>
|
||||||
null
|
:
|
||||||
}
|
null
|
||||||
<div className='icon' >
|
}
|
||||||
<p>
|
|
||||||
olá, {name}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
{
|
|
||||||
!admin?
|
|
||||||
<Image src={profile_picture} alt='teste' height={45} width={50} />
|
|
||||||
:
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
</section>
|
|
||||||
</HeaderView>
|
</HeaderView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,24 +2,10 @@ import styled from "styled-components";
|
|||||||
|
|
||||||
export const HeaderView = styled.header`
|
export const HeaderView = styled.header`
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: flex-end;
|
||||||
|
|
||||||
margin: 0 0 75px 0;
|
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
section {
|
|
||||||
width: 30%;
|
|
||||||
|
|
||||||
:last-child {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
height: fit-content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -32,6 +18,8 @@ export const HeaderView = styled.header`
|
|||||||
|
|
||||||
background-color: #254F7F;
|
background-color: #254F7F;
|
||||||
|
|
||||||
|
margin-right: 20px;
|
||||||
|
|
||||||
p{
|
p{
|
||||||
color: white;
|
color: white;
|
||||||
margin-left: 15%;
|
margin-left: 15%;
|
||||||
|
|||||||
@ -64,6 +64,9 @@ export function AuthProvider({children}: {children: React.ReactNode}) {
|
|||||||
if (user.client_id)
|
if (user.client_id)
|
||||||
setCookie(undefined, 'user-client_id', 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}`
|
api.defaults.headers['Authorization'] = `Bearer ${token}`
|
||||||
|
|
||||||
if (!exception) {
|
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)' />
|
<PageTitle title='Economia Bruta Mensal' subtitle='Economia Bruta Estimada e Acumulada mensal (Valores em R$ mil)' />
|
||||||
<section>
|
<section>
|
||||||
<SingleBar title='Economia Bruta Estimada e Acumulada' subtitle='(Valores em R$ mil)' dataset='Consolidada'
|
<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
|
||||||
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
|
return 0
|
||||||
})}
|
})}
|
||||||
label={years} barLabel month/>
|
label={years} barLabel/>
|
||||||
</section>
|
</section>
|
||||||
</AccumulatedSavingsView>
|
</AccumulatedSavingsView>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -4,41 +4,12 @@ import { parseCookies } from 'nookies'
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import Chart from '../components/graph/Chart'
|
import Chart from '../components/graph/Chart'
|
||||||
import { SingleBar } from '../components/graph/SingleBar'
|
|
||||||
import Header from '../components/header/Header'
|
import Header from '../components/header/Header'
|
||||||
import PageTitle from '../components/pageTitle/PageTitle'
|
import PageTitle from '../components/pageTitle/PageTitle'
|
||||||
import { dataEconomiaBruta } from '../services/economiaBruta'
|
|
||||||
import { dataEconomiaIndicador } from '../services/economiaIndicador'
|
|
||||||
import getAPIClient from '../services/ssrApi'
|
import getAPIClient from '../services/ssrApi'
|
||||||
import { CostIndicatorView } from '../styles/layouts/economy/costIndicator/CostIndicatorView'
|
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) {
|
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 (
|
return (
|
||||||
<CostIndicatorView>
|
<CostIndicatorView>
|
||||||
<Head>
|
<Head>
|
||||||
|
|||||||
@ -19,11 +19,11 @@ export default function EstimatedCost({graphData, userName}: any) {
|
|||||||
<title>Smart Energia - Custos Estimados</title>
|
<title>Smart Energia - Custos Estimados</title>
|
||||||
</Head>
|
</Head>
|
||||||
<Header name={userName} />
|
<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>
|
<section>
|
||||||
<LineBarChart2 data1={graphData} data2={graphData} data3={graphData}
|
<LineBarChart2 data1={graphData} data2={graphData} data3={graphData}
|
||||||
dataset1="Economia (R$)" dataset2='Cativo' dataset3='Livre'
|
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>
|
</section>
|
||||||
</EstimatedCostView>
|
</EstimatedCostView>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -146,7 +146,7 @@ export default function Home() {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</InputAdornment>
|
</InputAdornment>
|
||||||
}
|
}
|
||||||
label="Password"
|
label="Senha"
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<Link href='verifyEmail'>Esqueceu a senha ?</Link>
|
<Link href='verifyEmail'>Esqueceu a senha ?</Link>
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export default function Notifications({notificationData, userName}: any) {
|
|||||||
<title>Smart Energia - Notificações</title>
|
<title>Smart Energia - Notificações</title>
|
||||||
</Head>
|
</Head>
|
||||||
<Header name={userName} />
|
<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' >
|
<section className='CommonQuestionsSection' >
|
||||||
{
|
{
|
||||||
notificationData.map((value, index ) => {
|
notificationData.map((value, index ) => {
|
||||||
|
|||||||
@ -160,7 +160,12 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<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 <>
|
return <>
|
||||||
<tr>
|
<tr>
|
||||||
<td className='tg-gceh'>{data.year_month_formatted}</td>
|
<td className='tg-gceh'>{data.year_month_formatted}</td>
|
||||||
@ -210,7 +215,7 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div className='btnDownload'>
|
<div className='btnDownload'>
|
||||||
<BasicButton onClick={''} title='Download'/>
|
<BasicButton onClick={() => console.log()} title='Download'/>
|
||||||
</div>
|
</div>
|
||||||
<section>
|
<section>
|
||||||
|
|
||||||
@ -251,9 +256,9 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
</div>
|
</div>
|
||||||
<FormControl sx={{
|
<FormControl sx={{
|
||||||
width: '22%',
|
width: '22%',
|
||||||
ml: 1
|
ml: 1
|
||||||
}}>
|
}}>
|
||||||
<InputLabel id="demo-simple-select-label">Mês</InputLabel>
|
<InputLabel id="demo-simple-select-label">Mês</InputLabel>
|
||||||
<Select
|
<Select
|
||||||
value={day}
|
value={day}
|
||||||
@ -261,7 +266,6 @@ export default function pld({tableData, graphByHourData, graphByMonthData, userN
|
|||||||
displayEmpty
|
displayEmpty
|
||||||
placeholder='dia'
|
placeholder='dia'
|
||||||
label="Age"
|
label="Age"
|
||||||
|
|
||||||
>
|
>
|
||||||
<MenuItem value={'0'}>Nenhum</MenuItem>
|
<MenuItem value={'0'}>Nenhum</MenuItem>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -163,7 +163,7 @@ export default function ResumoOperacao({tableData, clientsData, userName, client
|
|||||||
<tr>
|
<tr>
|
||||||
<td key={index} className='tg-gceh'>{value.cod_smart_unidade}</td>
|
<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-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-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-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>
|
<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 = {
|
type UserObjectType = {
|
||||||
name: string;
|
name: string;
|
||||||
email: string;
|
email: string;
|
||||||
client_id: number
|
client_id: number;
|
||||||
id: number,
|
id: number;
|
||||||
role: number
|
role: number;
|
||||||
|
profile_picture?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function signInRequest(data: SignInRequestData) {
|
export async function signInRequest(data: SignInRequestData) {
|
||||||
@ -33,7 +34,8 @@ export async function signInRequest(data: SignInRequestData) {
|
|||||||
email: res.data.user.email,
|
email: res.data.user.email,
|
||||||
client_id: res.data.user.client_id,
|
client_id: res.data.user.client_id,
|
||||||
id: res.data.user.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 => {
|
}).catch(res => {
|
||||||
exception = res
|
exception = res
|
||||||
@ -46,7 +48,8 @@ export async function signInRequest(data: SignInRequestData) {
|
|||||||
email: user?.email,
|
email: user?.email,
|
||||||
client_id: user?.client_id,
|
client_id: user?.client_id,
|
||||||
id: user?.id,
|
id: user?.id,
|
||||||
role: user?.role
|
role: user?.role,
|
||||||
|
profile_picture: user?.profile_picture
|
||||||
},
|
},
|
||||||
exception
|
exception
|
||||||
}
|
}
|
||||||
@ -62,7 +65,8 @@ export default async function recoverUserInformation(id) {
|
|||||||
email: res.data.user.email,
|
email: res.data.user.email,
|
||||||
client_id: res.data.user.client_id,
|
client_id: res.data.user.client_id,
|
||||||
id: res.data.user.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 => {
|
}).catch(res => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
@ -73,7 +77,8 @@ export default async function recoverUserInformation(id) {
|
|||||||
name: user?.name,
|
name: user?.name,
|
||||||
email: user?.email,
|
email: user?.email,
|
||||||
client_id: user?.client_id,
|
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