<?php include($_SERVER['DOCUMENT_ROOT'] . "/COMPONENTS/root/path.php"); ?>


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

        <select class="form-control" id="configType" name="config_type_id">

        </select>
    </div>

    <div class="form-group secondInput">
        <label for="name" id="Description"></label>
        <input class="form-control" type="text" required name="name" id="name" placeholder="Enter description">
    </div>

    <div class="form-group serviceCharge" style="display:none;">
        <label for="name" id="serviceCharge"></label>
        <input class="form-control" type="number" required name="amount" id="amount" placeholder="Enter amount" pattern='[0-9]+([.][0.00-9.00]+)' step='0.01'>
    </div>





    <div class="form-group text-center">
        <button type="submit" class="btn btn-rounded btn-primary submit_addConfiguration" style="width:250px;">Submit</button>
    </div>

</form>

<script>
  

    $(".submit_addConfiguration").on("click", function() {
        var endpoint = $(".config").val();
        $("#form_addConfiguration").submit(function(e) {
            $.ajax({
                url: domain_api + "/other-configs/create.php",
                type: "POST",
                data: $(this).serialize(),
                beforeSend: function() {
                    $("#signin").attr("disabled", "disabled");
                },
                success: function(data) {
                    if (data.code == 200) {
                        swal("Succes!", "Configuration was successfully saved!", "success");
                    } else {
                        swal("Oops!", "Saving was not successful, you should try again!", "error");
                    }
                }
            });
            e.preventDefault();
        })
        $(this).off();
    });
</script>