From 8f3a423cd64ead6cfdc564983efa54010619b599 Mon Sep 17 00:00:00 2001 From: Joao Paulo Nunes Soares Date: Tue, 6 Jul 2021 11:08:02 -0300 Subject: [PATCH] Adding validation and fixing caption frames wrong url --- src/components/ChartAndReport/index.js | 6 ++++-- src/containers/Audiencias/index.js | 3 +++ src/pages/_app.js | 2 +- src/utils/format/date/index.js | 4 ++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/ChartAndReport/index.js b/src/components/ChartAndReport/index.js index c2fbbdbe..c7aad847 100644 --- a/src/components/ChartAndReport/index.js +++ b/src/components/ChartAndReport/index.js @@ -57,7 +57,7 @@ function getColumns(data) { export default function ChartAndReport(props) { const { isLoaded, title, data, chartType, chartOptions, exportData, - apiLastUpdate, tool, height, + apiLastUpdate, tool, height, apiUrl, } = props; const [wayOfVisualizeData, setWayOfVisualizeData] = useState('chart'); const convertDataToJson = convertArrayToJSON(data); @@ -80,7 +80,7 @@ export default function ChartAndReport(props) { exportData={exportData} download align="center" - apiUrl={process.env.NEXT_PUBLIC_AUDIENCIAS_SWAGGER_URL} + apiUrl={apiUrl} apiLastUpdate={apiLastUpdate} tool={tool} > @@ -143,6 +143,7 @@ ChartAndReport.propTypes = { apiLastUpdate: PropTypes.string, tool: PropTypes.string, height: PropTypes.string, + apiUrl: PropTypes.string, }; ChartAndReport.defaultProps = { @@ -155,4 +156,5 @@ ChartAndReport.defaultProps = { apiLastUpdate: 'Carregando', tool: '', height: '35vh', + apiUrl: process.env.NEXT_PUBLIC_EDEMOCRACIA_SWAGGER_URL, }; diff --git a/src/containers/Audiencias/index.js b/src/containers/Audiencias/index.js index ac686688..5108fb28 100644 --- a/src/containers/Audiencias/index.js +++ b/src/containers/Audiencias/index.js @@ -492,6 +492,7 @@ function Audiencias(props) { apiLastUpdate={apiLastConsolidateOfDataDate} tool={TOOLNAME} isLoaded + apiUrl={process.env.NEXT_PUBLIC_AUDIENCIAS_SWAGGER_URL} /> ) : ( ) : ( @@ -597,6 +599,7 @@ function Audiencias(props) { chartOptions={audiencesChartsUsersSettings.options} apiLastUpdate={apiLastConsolidateOfDataDate} tool={TOOLNAME} + apiUrl={process.env.NEXT_PUBLIC_AUDIENCIAS_SWAGGER_URL} /> ) : ( diff --git a/src/pages/_app.js b/src/pages/_app.js index c038b3dd..ad873ec3 100644 --- a/src/pages/_app.js +++ b/src/pages/_app.js @@ -44,7 +44,7 @@ export default function MyApp(props) { <> - + diff --git a/src/utils/format/date/index.js b/src/utils/format/date/index.js index b0c0ebe6..2015d2af 100644 --- a/src/utils/format/date/index.js +++ b/src/utils/format/date/index.js @@ -2,6 +2,10 @@ // Format date to format DD/MM/YYYY export function formatDate(input) { + if (!input) { + return '00/00/00'; + } + const datePart = input.match(/\d+/g); const year = datePart[0].substring(2); const month = datePart[1];