{{ $formClasses := "bg-neutral-500 text-neutral-50 placeholder-neutral-300 focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 focus:ring-offset-transparent m-2 p-3 rounded-lg hover:bg-neutral-500 checked:text-neutral-500" }}

<script>
 function submitForm(e) {
     e.preventDefault();
     const form = document.getElementById('form');
     const data = new FormData(form);
 
     var xhr = new XMLHttpRequest();
     xhr.onreadystatechange = function() {
         if (this.readyState == 4 && this.status == 200) {
             // Logic directing where to send the user after form submission based on results.
             window.location.href = '/thankyou/';
         };
     };
     xhr.open("POST", "https://n8n.tfcconnection.org/webhook/mt-church-form");
     xhr.send(data);
     console.log(data);
     console.log("Hallo!");
     return false;
 }
</script>

<div id="mt-form" class="form text-lg w-full">
    <form id='form' onsubmit="submitForm(event)" autocomplete="on" method="post" target="_parent" class="w-full items-center flex flex-wrap">
        <div class="basis-full flex flex-wrap my-4">
            <label for="firstname" class="basis-full">What is your first and last name?</label>
            <br/>
            <input type="text" id="firstname" name="firstname"
                   placeholder="First Name" class="flex-1 form-input {{ $formClasses }}">
            <input type="text" id="lastname" name="lastname"
                   placeholder="Last Name" class="flex-1 form-input {{ $formClasses }}">
        </div>
        <div class="basis-full flex flex-wrap my-4">
            <label for="studentnfirstname" class="basis-full">Teenager's first and last name?</label>
            <input type="text" id="studentfirstname" name="studentfirstname"
                   class="flex-1 form-input {{ $formClasses }}"
                   placeholder="First Name">
            <input type="text" id="studentlastname" name="studentlastname"
                   class="flex-1 form-input {{ $formClasses }}"
                   placeholder="Last Name">
        </div>
        <div class="basis-full flex flex-wrap my-4">
            <label for="relationship" class="basis-full">Relationship to Teen</label>
            <input type="text" id="relationship" name="relationship"
                   class="flex-1 form-input {{ $formClasses }}"
                   placeholder="First Name">
        </div>
        <div class="basis-full mt-10">
            <label for="walk-with-jesus" class="p-4">
                How would you describe this teenager's personal walk with Jesus?
            </label>
            <br/>
            <textarea id="walk-with-jesus" name="walk-with-jesus"
                      class="form-input w-full h-64 {{ $formClasses }}"
                      placeholder="notes..."></textarea>
        </div>
        <div class="basis-full mt-10">
            <label for="commitment" class="p-4">
                How would you rate the teenager's commitment to church and it's activities (or other activities that encourage spiritual growth)?
            </label>
            <br/>
            <textarea id="commitment" name="commitment"
                      class="form-input w-full h-64 {{ $formClasses }}"
                      placeholder=""></textarea>
        </div>
        <div class="basis-full mt-10">
            <label for="teachable" class="p-4">
                How would you describe the teen's teachable spirit and willingness to serve others?
            </label>
            <br/>
            <textarea id="teachable" name="teachable"
                      class="form-input w-full h-64 {{ $formClasses }}"
                      placeholder=""></textarea>
        </div>
        <div class="basis-full mt-10">
            <label for="pos-characteristics" class="p-4">
                What positive characteristics do you see this teenager bringing to a mission trip team?
            </label>
            <br/>
            <textarea id="pos-characteristics" name="pos-characteristics"
                      class="form-input w-full h-64 {{ $formClasses }}"
                      placeholder=""></textarea>
        </div>
        <div class="basis-full mt-10">
            <label for="neg-characteristics" class="p-4">
                What negative characteristics would you be concerned about this teenager bringing to a mission trip team?
            </label>
            <br/>
            <textarea id="neg-characteristics" name="neg-characteristics"
                      class="form-input w-full h-64 {{ $formClasses }}"
                      placeholder=""></textarea>
        </div>
        <div class="basis-full mt-10">
            <label for="extra-info" class="p-4">
                What else would you like to tell us about this teenager that might be relevant as we consider them for a Mission Trip?
            </label>
            <br/>
            <textarea id="extra-info" name="extra-info"
                      class="form-input w-full h-64 {{ $formClasses }}"
                      placeholder=""></textarea>
        </div>
        <div class="basis-full mt-8">
            <button type="submit" class="content-right rounded-lg bg-primary-700 h-12 w-24 focus:bg-primary-900 focus:ring focus:ring-primary-700 hover:bg-primary-900 float-right">Submit</button>
        </div>
    </form>
</div>
