2024-10-03 13:48:45 +02:00
|
|
|
import '../css/app.css';
|
|
|
|
import Alpine from 'alpinejs';
|
|
|
|
import Datepicker from 'flowbite-datepicker/Datepicker';
|
|
|
|
import de from '../../node_modules/flowbite-datepicker/js/i18n/locales/de.js';
|
2024-03-05 11:41:34 +01:00
|
|
|
Datepicker.locales.de = de.de;
|
2024-10-03 13:48:45 +02:00
|
|
|
import dayjs from 'dayjs';
|
|
|
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
2024-03-05 11:41:34 +01:00
|
|
|
dayjs.extend(customParseFormat);
|
2024-02-12 21:44:41 +01:00
|
|
|
|
2024-03-05 11:41:34 +01:00
|
|
|
function initDatepicker(el) {
|
2024-10-03 13:48:45 +02:00
|
|
|
new Datepicker(el, {
|
|
|
|
autohide: true,
|
|
|
|
format: 'dd.mm.yyyy',
|
|
|
|
language: 'de',
|
|
|
|
update: true,
|
|
|
|
});
|
|
|
|
el.addEventListener('changeDate', function (event) {
|
|
|
|
event.target.dispatchEvent(new Event('input'));
|
|
|
|
});
|
2024-03-05 11:41:34 +01:00
|
|
|
}
|
|
|
|
|
2024-10-03 13:48:45 +02:00
|
|
|
document.querySelectorAll('[datepicker]').forEach((el) => initDatepicker(el));
|
2024-03-05 11:41:34 +01:00
|
|
|
|
|
|
|
window.Alpine = Alpine;
|
2024-10-03 13:48:45 +02:00
|
|
|
Alpine.data('form', () => ({
|
|
|
|
birthday: null,
|
|
|
|
date: null,
|
|
|
|
isUnder18: function () {
|
|
|
|
if (!this.birthday || !this.date) {
|
|
|
|
return false;
|
|
|
|
}
|
2024-03-05 11:41:34 +01:00
|
|
|
|
2024-10-03 13:48:45 +02:00
|
|
|
return dayjs(this.birthday, 'DD.MM.YYYY').add(18, 'year').isAfter(dayjs(this.date, 'DD.MM.YYYY'));
|
|
|
|
},
|
2024-03-05 11:41:34 +01:00
|
|
|
}));
|
|
|
|
|
|
|
|
Alpine.start();
|