Level 51
This is what I had in jquery:
function updateEndDate() {
var dates = $startDate.selectedDates;
if (dates.length === 0) {
return false;
}
var duration = $('#duration').val();
var startDate = moment(dates[0]);
var endDate = null;
if (duration.length > 0 && startDate.isValid()) {
durationInt = duration.replace(/\D/g,'');
durationKey = duration.includes('years') ? 'y' : 'M';
endDate = startDate.add(durationInt, durationKey).subtract(1, "days");
$('#end-date .date').text(endDate.format('Do MMMM YYYY')).parent().fadeIn();
} else {
$('#end-date .date').empty();
}
}
var $startDate = $("#start_date").flatpickr({
dateFormat: 'J F Y',
onChange: function (selectedDates, dateStr, instance) {
return updateEndDate();
}
});
But I'm moving away from jQuery and want to replicate this working in Vue instead
