mores fixes
This commit is contained in:
parent
b4278cafcc
commit
3e8c5a70f2
@ -1,12 +1,11 @@
|
|||||||
import { BarElement, CategoryScale, Chart as ChartJS, Legend, LinearScale, Title, Tooltip } from 'chart.js';
|
import { BarElement, CategoryScale, Chart as ChartJS, Legend, LinearScale, Title, Tooltip } from 'chart.js';
|
||||||
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
||||||
import { draw, generate } from 'patternomaly'
|
import { draw } from 'patternomaly'
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { Bar, Chart } from 'react-chartjs-2';
|
import { Chart } from 'react-chartjs-2';
|
||||||
|
|
||||||
import { GrossAnualChartView } from './GrossAnualChartView';
|
import { GrossAnualChartView } from './GrossAnualChartView';
|
||||||
import ChartTitle from '../ChartTitle';
|
import ChartTitle from '../ChartTitle';
|
||||||
import { blue } from '@mui/material/colors';
|
|
||||||
|
|
||||||
ChartJS.register(
|
ChartJS.register(
|
||||||
CategoryScale,
|
CategoryScale,
|
||||||
@ -40,10 +39,9 @@ export function GrossAnualChart({ title, subtitle, dataProps, label, dataset, ba
|
|||||||
|
|
||||||
const options: any = {
|
const options: any = {
|
||||||
responsive: true,
|
responsive: true,
|
||||||
is3D: true,
|
|
||||||
scales: {
|
scales: {
|
||||||
x: {
|
x: {
|
||||||
grouped: false,
|
stacked: true,
|
||||||
font: {
|
font: {
|
||||||
size: 20
|
size: 20
|
||||||
},
|
},
|
||||||
@ -52,6 +50,7 @@ export function GrossAnualChart({ title, subtitle, dataProps, label, dataset, ba
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
y: {
|
y: {
|
||||||
|
stacked: true,
|
||||||
grid: {
|
grid: {
|
||||||
display: false
|
display: false
|
||||||
}
|
}
|
||||||
@ -78,7 +77,7 @@ export function GrossAnualChart({ title, subtitle, dataProps, label, dataset, ba
|
|||||||
display: true,
|
display: true,
|
||||||
color: '#255488',
|
color: '#255488',
|
||||||
anchor: "end",
|
anchor: "end",
|
||||||
offset: !miniature? -60 : -30,
|
offset: !miniature? -55 : -30,
|
||||||
align: "start",
|
align: "start",
|
||||||
font: {
|
font: {
|
||||||
size: !miniature? 22 : 10,
|
size: !miniature? 22 : 10,
|
||||||
@ -101,7 +100,7 @@ export function GrossAnualChart({ title, subtitle, dataProps, label, dataset, ba
|
|||||||
|
|
||||||
let labels: string[];
|
let labels: string[];
|
||||||
if (bruta) {
|
if (bruta) {
|
||||||
labels = label.map(value => value.replace('2021', 'Até 2021'))
|
labels = [`Até ${new Date().getFullYear()-1}`, `${new Date().getFullYear()}`]
|
||||||
} else {
|
} else {
|
||||||
labels = label
|
labels = label
|
||||||
}
|
}
|
||||||
@ -113,26 +112,20 @@ export function GrossAnualChart({ title, subtitle, dataProps, label, dataset, ba
|
|||||||
type: 'bar',
|
type: 'bar',
|
||||||
label: dataset,
|
label: dataset,
|
||||||
stacked: true,
|
stacked: true,
|
||||||
|
data: dataProps.filter(value => value.dad_estimado === false).map((value, index) => {
|
||||||
data: dataProps.map((value, index) => {
|
return parseFloat(value.economia_acumulada)
|
||||||
if (!value.dad_estimado)
|
|
||||||
return parseFloat(value.economia_acumulada).toFixed(2)
|
|
||||||
}),
|
}),
|
||||||
backgroundColor: (value, ctx) => {
|
backgroundColor: '#255488'
|
||||||
return '#255488'
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
stacked: true,
|
stacked: true,
|
||||||
label: 'Estimado',
|
label: 'Estimado',
|
||||||
data: dataProps.map((value, index) => {
|
data: dataProps.filter(value => value.ano === '2022').map((value, index) => {
|
||||||
if (value.dad_estimado)
|
if (value.dad_estimado)
|
||||||
return parseFloat(value.economia_acumulada).toFixed(2)
|
return parseFloat(value.economia_acumulada)
|
||||||
}),
|
}),
|
||||||
backgroundColor: (value, ctx) => {
|
backgroundColor: draw('diagonal-right-left', '#C2d5fb'),
|
||||||
return draw('diagonal-right-left', '#C2d5fb');
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import Router from 'next/router'
|
|||||||
|
|
||||||
import { destroyCookie, setCookie } from "nookies";
|
import { destroyCookie, setCookie } from "nookies";
|
||||||
|
|
||||||
import { signInRequest } from "../services/auth";
|
import { logout, signInRequest } from "../services/auth";
|
||||||
import { api } from "../services/api";
|
import { api } from "../services/api";
|
||||||
|
|
||||||
type UserType = {
|
type UserType = {
|
||||||
@ -37,6 +37,8 @@ export function AuthProvider({children}: {children: React.ReactNode}) {
|
|||||||
destroyCookie(null, 'user-role')
|
destroyCookie(null, 'user-role')
|
||||||
destroyCookie(null, 'user-id')
|
destroyCookie(null, 'user-id')
|
||||||
destroyCookie(null, '@smartAuth-token')
|
destroyCookie(null, '@smartAuth-token')
|
||||||
|
|
||||||
|
logout()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function signIn({email, password}: SignInData) {
|
async function signIn({email, password}: SignInData) {
|
||||||
|
|||||||
@ -2,10 +2,6 @@ import { api } from "./api";
|
|||||||
|
|
||||||
export const TOKEN_KEY = "@smartAuth-token";
|
export const TOKEN_KEY = "@smartAuth-token";
|
||||||
|
|
||||||
export const logout = () => {
|
|
||||||
localStorage.removeItem(TOKEN_KEY);
|
|
||||||
};
|
|
||||||
|
|
||||||
interface SignInRequestData {
|
interface SignInRequestData {
|
||||||
email: string,
|
email: string,
|
||||||
password: string
|
password: string
|
||||||
@ -81,3 +77,12 @@ export default async function recoverUserInformation(id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function logout() {
|
||||||
|
await api.post('/auth/logout', {})
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
|
.then(res => {})
|
||||||
|
.catch(res => {
|
||||||
|
console.log(res)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
|
||||||
export const EconomyView = styled.main`
|
export const EconomyView = styled.main`
|
||||||
|
section {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
`
|
`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user