|
|
@@ -219,14 +219,18 @@ const AddNewTripScreen = ({ route }: { route: any }) => {
|
|
|
return Object.keys(errors).length === 0;
|
|
|
};
|
|
|
|
|
|
+ const isFullDate = (d?: DateValue | null) => {
|
|
|
+ return !!(d?.year && d?.month && d?.day);
|
|
|
+ };
|
|
|
+
|
|
|
const openRangeCalendarForRegion = (index: number) => {
|
|
|
if (!regions) return;
|
|
|
|
|
|
const prevEnd = regions[index - 1]?.visitEndDate;
|
|
|
const nextStart = regions[index + 1]?.visitStartDate;
|
|
|
|
|
|
- const min = prevEnd ? dateValueToISO(prevEnd) : undefined;
|
|
|
- const max = nextStart ? dateValueToISO(nextStart) : undefined;
|
|
|
+ const min = isFullDate(prevEnd) ? dateValueToISO(prevEnd) : undefined;
|
|
|
+ const max = isFullDate(nextStart) ? dateValueToISO(nextStart) : undefined;
|
|
|
|
|
|
setCalendarMinDate(min as never);
|
|
|
setCalendarMaxDate(max as never);
|
|
|
@@ -577,12 +581,16 @@ const AddNewTripScreen = ({ route }: { route: any }) => {
|
|
|
closeRangeCalendar(startDate, endDate)
|
|
|
}
|
|
|
initialStartDate={
|
|
|
- calendarVisibleForIndex !== null && regions?.[calendarVisibleForIndex]?.visitStartDate
|
|
|
+ calendarVisibleForIndex !== null &&
|
|
|
+ regions?.[calendarVisibleForIndex]?.visitStartDate &&
|
|
|
+ regions[calendarVisibleForIndex].visitStartDate?.day
|
|
|
? `${regions[calendarVisibleForIndex].visitStartDate.year}-${regions[calendarVisibleForIndex].visitStartDate.month}-${regions[calendarVisibleForIndex].visitStartDate.day}`
|
|
|
: undefined
|
|
|
}
|
|
|
initialEndDate={
|
|
|
- calendarVisibleForIndex !== null && regions?.[calendarVisibleForIndex]?.visitEndDate
|
|
|
+ calendarVisibleForIndex !== null &&
|
|
|
+ regions?.[calendarVisibleForIndex]?.visitEndDate &&
|
|
|
+ regions[calendarVisibleForIndex].visitEndDate?.day
|
|
|
? `${regions[calendarVisibleForIndex].visitEndDate.year}-${regions[calendarVisibleForIndex].visitEndDate.month}-${regions[calendarVisibleForIndex].visitEndDate.day}`
|
|
|
: undefined
|
|
|
}
|