Skip to content

Commit 74d11ce

Browse files
committed
Added typescript for handleEvents
1 parent 1a8ee0a commit 74d11ce

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

src/app/components/FrontendTypes.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export interface Series {
2121

2222
export interface ActionObj {
2323
name: string,
24-
seriesName: string,
24+
seriesName: string,
25+
currentTab: string,
2526
}
2627

2728
export interface PerfData {
@@ -56,7 +57,7 @@ export interface snapshot {
5657
state: string;
5758
}
5859

59-
export interface margin {
60+
export interface Margin {
6061
top: number;
6162
right: number;
6263
bottom: number;
@@ -71,9 +72,9 @@ export interface BarGraphBase {
7172
}
7273

7374
export interface BarGraphComparisonProps extends BarGraphBase {
74-
setSeries: (e: boolean) => void,
75+
setSeries: (e: boolean | string) => void,
7576
series: number,
76-
setAction: (e: boolean) => void,
77+
setAction: (e: boolean | string) => void,
7778
}
7879

7980
export interface BarGraphProps extends BarGraphBase{

src/app/components/StateRoute/PerformanceVisx/BarGraph.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { schemeSet3 } from 'd3-scale-chromatic';
1111
import { onHover, onHoverExit, save } from '../../../actions/actions';
1212
import { useStoreContext } from '../../../store';
1313
import {
14-
snapshot, TooltipData, margin, BarGraphProps,
14+
snapshot, TooltipData, Margin, BarGraphProps,
1515
} from '../../FrontendTypes';
1616

1717
/* DEFAULTS */

src/app/components/StateRoute/PerformanceVisx/BarGraphComparison.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import {
1818
} from '../../../actions/actions';
1919
import { useStoreContext } from '../../../store';
2020
import {
21-
snapshot, TooltipData, margin, BarGraphComparisonProps, ActionObj, Series,
21+
snapshot, TooltipData, Margin, BarGraphComparisonProps, ActionObj, Series,
2222
} from '../../FrontendTypes';
2323
import { BarStack } from '@visx/shape/lib/types';
2424

2525
/* DEFAULTS */
26-
const margin: margin = {
26+
const margin: Margin = {
2727
top: 30, right: 30, bottom: 0, left: 50,
2828
};
2929
const axisColor = '#62d6fb';
@@ -139,8 +139,11 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
139139

140140
const handleSeriesChange = (event: Event) => {
141141
if (!event) return;
142-
setSeries(event.target.value);
143-
setAction(false);
142+
const target = event.target as HTMLInputElement;
143+
if (target) {
144+
setSeries(target.value);
145+
setAction(false);
146+
}
144147
};
145148

146149
const handleClose = () => {
@@ -152,9 +155,12 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
152155
};
153156

154157
const handleActionChange = (event: Event) => {
155-
if (!event.target.value) return;
156-
setAction(event.target.value);
157-
setSeries(false);
158+
const target = event.target as HTMLInputElement;
159+
if (!target.value) return;
160+
if (target) {
161+
setAction(target.value);
162+
setSeries(false);
163+
}
158164
};
159165

160166
const picHandleClose = () => {
@@ -178,7 +184,7 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
178184
});
179185
return data.barStack;
180186
}
181-
187+
182188
const animateButton = (e: MouseEvent) => {
183189
e.preventDefault();
184190
const target = event.target as HTMLButtonElement;

src/app/components/StateRoute/PerformanceVisx/BarGraphComparisonActions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import MenuItem from '@material-ui/core/MenuItem';
1414
import FormControl from '@material-ui/core/FormControl';
1515
import { deleteSeries, setCurrentTabInApp } from '../../../actions/actions';
1616
import { useStoreContext } from '../../../store';
17-
import { TooltipData, margin } from '../../FrontendTypes';
17+
import { TooltipData, Margin } from '../../FrontendTypes';
1818

1919
/* DEFAULTS */
20-
const margin = {
20+
const margin: Margin = {
2121
top: 30, right: 30, bottom: 0, left: 50,
2222
};
2323
const axisColor = '#62d6fb';

0 commit comments

Comments
 (0)