Skip to content

Commit

Permalink
Use Farmer Statistics Handler
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexEntrepreneur committed Sep 17, 2019
1 parent cc5ab2d commit 4f118e3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/pages/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React, { useEffect } from 'react';
import { Dimmer, Loader, Segment, Header, Button } from 'semantic-ui-react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { toast } from 'react-toastify';

import DashboardHeader from './DashboardHeader';
import tableColumLabels from './tableColumLabels';
import DashboardTable from '../../common/Table/Table';
import LoadingIndicator from './LoadingIndicator';
import withRestrictedAccess from '../../hoc/withRestrictedAccess';
import FarmersStatistic from '../../partials/FarmersStatistic';
import axiosWithHeader from '../../../utils/axiosWithHeaders';
import { pathObj } from '../../../utils/generalVariables';
import { getfarmerStatisticsHandler } from '../../../utils/handlers/farmerHandlers';

const Dashboard = ({ farmers, history }) => {
const [data, setData] = React.useState([]);
Expand All @@ -29,10 +29,11 @@ const Dashboard = ({ farmers, history }) => {
}, [farmers]);

useEffect(() => {
axiosWithHeader()
.get(pathObj.getFarmersStatistic)
.then(res => setFarmersStatistic(() => res.data))
.catch(error => error.response);
getfarmerStatisticsHandler()
.then(res => setFarmersStatistic(res))
.catch(error => {
toast.error(error.message);
});
}, []);

const renderFarmersStatistic = () => {
Expand Down

0 comments on commit 4f118e3

Please sign in to comment.