Skip to content

Commit

Permalink
fix(monitor-ui): datepicker to handle string date (#269)
Browse files Browse the repository at this point in the history
fixes #268
  • Loading branch information
thoomasbro authored Jan 20, 2023
2 parents 414d88c + 979f936 commit efb3997
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
14 changes: 7 additions & 7 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@dnd-kit/core": "^4.0.3",
"@dnd-kit/modifiers": "^4.0.0",
"@mtes-mct/monitor-ui": "2.8.0",
"@mtes-mct/monitor-ui": "2.8.1",
"@reduxjs/toolkit": "1.8.2",
"@sentry/react": "6.19.7",
"@sentry/tracing": "6.19.7",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/jsx-props-no-spreading */
import { DatePicker } from '@mtes-mct/monitor-ui'
import { useField } from 'formik'
import { MutableRefObject, useRef } from 'react'
import { MutableRefObject, useEffect, useReducer, useRef } from 'react'
// import { parseISO } from 'rsuite/esm/utils/dateUtils'
import styled from 'styled-components'

Expand All @@ -21,9 +21,16 @@ export function FormikDatePicker({ isCompact, isLight, label, name, withTime }:
const { setValue } = helpers
const datepickerRef = useRef() as MutableRefObject<HTMLDivElement>

const [keyForceUpdate, forceUpdate] = useReducer(x => x + 1, 0)

useEffect(() => {
forceUpdate()
}, [name, forceUpdate])

return (
<DatePickerWrapper ref={datepickerRef} data-cy="datepicker">
<DatePicker
key={keyForceUpdate}
defaultValue={value}
isCompact={isCompact}
isLight={isLight}
Expand Down

0 comments on commit efb3997

Please sign in to comment.