Skip to content

Commit

Permalink
fix-bug (#194)
Browse files Browse the repository at this point in the history
* fixing bug of chart not update when period is changed

* Fixing consolidade interval alert component to show in correct time

* Refactoring component
  • Loading branch information
joaopaulonsoares authored Sep 3, 2021
1 parent a1eb27b commit 37cbd13
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/components/AlertDataConsolidateInterval/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable radix */
/* eslint-disable max-len */
/* eslint-disable import/prefer-default-export */
/* eslint-disable react/destructuring-assignment */
Expand All @@ -14,9 +15,14 @@ export default function AlertDataConsolidateInterval() {
const [isInDataConsolidateInterval, setIsInDataConsolidateInterval] = useState(false);

function checkIfHourIsInInterval() {
const currentTime = `${(new Date().getHours())}:${(new Date().getMinutes())}`;
const date = new Date();
const currentTime = `${(date.getHours())}:${(date.getMinutes())}:00`;
const regExp = /(\d{1,2}):(\d{1,2}):(\d{1,2})/;

if (currentTime >= START_TIME_OF_DATA_CONSOLIDATION && currentTime <= END_TIME_OF_DATA_CONSOLIDATION) {
const isHourAfterBegginingOfConsolidation = parseInt(currentTime.replace(regExp, '$1$2$3')) > parseInt(START_TIME_OF_DATA_CONSOLIDATION.replace(regExp, '$1$2$3'));
const isHourBeforeEndOfConsolidation = parseInt(END_TIME_OF_DATA_CONSOLIDATION.replace(regExp, '$1$2$3')) > parseInt(currentTime.replace(regExp, '$1$2$3'));

if (isHourAfterBegginingOfConsolidation && isHourBeforeEndOfConsolidation) {
setIsInDataConsolidateInterval(true);
} else {
setIsInDataConsolidateInterval(false);
Expand Down
7 changes: 6 additions & 1 deletion src/components/ChartTotalRoomsWithFilter/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable react/require-default-props */
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';

import {
Expand Down Expand Up @@ -89,6 +89,11 @@ export default function ChartTotalRoomsWithFilter(props) {
const [columnsToNotShow, setColumnsToNotShow] = useState([]);
const [dataToShow, setDataToShow] = useState(data);

useEffect(async () => {
const tempDataToShow = await filterDataOfTotalRoomsMatrix(data, columnsToNotShow);
setDataToShow(tempDataToShow);
}, [data]);

async function handleShowColumsChange(event) {
let columnsToNotBeShow = [];

Expand Down
4 changes: 2 additions & 2 deletions src/settings/applicationOptions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ export const REFRESH_API_CACHE_DATA_INTERVAL = 900;// 900; // In seconds. (3600
export const SHOW_API_CACHE_ERROR_MESSAGE_LIMIT_TIME = 720; // In minutes (720 minutes = 12 hours)

// =============== HOUR SETTINGS ===============
export const START_TIME_OF_DATA_CONSOLIDATION = '1:00'; // In 24h format, in the format h:mm
export const END_TIME_OF_DATA_CONSOLIDATION = '2:30'; // In 24h format, in the format h:mm
export const START_TIME_OF_DATA_CONSOLIDATION = '1:00:00'; // In 24h format, in the format h:mm:ss
export const END_TIME_OF_DATA_CONSOLIDATION = '2:30:00'; // In 24h format, in the format h:mm:ss

0 comments on commit 37cbd13

Please sign in to comment.