Last active
January 2, 2019 11:28
-
-
Save heleneshaikh/455ae994d80a645e295b5b75560d9bcd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<datepicker | |
:startDate="startDate" | |
@checkInChanged="setCheckinDate" | |
:maxNights="30" | |
:disabledDates="bookedDates" | |
:firstDayOfWeek="1" | |
:i18n="lang" | |
:showYear="true" | |
> | |
</datepicker> | |
</template> | |
<script> | |
import datepicker from 'vue-hotel-datepicker'; | |
import Routing from '../../../../vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.min.js'; | |
const routes = require('../fos_js_routes.json'); | |
Routing.setRoutingData(routes); | |
export default { | |
components: { | |
datepicker | |
}, | |
data() { | |
return { | |
bookedDates: [], | |
startDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 14), | |
maxDate: 0, | |
minNights: 5, //4 + 1 for rendering | |
lang: { | |
night: 'Night', | |
nights: 'Nights', | |
'day-names': ['Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun'], | |
'check-in': 'Check-in', | |
'check-out': 'Check-Out', | |
'month-names': ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], | |
} | |
} | |
}, | |
methods: { | |
setCheckinDate(newDate) { | |
console.log('test'); | |
}, | |
fetchBookedDates() { | |
window.fetch(Routing.generate('bookings')) | |
.then(checkStatus) | |
.then(response => response.json()) | |
.then(data => { | |
this.bookedDates = data['period']; | |
this.maxDate = new Date(data['maxDate']); | |
}) | |
.catch((error) => console.log(error)); | |
}, | |
}, | |
created() { | |
this.fetchBookedDates(); | |
} | |
} | |
function checkStatus(response) { | |
if (response.status >= 200 && response.status < 300) { | |
return Promise.resolve(response); | |
} | |
else { | |
return Promise.reject(new Error(response.statusText)); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment