Skip to content

Commit 7a82780

Browse files
committed
Merge branch 'display' of https://github.com/oslabs-beta/ReacType into assignTab
2 parents eb11042 + 54b1e09 commit 7a82780

File tree

2 files changed

+32
-35
lines changed

2 files changed

+32
-35
lines changed
Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,47 @@
1-
import React, { useEffect } from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import { useStore } from 'react-redux';
33
import { Chart } from 'react-google-charts';
4+
import Grid from '@mui/material/Grid';
45

56
const DisplayContainer = () => {
67
const store = useStore();
8+
const { allContext } = store.getState().contextSlice;
9+
const [contextData, setContextData] = useState([]);
710

811
useEffect(() => {
9-
console.log(store.getState().contextSlice);
12+
transformData(allContext);
1013
}, []);
1114

15+
const transformData = contexts => {
16+
const formattedData = contexts
17+
.map(el => {
18+
return el.components.map(component => {
19+
return [`App ${el.name} ${component}`];
20+
});
21+
})
22+
.flat();
23+
setContextData([['Phrases'], ...formattedData]);
24+
};
1225

13-
const data = [
14-
['Phrases'],
15-
['cats are better than dogs'],
16-
['cats eat kibble'],
17-
['cats are better than hamsters'],
18-
['cats are awesome'],
19-
['cats are people too'],
20-
['cats eat mice'],
21-
['cats meowing'],
22-
['cats in the cradle'],
23-
['cats eat mice'],
24-
['cats in the cradle lyrics'],
25-
['cats eat kibble'],
26-
['cats for adoption'],
27-
['cats are family'],
28-
['cats eat mice'],
29-
['cats are better than kittens'],
30-
['cats are evil'],
31-
['cats are weird'],
32-
['cats eat mice'],
33-
];
3426
const options = {
3527
wordtree: {
3628
format: 'implicit',
37-
word: 'cats',
38-
},
29+
word: 'App'
30+
}
3931
};
32+
console.log(contextData);
4033
return (
41-
<Chart
42-
chartType='WordTree'
43-
width='100%'
44-
height='400px'
45-
data={data}
46-
options={options}
47-
/>
34+
<Grid container display="flex" justifyContent="center">
35+
<Grid item>
36+
<Chart
37+
chartType="WordTree"
38+
width="100%"
39+
height="500px"
40+
data={contextData}
41+
options={options}
42+
/>
43+
</Grid>
44+
</Grid>
4845
);
4946
};
50-
export default DisplayContainer;
47+
export default DisplayContainer;

app/src/redux/reducers/slice/contextReducer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ const initialState = {
88
{ key: 'testKey1', value: 'testValue1' },
99
{ key: 'testKey2', value: 'testValue2' }
1010
],
11-
components: []
11+
components: ['MainContainer', 'SubmitForm']
1212
},
1313
{
1414
name: 'MainContext3',
1515
values: [
1616
{ key: 'testKey3', value: 'testValue3' },
1717
{ key: 'testKey33', value: 'testValue33' }
1818
],
19-
components: []
19+
components: ['MainContainer', 'EditForm', 'TableContainer']
2020
}
2121
]
2222
};

0 commit comments

Comments
 (0)