import { Controller } from "@hotwired/stimulus";
import { GisState } from "../state.js";
import UI from "../ui.js";

export default class extends Controller {
    static values = {
        'coords': String,
        'group': String,
        'id': String,
    };

    static targets = ['search'];
    
    /**
     * 
     * @param {Event} event 
     */
    async submitSearch(event) {
        event.preventDefault();
        const data = new FormData(event.target);
        const body = {};

        for (const entry of data.entries()) {
            body[entry[0]] = entry[1];
        }

        const response = await fetch("https://caprigis-api.ddev.site:33001/search?" + new URLSearchParams(body));

        console.debug(await response.json(), body);
    }
}
