Commit 45ee557e by OuiAtichat

update

parent ccb7132c
import React, { Component } from 'react'; import React, { Component } from 'react';
// import { db } from '../firebase';
import { Row, Container } from 'react-bootstrap'; import { Row, Container } from 'react-bootstrap';
import DataTable from '../components/DataTable'; import DataTable from '../components/DataTable';
import NavBar from '../components/NavBar'; import NavBar from '../components/NavBar';
...@@ -120,11 +119,11 @@ class Home extends Component { ...@@ -120,11 +119,11 @@ class Home extends Component {
const { uid } = this.props.fireStoreCurrentUser; const { uid } = this.props.fireStoreCurrentUser;
this.props.getAllDevicesInfo(uid); this.props.getAllDevicesInfo(uid);
}; };
looper = null;
componentDidUpdate = async (prevProps, prevState) => { componentDidUpdate = (prevProps, prevState) => {
const { device, range, breakdown } = this.props.selectedFeed; const { device, range, breakdown } = this.props.selectedFeed;
if (prevProps.selectedFeed !== this.props.selectedFeed) { if (prevProps.selectedFeed !== this.props.selectedFeed) {
console.log(this.props.selectedFeed);
this.loopFeedData(device, range, breakdown); this.loopFeedData(device, range, breakdown);
} }
}; };
...@@ -280,7 +279,7 @@ class Home extends Component { ...@@ -280,7 +279,7 @@ class Home extends Component {
axios.defaults.headers.common['Authorization'] = `Bearer ${userToken}`; axios.defaults.headers.common['Authorization'] = `Bearer ${userToken}`;
const response = await axios.post(kairosUrl, q_data); const response = await axios.post(kairosUrl, q_data);
this.setState({ await this.setState({
currentFeed: response.data.queries[0].results[0].values || [], currentFeed: response.data.queries[0].results[0].values || [],
revenueFeed: response.data.queries[1].results[0].values || [], revenueFeed: response.data.queries[1].results[0].values || [],
remoteFeed: response.data.queries[2].results[0].values || [], remoteFeed: response.data.queries[2].results[0].values || [],
......
...@@ -3,7 +3,6 @@ import { Card, Col, Row } from 'react-bootstrap'; ...@@ -3,7 +3,6 @@ import { Card, Col, Row } from 'react-bootstrap';
import { FaMoneyBillAlt, FaArrowUp, FaArrowDown, FaUserFriends } from 'react-icons/fa'; import { FaMoneyBillAlt, FaArrowUp, FaArrowDown, FaUserFriends } from 'react-icons/fa';
import { AreaChart, Area, XAxis, YAxis, ResponsiveContainer, Tooltip } from 'recharts'; import { AreaChart, Area, XAxis, YAxis, ResponsiveContainer, Tooltip } from 'recharts';
import withWindowDimensions from '../utils/withWindowDimensions'; import withWindowDimensions from '../utils/withWindowDimensions';
// import { CSVLink } from 'react-csv';
import moment from 'moment'; import moment from 'moment';
export const SmCard = props => { export const SmCard = props => {
......
...@@ -10,12 +10,12 @@ import { getSelectedFeed } from '../../redux/actions/selectedFeedAction'; ...@@ -10,12 +10,12 @@ import { getSelectedFeed } from '../../redux/actions/selectedFeedAction';
class GetDataSelection extends Component { class GetDataSelection extends Component {
state = { state = {
device: this.props.allDeviceId[0], device: this.props.allDeviceId[0],
range: { // range: {
startDate: moment() // startDate: moment()
.startOf('day') // .startOf('day')
.valueOf(), // .valueOf(),
endDate: moment().valueOf(), // endDate: moment().valueOf(),
}, // },
breakdown: 'minutes', breakdown: 'minutes',
startDate: moment().startOf('day'), startDate: moment().startOf('day'),
endDate: moment(), endDate: moment(),
...@@ -62,6 +62,14 @@ class GetDataSelection extends Component { ...@@ -62,6 +62,14 @@ class GetDataSelection extends Component {
this.submitSelectedRange(); this.submitSelectedRange();
}; };
componentDidUpdate = (prevProps, prevState) => {
if (prevProps) {
if (prevState !== this.state) {
this.submitSelectedRange();
}
}
};
render() { render() {
const { allDeviceId, allDeviceInfo } = this.props; const { allDeviceId, allDeviceInfo } = this.props;
let start = this.state.startDate.format('DD MMM YY'); let start = this.state.startDate.format('DD MMM YY');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment