[booking resource_id=1 form_type=’time_slots_booking’]
div class= »raku-booking »> const container = document.getElementById(‘slots’); container.innerHTML = »; slots.forEach(slot => { const remaining = slot.placesMax – slot.placesReservees; const div = document.createElement(‘div’); div.className = ‘slot’; if(remaining <= 0){ div.classList.add('complete'); } let html = `${slot.date} – ${slot.heure}
Places restantes : ${remaining}
`; if(remaining > 0){ html += ` `; } else{ html += `Complet
`; } div.innerHTML = html; container.appendChild(div); if(remaining > 0){ const button = div.querySelector(‘button’); button.addEventListener(‘click’, async () => { const nom = div.querySelector(‘.nom’).value; const email = div.querySelector(‘.email’).value; const places = parseInt(div.querySelector(‘.places’).value); if(!nom || !email){ alert(‘Merci de remplir tous les champs’); return; } const reservation = { row: slot.row, nom, email, places }; const response = await fetch(SCRIPT_URL, { method:’POST’, body: JSON.stringify(reservation) }); const result = await response.json(); alert(result.message); loadSlots(); }); } }); } loadSlots();