From c984f4c6aecdb6f9991c23261e9ce701a996997e Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Wed, 2 Sep 2020 16:49:14 -0700 Subject: [PATCH] Track query times. Updated refresh button. --- components/common/RefreshButton.js | 14 +++++++++++--- hooks/useFetch.js | 7 +++++++ redux/actions/queries.js | 17 +++++++++++++++++ redux/actions/websites.js | 26 +++++++++++--------------- redux/reducers.js | 3 ++- 5 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 redux/actions/queries.js diff --git a/components/common/RefreshButton.js b/components/common/RefreshButton.js index ce4c4f19..2d948cde 100644 --- a/components/common/RefreshButton.js +++ b/components/common/RefreshButton.js @@ -1,19 +1,27 @@ -import React from 'react'; -import { useDispatch } from 'react-redux'; +import React, { useState, useEffect } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; import { setDateRange } from 'redux/actions/websites'; import Button from './Button'; import Refresh from 'assets/redo.svg'; +import Dots from 'assets/ellipsis-h.svg'; import { useDateRange } from 'hooks/useDateRange'; export default function RefreshButton({ websiteId }) { const dispatch = useDispatch(); const dateRange = useDateRange(websiteId); + const [loading, setLoading] = useState(false); + const completed = useSelector(state => state.queries[`/api/website/${websiteId}/metrics`]); function handleClick() { if (dateRange) { + setLoading(true); dispatch(setDateRange(websiteId, dateRange)); } } - return