diff --git a/src/components/graph/SingleBar.tsx b/src/components/graph/SingleBar.tsx index 1585ff6..1bb3815 100644 --- a/src/components/graph/SingleBar.tsx +++ b/src/components/graph/SingleBar.tsx @@ -20,13 +20,16 @@ ChartJS.register( interface SingleBarInterface{ title: string, subtitle: string, - dataProps: Array, + dataProps: any, label: Array, dataset: string, barLabel?: boolean | undefined, year?: boolean | undefined, month?: boolean | undefined, dataset1?: string, + + + } export function SingleBar({ title, subtitle, dataProps, label, dataset, dataset1, barLabel, year, month }: SingleBarInterface) { @@ -79,19 +82,14 @@ export function SingleBar({ title, subtitle, dataProps, label, dataset, dataset1 { label: dataset, data: dataProps.map((value, index) => { - return year? label[index]<=currentTime.getFullYear().toString()? value : null : month? label.indexOf(label[index])>currentTime.getMonth()? null : value : null + return value.economia_acumulada }), backgroundColor: (value, ctx) => { - return year? label[value.dataIndex]<=currentTime.getFullYear().toString()? '#255488' : 'transparent' : month? label.indexOf(label[value.dataIndex])<=currentTime.getMonth()? '#255488' : 'transparent' : null// parseInt(label[value.dataIndex])<=currentTime.getMonth()? '#255488' : draw('diagonal', '#C2D5FB') : null + console.log(dataProps[value.dataIndex]) + return dataProps[value.dataIndex].dad_estimado == false ? '#255488' : '#C2d5fb' }, }, - { - label: dataset1, - data: dataProps.map((value, index) => { - return year? label[index]>=currentTime.getFullYear().toString()? value : null : month? label.indexOf(label[index])<=currentTime.getMonth()? null : value : null - }), - backgroundColor: typeof window !== 'undefined'? draw('diagonal', '#C2D5FB') : null - } + ], } diff --git a/src/components/modal/ConfirmModal.tsx b/src/components/modal/ConfirmModal.tsx index 6158dc2..7164eac 100644 --- a/src/components/modal/ConfirmModal.tsx +++ b/src/components/modal/ConfirmModal.tsx @@ -12,7 +12,7 @@ const style = { top: '50%', left: '50%', transform: 'translate(-50%, -50%)', - width: 900, + width: 600, height: 500, bgcolor: 'background.paper', border: '2px solid #254F7F', diff --git a/src/components/modal/Modal.tsx b/src/components/modal/Modal.tsx index a6b7957..1288582 100644 --- a/src/components/modal/Modal.tsx +++ b/src/components/modal/Modal.tsx @@ -13,7 +13,7 @@ const style = { left: '50%', transform: 'translate(-50%, -50%)', width: '80%', - height: '550px', + height: '200px', bgcolor: 'background.paper', border: '2px solid #254F7F', boxShadow: 24, diff --git a/src/pages/accumulatedSavings.tsx b/src/pages/accumulatedSavings.tsx index 1134f8f..6131c3f 100644 --- a/src/pages/accumulatedSavings.tsx +++ b/src/pages/accumulatedSavings.tsx @@ -1,4 +1,6 @@ +import { GetServerSideProps } from 'next' import Head from 'next/head' +import { parseCookies } from 'nookies' import React from 'react' import Chart from '../components/graph/Chart' @@ -7,9 +9,10 @@ import Header from '../components/header/Header' import PageTitle from '../components/pageTitle/PageTitle' import { EconomiaAcumulada } from '../services/economiaAcumulada' import { dataEconomiaBruta } from '../services/economiaBruta' +import getAPIClient from '../services/ssrApi' import { AccumulatedSavingsView } from '../styles/layouts/economy/accumulatedSavings/AccumulatedSavingsView' -export default function AccumulatedSavings() { +export default function AccumulatedSavings({graphData, years}: any) { return ( @@ -19,8 +22,42 @@ export default function AccumulatedSavings() {
+ dataset1='Estimada' dataProps={graphData} + label={years} barLabel month/>
) } + +export const getServerSideProps: GetServerSideProps = async (ctx) => { + const apiClient = getAPIClient(ctx) + const { ['@smartAuth-token']: token } = parseCookies(ctx) + + let graphData = []; + + await apiClient.post('/economy/grossMonthly').then(res => { + graphData = res.data.data + console.log(graphData[0].mes) + }).catch(res => { + console.log(res) + }) + + const years = graphData.map((value) => value.mes) + + if (!token) { + return { + redirect: { + destination: '/', + permanent: false + } + } + } + + + return { + props: { + graphData, + years, + } + } +} diff --git a/src/pages/administrative/faq/index.tsx b/src/pages/administrative/faq/index.tsx index ebf726e..592ac3a 100644 --- a/src/pages/administrative/faq/index.tsx +++ b/src/pages/administrative/faq/index.tsx @@ -55,7 +55,6 @@ type FaqInterface = { } export default function Sidebar({faqData} : any ) { -<<<<<<< HEAD const [openModalInativar, setOpenModalInativar] = useState(false) const [openSnackSuccess, setOpenSnackSuccess] = useState(false); @@ -104,9 +103,6 @@ export default function Sidebar({faqData} : any ) { const [selectedfaq, setSelectedfaq] = useState([]) -======= -export default function Sidebar({faqData}: any) { ->>>>>>> b045a2e541bdcd6882d728bf6a7d600768b93f1d async function handleRegisterNewFaq({question, answer}: FaqInterface) { await api.post('/faq', { "question": question, diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index d6f4f37..37b50a3 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -22,7 +22,7 @@ import { parseCookies } from 'nookies' import { GetServerSideProps } from 'next' import getAPIClient from '../services/ssrApi' -export default function Dashboard() { +export default function Dashboard({grossAnualGraph, grossAnualYears} : any) { return ( @@ -44,7 +44,10 @@ export default function Dashboard() {
- + @@ -66,8 +69,24 @@ export default function Dashboard() { } export const getServerSideProps: GetServerSideProps = async (ctx) => { + const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) + let grossAnualGraph = []; + + + + await apiClient.post('/economy/grossAnnual').then(res => { + grossAnualGraph = res.data.data + console.log(grossAnualGraph[0]) + }).catch(res => { + console.log(res) + }) + + + + const grossAnualYears = grossAnualGraph.map((value) => value.ano) + if (!token) { return { redirect: { @@ -77,7 +96,11 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { } } + return { - props: {} + props: { + grossAnualGraph, + grossAnualYears, + } } } diff --git a/src/pages/grossSavings.tsx b/src/pages/grossSavings.tsx index ac461e7..adf3d8a 100644 --- a/src/pages/grossSavings.tsx +++ b/src/pages/grossSavings.tsx @@ -1,5 +1,6 @@ import { GetServerSideProps } from 'next' import Head from 'next/head' +import { parseCookies } from 'nookies' import React from 'react' import Chart from '../components/graph/Chart' @@ -11,7 +12,19 @@ import getAPIClient from '../services/ssrApi' import { GrossSavingsView } from '../styles/layouts/economy/grossSavings/GrossSavings' -export default function GrossSavings() { +function addMissingMonths(data) { + console.log(data[0].mes.slice(1, 1)) +} + +function verifyDataByYear(data) { + if (data.length === 12) + return true + else + return false +} + + +export default function GrossSavings({graphData, years}: any) { return ( @@ -20,7 +33,12 @@ export default function GrossSavings() {
- + +
) @@ -29,23 +47,17 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) - let clients = []; - let notifications = []; - - await apiClient.get('/user').then(res => { - clients = res.data - }).catch(res => { - console.log(res) - }) - - await apiClient.get('/economy/grossAnnual').then(res => { - grossSaving = res.data - grossSaving.map(value) + let graphData = []; + await apiClient.post('/economy/grossAnnual').then(res => { + graphData = res.data.data + console.log(graphData[0]) }).catch(res => { console.log(res) }) + const years = graphData.map((value) => value.ano) + console.log(years) if (!token) { return { redirect: { @@ -55,10 +67,11 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { } } + return { props: { - clients, - grossSaving + graphData, + years, } } }