import { Controller } from '@hotwired/stimulus'; export default class extends Controller { static values = { eventId: String, // UUIDv7 de l'événement gameId: String // UUIDv7 du jeu } connect() { console.log("Stimulus: toggle game actif"); this.element.addEventListener('click', this.toggleGame.bind(this)); } async toggleGame(event) { event.preventDefault(); const eventId = this.eventIdValue; const gameId = this.gameIdValue; if (!eventId || !gameId) { console.error("UUID manquant pour event ou game"); return; } const url = `/admin/event/${eventId}/configure/game/toggle/`; console.log(gameId); try { const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest', //'X-CSRF-TOKEN': this.getCsrfToken() TODO: remettre en place si néccesaire ? }, body: JSON.stringify({ gameId: gameId }) }); if (!response.ok) { console.error("Erreur HTTP :", response.status); return; } const data = await response.json(); const cell = this.element; if (!cell) { console.error("Élément