import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
    static targets = ["dialog", "form", "token"];

    open(event) {
        const button = event.currentTarget;
        const url = button.dataset.url;
        const token = button.dataset.token;

        // Remplit le formulaire avec les bonnes données
        this.formTarget.action = url;
        this.tokenTarget.value = token;

        this.dialogTarget.classList.remove("hidden");
        this.dialogTarget.classList.add("flex");
    }

    close() {
        this.dialogTarget.classList.add("hidden");
        this.dialogTarget.classList.remove("flex");
    }
}
