Parcourir la source

validation fix

Viktoriia il y a 1 mois
Parent
commit
223315d271

+ 2 - 1
src/screens/InAppScreens/TravelsScreen/EditNmDataScreen/index.tsx

@@ -282,6 +282,7 @@ const EditNmDataScreen = ({ navigation, route }: { navigation: any; route: any }
   const compareDates = useCallback(
     (startDate: DateValue | null, endDate: DateValue | null): boolean => {
       if (!startDate || !endDate || !startDate.year || !endDate.year) return true;
+      const maxEndDay = moment(`${endDate.year}-${endDate.month ?? 12}`, 'YYYY-M').daysInMonth();
 
       const start = moment({
         year: startDate.year,
@@ -292,7 +293,7 @@ const EditNmDataScreen = ({ navigation, route }: { navigation: any; route: any }
       const end = moment({
         year: endDate.year,
         month: (endDate.month || 12) - 1,
-        day: endDate.day || 31
+        day: endDate.day || maxEndDay
       });
 
       if (!start || !end) return true;