@@ -26,7 +26,7 @@ interface IDateFieldsState {
2626const TaskPublicationAndDeadlineDates : React . FC < IDateFieldsProps > = ( props ) => {
2727 const { homework} = props
2828 const homeworkPublicationDate = new Date ( homework . publicationDate ! )
29- const homeworkDeadlineDate = homework . deadlineDate === undefined ? undefined : new Date ( homework . deadlineDate )
29+ const homeworkDeadlineDate = homework . deadlineDate == null ? undefined : new Date ( homework . deadlineDate )
3030
3131 const [ state , setState ] = useState < IDateFieldsState > ( {
3232 hasDeadline : props . hasDeadline ,
@@ -36,10 +36,10 @@ const TaskPublicationAndDeadlineDates: React.FC<IDateFieldsProps> = (props) => {
3636 } ) ;
3737
3838 const [ showDates , setShowDates ] = useState < boolean > (
39- props . deadlineDate !== undefined
40- || props . hasDeadline !== undefined
41- || props . isDeadlineStrict !== undefined
42- || props . publicationDate !== undefined )
39+ props . deadlineDate != null
40+ || props . hasDeadline != null
41+ || props . isDeadlineStrict != null
42+ || props . publicationDate != null )
4343
4444 const { publicationDate, isDeadlineStrict, deadlineDate, hasDeadline} = state
4545
@@ -48,15 +48,16 @@ const TaskPublicationAndDeadlineDates: React.FC<IDateFieldsProps> = (props) => {
4848
4949 const isDeadlineSoonerThanPublication = ( taskPublicationDate : Date | undefined , taskDeadlineDate : Date | undefined ) =>
5050 {
51- if ( ( taskDeadlineDate || homeworkDeadlineDate ) === undefined ) return false
51+ const deadlineDate = taskDeadlineDate || homeworkDeadlineDate
52+ if ( deadlineDate == null ) return false
5253
53- return ( taskDeadlineDate || homeworkDeadlineDate ) ! < ( taskPublicationDate || homeworkPublicationDate )
54+ return deadlineDate < ( taskPublicationDate || homeworkPublicationDate )
5455 }
5556
5657 const taskSoonerThanHomework = ! ! state . publicationDate && isTaskSoonerThanHomework ( state . publicationDate )
5758 const deadlineSoonerThanPublication = ( ! ! state . deadlineDate || ! ! homeworkDeadlineDate ) && isDeadlineSoonerThanPublication ( state . publicationDate , state . deadlineDate )
5859
59- const showDeadlineEdit = hasDeadline === undefined ? homework . hasDeadline : hasDeadline
60+ const showDeadlineEdit = hasDeadline == null ? homework . hasDeadline : hasDeadline
6061
6162 useEffect ( ( ) => {
6263 const validationResult =
@@ -143,13 +144,13 @@ const TaskPublicationAndDeadlineDates: React.FC<IDateFieldsProps> = (props) => {
143144 ...prevState ,
144145 deadlineDate : undefined ,
145146 isDeadlineStrict : undefined ,
146- hasDeadline : hasDeadline === undefined ? ! homework . hasDeadline : undefined ,
147+ hasDeadline : hasDeadline == null ? ! homework . hasDeadline : undefined ,
147148 } ) )
148149 } }
149150 /> }
150151 />
151152 < FormHelperText style = { { marginTop : '-1px' } } >
152- { hasDeadline !== undefined
153+ { hasDeadline != null
153154 ? hasDeadline
154155 ? 'Было без дедлайна'
155156 : 'Был c дедлайном'
@@ -174,7 +175,7 @@ const TaskPublicationAndDeadlineDates: React.FC<IDateFieldsProps> = (props) => {
174175 variant = "standard"
175176 error = { deadlineSoonerThanPublication }
176177 helperText = { deadlineSoonerThanPublication ? `Дедлайн задачи раньше ее публикации: ${ Utils . renderDateWithoutSeconds ( state . publicationDate ! ) } ` :
177- deadlineDate !== undefined
178+ deadlineDate != null
178179 ? props . homework . hasDeadline
179180 ? `Было ${ Utils . renderDateWithoutSeconds ( props . homework . deadlineDate ! ) } `
180181 : `Было без дедлайна`
@@ -200,7 +201,7 @@ const TaskPublicationAndDeadlineDates: React.FC<IDateFieldsProps> = (props) => {
200201 < FormControlLabel
201202 label = "Строгий"
202203 control = { < Checkbox
203- checked = { isDeadlineStrict === undefined ? homework . isDeadlineStrict : isDeadlineStrict }
204+ checked = { isDeadlineStrict == null ? homework . isDeadlineStrict : isDeadlineStrict }
204205 onChange = { ( _ ) => {
205206 setState ( prevState => ( {
206207 ...prevState ,
@@ -210,7 +211,7 @@ const TaskPublicationAndDeadlineDates: React.FC<IDateFieldsProps> = (props) => {
210211 /> }
211212 />
212213 < FormHelperText style = { { marginTop : '-1px' } } >
213- { isDeadlineStrict !== undefined
214+ { isDeadlineStrict != null
214215 ? isDeadlineStrict
215216 ? 'Был нестрогий'
216217 : 'Был строгий'
0 commit comments