Skip to content
Snippets Groups Projects
Verified Commit e088498b authored by Birk Gustav Samson Stoveland's avatar Birk Gustav Samson Stoveland :speech_balloon:
Browse files

fix: remove type assertions, add stylesheet

parent 816fccd7
Branches
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Commit } from '../../helpers/types'; import { Commit } from '../../helpers/types';
import { Switch } from '@material-ui/core/'; import { Switch } from '@material-ui/core/';
import useStyles from './styles';
export default function CommitsPerBranchPage() { export default function CommitsPerBranchPage() {
const [data, setData] = useState<Array<{ barLabel: string; barValue: number }> | null>(null); const [data, setData] = useState<Array<{ barLabel: string; barValue: number }> | null>(null);
...@@ -15,6 +16,7 @@ export default function CommitsPerBranchPage() { ...@@ -15,6 +16,7 @@ export default function CommitsPerBranchPage() {
); );
const commitsByBranch: Array<{ barLabel: string; barValue: number }> = []; const commitsByBranch: Array<{ barLabel: string; barValue: number }> = [];
const [activeBranch, setActiveBranch] = useState<Map<string, boolean> | null>(null); const [activeBranch, setActiveBranch] = useState<Map<string, boolean> | null>(null);
const classes = useStyles();
useEffect(() => { useEffect(() => {
getAllMergeRequestsFromAPI().then((res) => { getAllMergeRequestsFromAPI().then((res) => {
if (res) { if (res) {
...@@ -22,15 +24,15 @@ export default function CommitsPerBranchPage() { ...@@ -22,15 +24,15 @@ export default function CommitsPerBranchPage() {
if (res2) { if (res2) {
const activeBranches = new Map<string, boolean>(); const activeBranches = new Map<string, boolean>();
res2.forEach((value: Array<Commit>, key: number) => { res2.forEach((value: Array<Commit>, key: number) => {
activeBranches.set(String(key) as string, true); activeBranches.set(String(key), true);
if ( if (
!commitsByBranch.includes({ !commitsByBranch.includes({
barLabel: String(key) as string, barLabel: String(key),
barValue: value.length, barValue: value.length,
}) })
) { ) {
commitsByBranch.push({ commitsByBranch.push({
barLabel: String(key) as string, barLabel: String(key),
barValue: value.length, barValue: value.length,
}); });
} }
...@@ -48,7 +50,7 @@ export default function CommitsPerBranchPage() { ...@@ -48,7 +50,7 @@ export default function CommitsPerBranchPage() {
<PageContainer> <PageContainer>
<header /> <header />
{data && <ChartBar data={data} title={'Commits by merge request iid'} />} {data && <ChartBar data={data} title={'Commits by merge request iid'} />}
<div> <div className={classes.switchcontainer}>
{trueData && {trueData &&
activeBranch && activeBranch &&
trueData.map((m, i) => { trueData.map((m, i) => {
...@@ -56,6 +58,7 @@ export default function CommitsPerBranchPage() { ...@@ -56,6 +58,7 @@ export default function CommitsPerBranchPage() {
return ( return (
<div key={i}> <div key={i}>
<Switch <Switch
className={classes.switch}
checked={activeBranch.get(m.barLabel)} checked={activeBranch.get(m.barLabel)}
onChange={() => { onChange={() => {
activeBranch.set(m.barLabel, !activeBranch.get(m.barLabel)); activeBranch.set(m.barLabel, !activeBranch.get(m.barLabel));
......
import { createStyles, makeStyles, Theme } from '@material-ui/core';
const useStyles = makeStyles((theme: Theme) =>
createStyles({
switch: {
display: 'flex',
color: theme.palette.primary.contrastText + '!important',
},
switchcontainer: {
display: 'grid',
width: '100%',
gridTemplateColumns: '1fr 1fr 1fr 1fr',
},
}),
);
export default useStyles;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment