@@ -97,11 +97,7 @@ export default class Education extends ConsentComponent {
97
97
invalid = true ;
98
98
}
99
99
100
- if ( _ . isEmpty ( newEducation . timePeriodFrom ) && ! _ . isEmpty ( newEducation . timePeriodTo ) ) {
101
- // If enter End Date, the other becomes mandatory.
102
- // Not as per requirement, both are optional
103
- invalid = true ;
104
- } else if ( ! _ . isEmpty ( newEducation . timePeriodFrom ) && _ . isEmpty ( newEducation . timePeriodTo ) ) {
100
+ if ( ! _ . isEmpty ( newEducation . timePeriodFrom ) && _ . isEmpty ( newEducation . timePeriodTo ) ) {
105
101
const fromDate = new Date ( newEducation . timePeriodFrom ) . setHours ( 0 , 0 , 0 , 0 ) ;
106
102
107
103
if ( fromDate > currentDate ) {
@@ -111,19 +107,12 @@ export default class Education extends ConsentComponent {
111
107
const fromDate = new Date ( newEducation . timePeriodFrom ) . setHours ( 0 , 0 , 0 , 0 ) ;
112
108
const toDate = new Date ( newEducation . timePeriodTo ) . setHours ( 0 , 0 , 0 , 0 ) ;
113
109
114
- if ( fromDate > currentDate ) {
115
- invalid = true ; // Start Date should be in past or current
116
- }
110
+ if ( fromDate > currentDate // Start Date is in past or current
111
+ || fromDate >= toDate // Start Date is before End Date
112
+ || ( newEducation . graduated && toDate > currentDate ) ) { // End Date is in past or current
117
113
118
- if ( fromDate >= toDate ) { // Start Date should be before End Date
119
114
invalid = true ;
120
115
}
121
-
122
- if ( newEducation . graduated ) {
123
- if ( toDate > currentDate ) {
124
- invalid = true ; // End Date should be in past or current
125
- }
126
- }
127
116
}
128
117
129
118
this . setState ( { formInvalid : invalid } ) ;
@@ -138,13 +127,7 @@ export default class Education extends ConsentComponent {
138
127
message : '' ,
139
128
} ;
140
129
141
-
142
- if ( _ . isEmpty ( newEducation . timePeriodFrom ) && ! _ . isEmpty ( newEducation . timePeriodTo ) ) {
143
- // If enter End Date, the other becomes mandatory.
144
- // Not as per requirement, both are optional
145
- result . invalid = true ;
146
- result . message = 'Start Date cannot be empty' ;
147
- } else if ( ! _ . isEmpty ( newEducation . timePeriodFrom ) && _ . isEmpty ( newEducation . timePeriodTo ) ) {
130
+ if ( ! _ . isEmpty ( newEducation . timePeriodFrom ) && _ . isEmpty ( newEducation . timePeriodTo ) ) {
148
131
const fromDate = new Date ( newEducation . timePeriodFrom ) . setHours ( 0 , 0 , 0 , 0 ) ;
149
132
150
133
if ( fromDate > currentDate ) {
@@ -343,6 +326,13 @@ export default class Education extends ConsentComponent {
343
326
newEducation [ e . target . name ] = e . target . value ;
344
327
} else {
345
328
newEducation [ e . target . name ] = e . target . checked ;
329
+ if ( e . target . checked ) { // if gradated and toDate is in Future, nullify it
330
+ const toDate = new Date ( newEducation . timePeriodTo ) . setHours ( 0 , 0 , 0 , 0 ) ;
331
+ const currentDate = new Date ( ) . setHours ( 0 , 0 , 0 , 0 ) ;
332
+ if ( toDate > currentDate ) {
333
+ newEducation . timePeriodTo = ''
334
+ }
335
+ }
346
336
}
347
337
348
338
this . setState ( { newEducation, inputChanged : true } ) ;
@@ -511,11 +501,6 @@ export default class Education extends ConsentComponent {
511
501
</ label >
512
502
</ div >
513
503
< div styleName = "field col-2" >
514
- {
515
- ! _ . isEmpty ( newEducation . timePeriodTo ) && (
516
- < span styleName = "text-required" > * Required</ span >
517
- )
518
- }
519
504
< DatePicker
520
505
readOnly
521
506
numberOfMonths = { 1 }
0 commit comments