Skip to content
Snippets Groups Projects
Commit 2118d427 authored by lass's avatar lass
Browse files

Remember end-date between forms

parent dcba7779
No related branches found
No related tags found
1 merge request!396Greg 334 fix
Pipeline #185468 failed
......@@ -49,7 +49,6 @@ const StepPersonForm = forwardRef(
const [todayPlusMaxDays, setTodayPlusMaxDays] = useState(today)
const roleTypes = useRoleTypes()
const { displayContactAtUnit, displayComment } = useContext(FeatureContext)
const [endDate, setEndDate] = useState<Date | null>(null)
const roleTypeSort = () => (a: RoleTypeData, b: RoleTypeData) => {
if (i18n.language === 'en') {
......@@ -104,9 +103,6 @@ const StepPersonForm = forwardRef(
: roleTypes.find((rt) => rt.id === roleTypeId)
const maxDate = getMaxDateForRoleType(selectedRoleTypeInfo)
setTodayPlusMaxDays(maxDate)
// Trigger revalidation of role end since the max end date is
// different for different role types
trigger('role_end')
}
// When the component is first rendered and there is some role_type set in
......@@ -325,12 +321,11 @@ const StepPersonForm = forwardRef(
<DatePicker
mask="____-__-__"
label={t('input.roleEndDate')}
value={endDate}
value={field.value}
minDate={today}
maxDate={todayPlusMaxDays}
inputFormat="yyyy-MM-dd"
onChange={(value) => {
setEndDate(value)
field.onChange(value)
}}
renderInput={(params) => <TextField {...params} />}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment