<?php
include($_SERVER['DOCUMENT_ROOT'] . "/COMPONENTS/root/path.php");
echo "<h5 class='userId' style='display:none;'>" . $_GET['configId'] . "</h5>";
?>



<form action="#" class="pl-3 pr-3" id="form_deleteConfiguration">
    <h1 style='font-size:18px; text-align:center; color:black;' id="configHeading"></h1>
    <h1 style='font-size:15px; text-align:center;' id="subTitle"></h1>
    <div class="form-group fourthInput" style="display:none;">
        <label for="emailaddress1">Config Type</label>

        <select class="form-control" name="config_id" >
             <option><?php echo $_GET['configId']?></option>
        </select>
    </div>


    <div class="form-group text-center">
    <button type="button" class="btn btn-rounded btn-secondary closeModal" >Cancel</button>
    <button type="submit" class="btn btn-rounded btn-success submit_deleteConfiguration" ><span class='submitLoader'><i class="fas fa-check"></i> Delete</span></button>
    </div>

</form>

<script>
    $(".submit_deleteConfiguration").on("click", function() {
        $("#form_deleteConfiguration").submit(function(e) {
            $.ajax({
                url: domain_api + "/other-configs/delete.php",
                type: "POST",
                data: $(this).serialize(),
                beforeSend: function() {
                    $(".submit_deleteConfiguration").attr("disabled", "disabled");
                    $(".submitLoader").html("<i class='fa fa-spinner fa-spin'></i>")
                },
                success: function(data) {
                    $(".submitLoader").html("Update");
                    $(".submit_deleteConfiguration").attr("disabled", false);
                    if (data.code == 200) {
                        swal("Succes!", "Configuration was successfully deleted!", "success");
                    } else {
                        swal("Oops!", "Deletion was not successful, you should try again!", "error");
                    }
                }
            });
            e.preventDefault();
        })
        $(this).off();
    });
</script>