@sabroso/react-native-date-range-picker
Version:
## Reference This component is a clone of react-native-date-range but adding some new props like: `textStartDate`,`textEndDate` and `alertMessageText`.
17 lines (15 loc) • 579 B
JavaScript
export const dates = (startDate, endDate, focusedInput ) => {
if (focusedInput === 'startDate') {
if (startDate && endDate) {
return ({ startDate, endDate: null, focusedInput: 'endDate' });
}
return ({ startDate, endDate, focusedInput: 'endDate' });
}
if (focusedInput === 'endDate') {
if (endDate && startDate && endDate.isBefore(startDate)) {
return ({ startDate: endDate, endDate: null, focusedInput: 'endDate' });
}
return ({ startDate, endDate, focusedInput: 'startDate' });
}
return ({ startDate, endDate, focusedInput });
};