File tree Expand file tree Collapse file tree 4 files changed +14
-12
lines changed
course-updates/update-form
generic/datepicker-control Expand file tree Collapse file tree 4 files changed +14
-12
lines changed Original file line number Diff line number Diff line change 77 Icon ,
88} from '@openedx/paragon' ;
99import classNames from 'classnames' ;
10- import DatePicker from 'react-datepicker/dist ' ;
10+ import DatePicker from 'react-datepicker' ;
1111import { useIntl } from '@edx/frontend-platform/i18n' ;
1212import { Calendar as CalendarIcon , Error as ErrorIcon } from '@openedx/paragon/icons' ;
1313import { Formik } from 'formik' ;
@@ -73,7 +73,7 @@ const UpdateForm = ({
7373 < DatePicker
7474 name = "date"
7575 data-testid = "course-updates-datepicker"
76- selected = { isValidDate ( values . date ) ? convertToDateFromString ( values . date ) : '' }
76+ selected = { isValidDate ( values . date ) ? convertToDateFromString ( values . date ) : undefined }
7777 dateFormat = { DATE_FORMAT }
7878 className = { classNames ( 'datepicker-custom-control' , {
7979 'datepicker-custom-control_isInvalid' : ! isValid ,
Original file line number Diff line number Diff line change 11import React from 'react' ;
2- import DatePicker from 'react-datepicker/dist ' ;
2+ import DatePicker from 'react-datepicker' ;
33import PropTypes from 'prop-types' ;
44import classNames from 'classnames' ;
55import { Form , Icon } from '@openedx/paragon' ;
Original file line number Diff line number Diff line change @@ -124,10 +124,10 @@ describe('FilesAndUploads utils', () => {
124124 expect ( date . toISOString ( ) ) . toBe ( '2023-10-01T12:00:00.000Z' ) ;
125125 } ) ;
126126
127- it ( 'returns an empty string for invalid date strings' , ( ) => {
127+ it ( 'returns undefined for invalid date strings' , ( ) => {
128128 const dateStr = '' ;
129129 const date = convertToDateFromString ( dateStr ) ;
130- expect ( date ) . toBe ( '' ) ;
130+ expect ( date ) . toBeUndefined ( ) ;
131131 } ) ;
132132 } ) ;
133133
Original file line number Diff line number Diff line change @@ -265,28 +265,30 @@ export function setupYupExtensions() {
265265 } ) ;
266266}
267267
268- export const convertToDateFromString = ( dateStr : string ) => {
268+ export const convertToDateFromString = ( dateStr : string ) : Date | undefined => {
269269 /**
270270 * Convert UTC to local time for react-datepicker
271- * Note: react-datepicker has a bug where it only interacts with local time
271+ * Note: react-datepicker v4 had a bug where it only interacts with local time
272+ * but this bug may no longer be affecting v8+ ?
272273 * @param {string } dateStr - YYYY-MM-DDTHH:MM:SSZ
273- * @return { Date } date in local time
274+ * @return date in local time
274275 */
275276 if ( ! dateStr ) {
276- return '' ;
277+ return undefined ;
277278 }
278279
279280 const stripTimeZone = ( stringValue : string ) => stringValue . substring ( 0 , 19 ) ;
280281
281282 return moment ( stripTimeZone ( String ( dateStr ) ) ) . toDate ( ) ;
282283} ;
283284
284- export const convertToStringFromDate = ( date : moment . MomentInput ) => {
285+ export const convertToStringFromDate = ( date : moment . MomentInput ) : string => {
285286 /**
286287 * Convert local time to UTC from react-datepicker
287- * Note: react-datepicker has a bug where it only interacts with local time
288+ * Note: react-datepicker v4 had a bug where it only interacts with local time
289+ * but this bug may no longer be affecting v8+ ?
288290 * @param {Date } date - date in local time
289- * @return { string } YYYY-MM-DDTHH:MM:SSZ
291+ * @return YYYY-MM-DDTHH:MM:SSZ
290292 */
291293 if ( ! date ) {
292294 return '' ;
You can’t perform that action at this time.
0 commit comments