1- import React , { FC , memo , useMemo } from 'react' ;
2- import { Chart } from 'react-google-charts' ;
3- import { createUseStyles } from 'react-jss' ;
1+ import React , { FC , memo , useMemo } from 'react' ;
2+ import { Chart } from 'react-google-charts' ;
3+ import { createUseStyles } from 'react-jss' ;
44
55import rootStore from '../../modules/RootStore' ;
6- import { getTimeItems } from '../../helpers/TaskHelper' ;
6+ import { getTimeItems } from '../../helpers/TaskHelper' ;
77
8- const { tasksStore } = rootStore ;
8+ const { tasksStore} = rootStore ;
99
1010const columns = [
11- { type : 'string' , id : 'Task' } ,
12- { type : 'date' , id : 'Start' } ,
13- { type : 'date' , id : 'End' } ,
11+ { type : 'string' , id : 'Task' } ,
12+ { type : 'date' , id : 'Start' } ,
13+ { type : 'date' , id : 'End' } ,
1414] ;
1515
1616const nowDate = new Date ( ) ;
1717
1818const Timeline : FC = ( ) => {
1919 const classes = useStyles ( ) ;
2020
21- const tasks = useMemo ( ( ) => tasksStore . getTasksByDate ( nowDate ) , [ ] ) ;
22- const filteredTimeItems = useMemo ( ( ) => getTimeItems ( tasks , nowDate ) , [
23- tasks ,
24- ] ) ;
25-
2621 const data = useMemo ( ( ) => {
27- const items = filteredTimeItems . map ( ( { task, time } ) => [
28- task . title ,
29- time . start ,
22+ const tasks = tasksStore . getTasksByDate ( nowDate ) ;
23+ const filteredTimeItems = getTimeItems ( tasks , nowDate ) ;
24+ const items = filteredTimeItems . map ( ( { task, time} ) => [
25+ task . title || '-' ,
26+ time . start || new Date ( ) ,
3027 time . end || new Date ( ) ,
3128 ] ) ;
3229 return [ columns , ...items ] ;
33- } , [ filteredTimeItems ] ) ;
30+ } , [ ] ) ;
3431
3532 return (
3633 < div className = { classes . main } >
37- < Chart chartType = "Timeline" data = { data } height = " 100%" /> ;
34+ < Chart style = { { flex : 1 } } chartType = "Timeline" data = { data } height = ' 100%' />
3835 </ div >
3936 ) ;
4037} ;
@@ -44,5 +41,7 @@ export default memo(Timeline);
4441const useStyles = createUseStyles ( {
4542 main : {
4643 padding : 10 ,
44+ display : 'flex' ,
45+ height : '100%' ,
4746 } ,
4847} ) ;
0 commit comments