1- import React , { useState } from 'react' ;
1+ import React , { useState } from 'react' ;
22import { Modal , Button } from 'react-bootstrap' ;
33import { Container , Row , Col , Modal as NestedModal , ModalBody , ModalFooter } from 'reactstrap' ;
44import { useDispatch , useSelector } from 'react-redux' ;
@@ -91,7 +91,7 @@ const ScheduleReasonModal = ({
9191
9292 const handleAddRequestDataChange = e => {
9393 e . preventDefault ( ) ;
94- const { name , value} = e . target
94+ const { name, value } = e . target ;
9595 if ( name === 'numberOfWeeks' ) {
9696 if ( checkIfUserIsAllowedToscheduleForTheDuration ( value ) ) return ;
9797 }
@@ -109,8 +109,6 @@ const ScheduleReasonModal = ({
109109 return moment ( `${ month } -${ day } -${ year } ` , 'MM-DD-YYYY' ) . format ( 'YYYY-MM-DD' ) ;
110110 } ;
111111
112-
113-
114112 // checks if date value is not empty
115113 const validateDateOfLeave = data => {
116114 if ( ! data . dateOfLeave ) {
@@ -154,9 +152,9 @@ const ScheduleReasonModal = ({
154152
155153 if (
156154 ( requestStartingDate . isSameOrAfter ( dataStartingDate ) &&
157- requestStartingDate . isSameOrBefore ( dataEndingDate ) ) ||
155+ requestStartingDate . isSameOrBefore ( dataEndingDate ) ) ||
158156 ( requestEndingDate . isSameOrAfter ( dataStartingDate ) &&
159- requestEndingDate . isSameOrBefore ( dataEndingDate ) )
157+ requestEndingDate . isSameOrBefore ( dataEndingDate ) )
160158 ) {
161159 return true ;
162160 }
@@ -272,7 +270,6 @@ const ScheduleReasonModal = ({
272270 toggleConfirmationModal ( ) ;
273271 } ;
274272
275-
276273 const handleDeleteRequest = id => {
277274 toggleDeleteConfirmationModal ( ) ;
278275 setRequestTodelete ( id ) ;
@@ -290,7 +287,6 @@ const ScheduleReasonModal = ({
290287 return momentA - momentB ;
291288 } ;
292289
293-
294290 const durationExplanationText = data => {
295291 const { numberOfScheduledReasons, blueSquares, durationOfScheduledReasons } = data ;
296292
@@ -334,7 +330,7 @@ const ScheduleReasonModal = ({
334330 < Modal . Body className = { darkMode ? 'bg-yinmn-blue' : '' } >
335331 < Form . Group className = "mb-0" controlId = "exampleForm.ControlTextarea1" >
336332 < Form . Label className = { `mb-3 ${ darkMode ? 'text-light' : '' } ` } >
337- { ` Need to take time off for an emergency or vacation? That's no problem. The system
333+ { ` Need to take time off for an emergency or vacation? That's no problem. The system
338334 will still issue you a blue square but scheduling here will note this reason on it
339335 so it's clear you chose to use one (vs receiving one for missing something) and
340336 let us know in advance. Blue squares are meant for situations like this and we allow the use and scheduling of 4 a year.` }
@@ -361,13 +357,22 @@ const ScheduleReasonModal = ({
361357 < Form . Text className = "text-danger pl-1" >
362358 { requestDataErrors . dateOfLeaveError }
363359 </ Form . Text >
364- < Form . Label className = { darkMode ? 'text-light' : '' } > Enter the duration of your absence (In Weeks):</ Form . Label >
360+ < Form . Label className = { darkMode ? 'text-light' : '' } >
361+ Enter the duration of your absence (In Weeks):
362+ </ Form . Label >
365363 < Form . Control
366364 type = "number"
367365 placeholder = "Enter duration in weeks"
368366 name = "numberOfWeeks"
369367 value = { requestData . numberOfWeeks }
370- onChange = { e => handleAddRequestDataChange ( e ) }
368+ min = "0"
369+ step = "1"
370+ onChange = { e => {
371+ const value = e . target . value ;
372+ if ( value === '' || / ^ [ 0 - 9 ] + $ / . test ( value ) ) {
373+ handleAddRequestDataChange ( e ) ;
374+ }
375+ } }
371376 />
372377 < Form . Text className = "text-danger pl-1" >
373378 { requestDataErrors . numberOfWeeksError }
@@ -391,7 +396,11 @@ const ScheduleReasonModal = ({
391396 </ Form . Group >
392397 </ Modal . Body >
393398 < Modal . Footer className = { darkMode ? 'bg-yinmn-blue' : '' } >
394- < Button variant = "secondary" onClick = { handleClose } style = { darkMode ? boxStyleDark : boxStyle } >
399+ < Button
400+ variant = "secondary"
401+ onClick = { handleClose }
402+ style = { darkMode ? boxStyleDark : boxStyle }
403+ >
395404 Close
396405 </ Button >
397406 < Button
@@ -403,7 +412,11 @@ const ScheduleReasonModal = ({
403412 >
404413 Save
405414 </ Button >
406- < NestedModal isOpen = { confirmationModal } toggle = { toggleConfirmationModal } className = { darkMode ? 'text-light dark-mode' : '' } >
415+ < NestedModal
416+ isOpen = { confirmationModal }
417+ toggle = { toggleConfirmationModal }
418+ className = { darkMode ? 'text-light dark-mode' : '' }
419+ >
407420 < ModalBody className = { darkMode ? 'bg-yinmn-blue' : '' } >
408421 < Container >
409422 < Row >
@@ -463,7 +476,11 @@ const ScheduleReasonModal = ({
463476 </ Button >
464477 </ ModalFooter >
465478 </ NestedModal >
466- < NestedModal isOpen = { allowedDurationModal } toggle = { toggleDurationInfoModal } className = { darkMode ? 'text-light dark-mode' : '' } >
479+ < NestedModal
480+ isOpen = { allowedDurationModal }
481+ toggle = { toggleDurationInfoModal }
482+ className = { darkMode ? 'text-light dark-mode' : '' }
483+ >
467484 < ModalBody className = { darkMode ? 'bg-yinmn-blue' : '' } >
468485 < Container >
469486 < Row > { durationExplanationText ( allowedDurationData ) } </ Row >
0 commit comments