Skip to content

Commit

Permalink
fix: resolve remaining bug on refacto
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehdi-BOUYAHIA authored Nov 30, 2023
1 parent 0389672 commit 26c90ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const DemographicForm = (props: DemographicFormProps) => {
const [multiFields, setMultiFields] = useState<string | null>(localStorage.getItem('multiple_fields'))
const isEdition = selectedCriteria !== null ? true : false

console.log('test error', error)

useEffect(() => {
setError(Error.NO_ERROR)
const _age0 = convertStringToDuration(age[0])
Expand Down
14 changes: 14 additions & 0 deletions src/components/ui/Inputs/DurationRange/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ const DurationRange: React.FC<DurationRangeProps> = ({
useEffect(() => {
setError({ isError: false, errorMessage: '' })
onError(false)
if (
(minDuration.year === null || minDuration.year === 0) &&
(minDuration.month === null || minDuration.month === 0) &&
(minDuration.day === null || minDuration.day === 0)
) {
setMinDuration(defaultMinDuration)
}
if (
(maxDuration.year === null || maxDuration.year === 0) &&
(maxDuration.month === null || maxDuration.month === 0) &&
(maxDuration.day === null || maxDuration.day === 0)
) {
setMaxDuration(defaultMaxDuration)
}
if (!checkMinMaxValue(minDuration, maxDuration)) {
setError({ isError: true, errorMessage: 'La date maximale doit être supérieure à la date minimale.' })
onError(true)
Expand Down

0 comments on commit 26c90ea

Please sign in to comment.