Commit 45b3bbcb authored by Zhou Fang's avatar Zhou Fang
Browse files

Fixed months issue for committers chart

parent b515f433
......@@ -72,6 +72,7 @@ const App = () => {
const [yourWGData, setYourWGData] = useState(null);
const [allYourWGData, setAllYourWGData] = useState(null);
const [interestedWGData, setInterestedWGData] = useState(null);
const [chartMonths, setChartMonths] = useState([]);
const failedToExecute = (msg) => {
setShouldShowMsg(true);
......@@ -145,6 +146,8 @@ const App = () => {
setAllYourWGData,
interestedWGData,
setInterestedWGData,
chartMonths,
setChartMonths,
};
useEffect(() => {
......
......@@ -50,6 +50,8 @@ interface PortalContextType {
setAllYourWGData: (allYourWGData: Array<ProjectsAndWGItem>) => void;
interestedWGData: Array<ProjectsAndWGItem> | null;
setInterestedWGData: (interestedWGData: Array<ProjectsAndWGItem>) => void;
chartMonths: Array<string>;
setChartMonths: (monthData: Array<string>) => void;
}
const PortalContext = React.createContext<PortalContextType>({
......@@ -91,6 +93,8 @@ const PortalContext = React.createContext<PortalContextType>({
setAllYourWGData: (allYourWGData: Array<ProjectsAndWGItem>) => {},
interestedWGData: null,
setInterestedWGData: (interestedWGData: Array<ProjectsAndWGItem>) => {},
chartMonths: [],
setChartMonths: (monthData: Array<string>) => {},
});
export default PortalContext;
......@@ -9,7 +9,7 @@ import {
MODE_REACT_ONLY,
} from '../../../../Constants/Constants';
import { Bar } from 'react-chartjs-2';
import { memo, useState, useEffect, useContext } from 'react';
import { memo, useEffect, useContext } from 'react';
import PortalContext from '../../../../Context/PortalContext';
import { fetchWrapper } from '../../../../Utils/formFunctionHelpers';
......@@ -33,8 +33,8 @@ const useStyles = makeStyles(() =>
function DashboardCommittersAndContributorsChart() {
const classes = useStyles();
const [chartMonths, setChartMonths] = useState<Array<string>>([]);
const { orgId, chartCommits, setChartCommits, chartCommitters, setChartCommitters } = useContext(PortalContext);
const { orgId, chartCommits, setChartCommits, chartCommitters, setChartCommitters, chartMonths, setChartMonths } =
useContext(PortalContext);
const DATA_FOR_BAR_LINE_CHART = {
labels: chartMonths,
......@@ -89,7 +89,7 @@ function DashboardCommittersAndContributorsChart() {
setChartMonths(monthArray);
};
fetchWrapper(urlForChartCommits, FETCH_METHOD.GET, saveChartCommitsData);
}, [orgId, chartCommits, setChartCommits]);
}, [orgId, chartCommits, setChartCommits, setChartMonths]);
useEffect(() => {
if (!orgId || chartCommitters !== null) {
......
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