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