From 4401878f24d4f4fbec49372aded09c44dc53533d Mon Sep 17 00:00:00 2001 From: joseCorte-exe Date: Mon, 11 Jul 2022 16:09:24 -0300 Subject: [PATCH] fix units --- src/pages/costIndicator/index.tsx | 5 +++-- src/pages/economy/index.tsx | 3 ++- src/pages/estimatedCost/index.tsx | 4 ++-- src/pages/resumoOperacao/index.tsx | 28 ++++++++++++++++++++++++---- src/pages/telemetria/index.tsx | 5 +++-- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/pages/costIndicator/index.tsx b/src/pages/costIndicator/index.tsx index 959bd63..3e87bbe 100644 --- a/src/pages/costIndicator/index.tsx +++ b/src/pages/costIndicator/index.tsx @@ -95,7 +95,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) - const { ['user-client_id']: id } = parseCookies(ctx) + const { ['user-client_id']: client_id } = parseCookies(ctx) + let graphData = []; @@ -103,7 +104,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { await apiClient.post('/units', { "filters": [ - {"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": 180201211}, + {"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": client_id}, {"type" : "not_in", "field": "dados_cadastrais.codigo_scde", "value":["0P"]} ], "fields": [ diff --git a/src/pages/economy/index.tsx b/src/pages/economy/index.tsx index dde650d..86869a0 100644 --- a/src/pages/economy/index.tsx +++ b/src/pages/economy/index.tsx @@ -190,6 +190,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) + const { ['user-client_id']: client_id } = parseCookies(ctx) let anual = []; @@ -217,7 +218,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { await apiClient.post('/units', { "filters": [ - {"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": 180201211}, + {"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": client_id}, {"type" : "not_in", "field": "dados_cadastrais.codigo_scde", "value":["0P"]} ], "fields": [ diff --git a/src/pages/estimatedCost/index.tsx b/src/pages/estimatedCost/index.tsx index a6652f5..8c25309 100644 --- a/src/pages/estimatedCost/index.tsx +++ b/src/pages/estimatedCost/index.tsx @@ -76,14 +76,14 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) - const { ['user-client_id']: id } = parseCookies(ctx) + const { ['user-client_id']: client_id } = parseCookies(ctx) let graphData = []; let clients = []; await apiClient.post('/units', { "filters": [ - {"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": 180201211}, + {"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": client_id}, {"type" : "not_in", "field": "dados_cadastrais.codigo_scde", "value":["0P"]} ], "fields": [ diff --git a/src/pages/resumoOperacao/index.tsx b/src/pages/resumoOperacao/index.tsx index 6efd3d0..27d4b85 100644 --- a/src/pages/resumoOperacao/index.tsx +++ b/src/pages/resumoOperacao/index.tsx @@ -20,6 +20,10 @@ import data from '../../services/dados.json' import getAPIClient from '../../services/ssrApi'; import { Pagination, TableBodyView, TableHeader, TableView } from '../../styles/layouts/ResumoOperacao/ResumoOperacaoView'; +import Fab from '@mui/material/Fab'; + +import NavigationIcon from '@mui/icons-material/Navigation'; + export default function ResumoOperacao({tableData, clients, userName, clientMonth}: any) { const csvData = tableData; @@ -38,6 +42,13 @@ export default function ResumoOperacao({tableData, clients, userName, clientMont setUnidade(event.target.value); }; + const [ pageYPosition, setPageYPosition ] = useState(0); + + function getPageYAfterScroll(){ + setPageYPosition(window.scrollY); + console.log(window.scrollY) + } + function downloadCSVFile(csv, filename) { const csv_file = new Blob(["\ufeff",csv], {type: "text/csv"}); const download_link = document.createElement("a"); @@ -88,6 +99,10 @@ export default function ResumoOperacao({tableData, clients, userName, clientMont } }, [month, unidade]) + useEffect(() => { + window?.addEventListener('scroll', getPageYAfterScroll); + }, []) + return ( @@ -97,7 +112,7 @@ export default function ResumoOperacao({tableData, clients, userName, clientMont -
+
@@ -173,7 +188,7 @@ export default function ResumoOperacao({tableData, clients, userName, clientMont { - tableDataState.map((value, index) => { + tableDataState?.map((value, index) => { if (value.mes.slice(4,7) != '2020') return {value.mes} @@ -189,6 +204,11 @@ export default function ResumoOperacao({tableData, clients, userName, clientMont + {pageYPosition > 300 && + + + + } ) } @@ -196,7 +216,7 @@ export default function ResumoOperacao({tableData, clients, userName, clientMont export const getServerSideProps: GetServerSideProps = async (ctx) => { const apiClient = getAPIClient(ctx) const { ['@smartAuth-token']: token } = parseCookies(ctx) - const { ['user-id']: id } = parseCookies(ctx) + const { ['user-client_id']: client_id } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) let tableData = []; @@ -222,7 +242,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { await apiClient.post('/units', { "filters": [ - {"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": 180201211}, + {"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": client_id}, {"type" : "not_in", "field": "dados_cadastrais.codigo_scde", "value":["0P"]} ], "fields": [ diff --git a/src/pages/telemetria/index.tsx b/src/pages/telemetria/index.tsx index f7d6f3c..3ee4058 100644 --- a/src/pages/telemetria/index.tsx +++ b/src/pages/telemetria/index.tsx @@ -412,14 +412,15 @@ export default function Telemetria({userName, clients}: any) { export const getServerSideProps: GetServerSideProps = async (ctx) => { const { ['@smartAuth-token']: token } = parseCookies(ctx) const { ['user-name']: userName } = parseCookies(ctx) - const { ['user-client_id']: id } = parseCookies(ctx) + const { ['user-client_id']: client_id } = parseCookies(ctx) + const apiClient = getAPIClient(ctx) let clients = [] await apiClient.post('/units', { "filters": [ - {"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": 180201211}, + {"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": client_id}, {"type" : "not_in", "field": "dados_cadastrais.codigo_scde", "value":["0P"]} ], "fields": [