calendar-strip - get mapado events for month working

This commit is contained in:
isUnknown 2024-07-24 18:01:01 +02:00
parent 801fe38447
commit 02554fa718
3 changed files with 64 additions and 14 deletions

View file

@ -4,26 +4,35 @@
monthNumb: dayjs().month(),
token: '<?= $site->mapadoToken() ?>',
contractId: '<?= $site->mapadoContractId() ?>',
dates: [],
get monthName() {
return dayjs().month(this.monthNumb).format('MMMM');
},
get days() {
return getDaysInMonth(this.monthNumb, dayjs().year())
async updateDates() {
this.dates = getDatesInMonth(this.monthNumb);
const mapadoDates = await getMapadoDates(this.monthNumb)
mapadoDates.forEach(mapadoDate => {
const day = parseInt(mapadoDate.day)
this.dates[day].push(mapadoDate.name)
})
console.log(this.dates)
}
}"
x-init="getEvents(monthNumb)"
x-init="updateDates()"
>
<div class="calendar-strip__selector">
<button class="prev-month" @click="monthNumb--" :disabled="monthNumb === -4 ? true : false"></button>
<button class="prev-month" @click="monthNumb--; updateDates()" :disabled="monthNumb === -4 ? true : false"></button>
<span x-text="monthName"></span>
<button class="next-month" @click="monthNumb++" :disabled="monthNumb === 7 ? true : false"></button>
<button class="next-month" @click="monthNumb++; updateDates()"></button>
</div>
<ul class="calendar-strip__days">
<template x-for="(day, index) in days">
<li x-text="index + 1"></li>
<template x-for="(date, index) in dates">
<li class="calendar-strip__day" :class="date.length > 0 ? 'event' : false" x-text="index"></li>
</template>
</ul>
<button class="calendar-strip__calendar-btn">calendrier</button>