From e706b6216753031dd06ef52754ec89a1cb2231ca Mon Sep 17 00:00:00 2001 From: Josh Latour Date: Tue, 14 Apr 2020 00:21:35 -0500 Subject: [PATCH 1/2] feat(datepickerwithlabelformgroup.tsx): max DOB set for current date Added maxDate prop to DatePicker component to avoid DOB being set in the future. --- src/components/input/DatePickerWithLabelFormGroup.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/input/DatePickerWithLabelFormGroup.tsx b/src/components/input/DatePickerWithLabelFormGroup.tsx index e1f137b0e8..c3cf10c308 100644 --- a/src/components/input/DatePickerWithLabelFormGroup.tsx +++ b/src/components/input/DatePickerWithLabelFormGroup.tsx @@ -1,5 +1,6 @@ import React from 'react' import { Label, DateTimePicker } from '@hospitalrun/components' +import { addDays } from 'date-fns' interface Props { name: string @@ -22,6 +23,7 @@ const DatePickerWithLabelFormGroup = (props: Props) => { dateFormat="MM/dd/yyyy" dateFormatCalendar="LLLL yyyy" dropdownMode="scroll" + maxDate={addDays(new Date(), 0)} selected={value} timeIntervals={30} withPortal={false} From 1d5e828f1006ff405051fcf27d492f1d6b36551e Mon Sep 17 00:00:00 2001 From: Josh Latour Date: Tue, 14 Apr 2020 17:50:27 -0500 Subject: [PATCH 2/2] feat(datepickerwithlabel, generalinformation): max date for DOB Added maxDate prop to DatePicker component to avoid DOB being set in the future. fix #1985 --- .../input/DatePickerWithLabelFormGroup.tsx | 16 +++++++++++++--- src/patients/GeneralInformation.tsx | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/input/DatePickerWithLabelFormGroup.tsx b/src/components/input/DatePickerWithLabelFormGroup.tsx index c3cf10c308..777b69326e 100644 --- a/src/components/input/DatePickerWithLabelFormGroup.tsx +++ b/src/components/input/DatePickerWithLabelFormGroup.tsx @@ -1,6 +1,5 @@ import React from 'react' import { Label, DateTimePicker } from '@hospitalrun/components' -import { addDays } from 'date-fns' interface Props { name: string @@ -11,10 +10,21 @@ interface Props { isRequired?: boolean feedback?: string isInvalid?: boolean + maxDate?: Date } const DatePickerWithLabelFormGroup = (props: Props) => { - const { onChange, label, name, isEditable, value, isRequired, feedback, isInvalid } = props + const { + onChange, + label, + name, + isEditable, + value, + isRequired, + feedback, + isInvalid, + maxDate, + } = props const id = `${name}DatePicker` return (
@@ -23,7 +33,7 @@ const DatePickerWithLabelFormGroup = (props: Props) => { dateFormat="MM/dd/yyyy" dateFormatCalendar="LLLL yyyy" dropdownMode="scroll" - maxDate={addDays(new Date(), 0)} + maxDate={maxDate} selected={value} timeIntervals={30} withPortal={false} diff --git a/src/patients/GeneralInformation.tsx b/src/patients/GeneralInformation.tsx index 93efcb6ce4..4a1811e2e0 100644 --- a/src/patients/GeneralInformation.tsx +++ b/src/patients/GeneralInformation.tsx @@ -167,6 +167,7 @@ const GeneralInformation = (props: Props) => { : undefined } isInvalid={invalidFields?.dateOfBirth} + maxDate={new Date()} feedback={feedbackFields?.dateOfBirth} onChange={(date: Date) => { onDateOfBirthChange(date)