11import React , { useCallback , useState } from 'react' ;
2- import { Form , Modal , Select , Space , TimePicker } from 'antd' ;
2+ import {
3+ Checkbox ,
4+ Divider ,
5+ Form ,
6+ Modal ,
7+ Select ,
8+ Space ,
9+ TimePicker ,
10+ } from 'antd' ;
11+ import { CheckboxChangeEvent } from 'antd/lib/checkbox' ;
312import { observer } from 'mobx-react' ;
413// eslint-disable-next-line import/named
514import moment , { Moment } from 'moment' ;
@@ -24,6 +33,9 @@ const SettingsModal: React.VFC<ISettingsModalProps> = observer(
2433 const [ showNewProfilePopover , setShowNewProfilePopover ] = useState < boolean > (
2534 false
2635 ) ;
36+ const [ showNotifications , setShowNotifications ] = useState < boolean > (
37+ settings . showNotifications
38+ ) ;
2739 const [ profile , setProfile ] = useState < string > ( settings . currentProfile ) ;
2840 const [ workingHours , setWorkingHours ] = useState < Moment | null > (
2941 moment ( settings . numberOfWorkingHours ) . utcOffset ( 0 )
@@ -35,9 +47,10 @@ const SettingsModal: React.VFC<ISettingsModalProps> = observer(
3547 numberOfWorkingHours : workingHours
3648 ? timeToMs ( workingHours ?. toDate ( ) )
3749 : DEFAULT_SETTINGS . numberOfWorkingHours ,
50+ showNotifications,
3851 } ) ;
3952 onClose ( ) ;
40- } , [ profile , workingHours , onClose ] ) ;
53+ } , [ profile , workingHours , showNotifications , onClose ] ) ;
4154
4255 const handleChangeProfile = useCallback ( ( selected : string ) => {
4356 setProfile ( selected ) ;
@@ -53,6 +66,10 @@ const SettingsModal: React.VFC<ISettingsModalProps> = observer(
5366 [ ]
5467 ) ;
5568
69+ const handleChangeNotifications = useCallback ( ( e : CheckboxChangeEvent ) => {
70+ setShowNotifications ( e . target . checked ) ;
71+ } , [ ] ) ;
72+
5673 return (
5774 < Modal
5875 title = "Settings"
@@ -81,7 +98,8 @@ const SettingsModal: React.VFC<ISettingsModalProps> = observer(
8198 />
8299 </ Space >
83100 </ Form . Item >
84- < Form . Item label = "Number of working hours" >
101+ < Divider />
102+ < Form . Item label = "Number of working hours" labelCol = { { span : 10 } } >
85103 < TimePicker
86104 value = { workingHours }
87105 onChange = { ( value ) => setWorkingHours ( value ) }
@@ -91,6 +109,12 @@ const SettingsModal: React.VFC<ISettingsModalProps> = observer(
91109 allowClear = { false }
92110 />
93111 </ Form . Item >
112+ < Form . Item label = "Notifications" labelCol = { { span : 10 } } >
113+ < Checkbox
114+ checked = { showNotifications }
115+ onChange = { handleChangeNotifications }
116+ />
117+ </ Form . Item >
94118 </ Modal >
95119 ) ;
96120 }
0 commit comments