// function getWaters(venueID) {
//     $.ajax({
//         url: `/venues/get-waters/${venueID}`,
//         type: "GET",
//         "dataType": "json",
//         success: function (data) {
//             alert(JSON.stringify(data));
//         },
//         error: function (error) {
//             alert("error: " + error);
//         }
//     });
// }

function openVenueModal(venue_id) {
    if (venue_id == -1) {
        $("#venueModal .edit").hide();
        $("#venueModal .create").show();

        $("#venueName").val("");
        $("#venueDescription").val("");
        $("#venueType").val("FISHERY").change();

        $("#venueStreetAddress").val("");
        $("#venueCity").val("");
        $("#venueProvence").val("");
        $("#venuePostCode").val("")

        $("#venuePhone").val("");
        $("#venueEmail").val("");
        $("#venueWebsite").val("");

        $("#venueTwitter").val("");
        $("#venueFacebook").val("");
        $("#venueInstagram").val("");
    }
    else {
        $("#venueModal .edit").show();
        $("#venueModal .create").hide();

        $.ajax({
            url: `/venues/api/${venue_id}`,
            method: 'get',
            dataType: 'json',
            success: function(response) {
                const venue = response.data;

                $("#venueName").val(venue.name);
                $("#venueDescription").val(venue.description);
                $("#venueType").val(venue.venue_type).change();

                $("#venueStreetAddress").val(venue.street_address);
                $("#venueCity").val(venue.city);
                $("#venueProvence").val(venue.provence);
                $("#venuePostCode").val(venue.postal_code)

                $("#venuePhone").val(venue.phone_number);
                $("#venueEmail").val(venue.email_address);
                $("#venueWebsite").val(venue.website_url);

                $("#venueTwitter").val(venue.twitter_url);
                $("#venueFacebook").val(venue.facebook_url);
                $("#venueInstagram").val(venue.instagram);
            },
            error: function(error) {
                alert("error: " + JSON.stringify(error));
            }
        });
    }

    new bootstrap.Modal("#venueModal").show();
}