{% extends 'base.html' %}
{% from 'bootstrap5/form.html' import render_form %}

{% block content %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script>
<script>
    function drop(id) {
        if(window.confirm("Are you sure you wish to drop your application? This cannot be undone. (patiently wait after clicking the button)")) {
            window.location.href = "/admin/drop/" + id;
        }
    }

    function resumeChange() {
        let val = document.getElementById('resume').value;
        val = val.split(/\\|\//gi).slice(-1)[0]
        document.getElementById('filename').setAttribute('value', val);
    }
</script>

<div class="d-flex flex-column p-2 mt-3 align-items-center">
   <div class="row">
        
    <h1>Hi {{ current_user.first_name }}!</h1><br/>

   </div>    <div class="row p-2">
    {% if current_user.waitlisted %}
    <h2>You're currently waitlisted, keep checking your email to see if space
        opens up!</h2>
    {% else %}
    <h2>Your registration is confirmed! We're looking forward to seeing you at
        GoatHacks!</h2>
    <span>Let us know if you have any questions by sending them to <a
                                                                           href="mailto:hack@wpi.edu">hack@wpi.edu</a></span>
    </div>
    <br/>
    <div class="row">
        <p>Make sure you join the Discord and add your shirt size as well as any
        needed accomodations below</p>
    </div>
    <div class="row mb-3">
        <button type="button" class="btn btn-secondary"><a
                              href="https://discord.gg/gqYxndzY"
                                    class="link-light">Discord</a></button>
    </div>
    
    <div class="row mb-3">
        <div class="card" style="width: 50rem; background-color: #974355;">
            <div class="card-body">
                <div class="card-text">
                    {{ render_form(form) }}
                </div>
            </div>
        </div>
    </div>
    <div class="row">
            <form method="post" action="{{url_for('dashboard.resume')}}" enctype="multipart/form-data">
                {{ resform.csrf_token }}
                <p><b>If you'd like, add your resume to send to sponsors... </b></p>
                <div class="file-field input-field">
                    <div class="btn">
                        <label for="resume">File</span>
                        <input class="form-control" id="resume" name="resume" type="file" oninput="resumeChange()"/>
                        
                    </div>
                </div>
                <input name="submit" class="btn btn-lg btn-primary btn-invert" type="submit" value="Submit"/>
            </form>
    </div>
    {% endif %}
    {% if current_user.is_admin %}
    <div class="row">
        <button type="button" class="btn btn-primary"><a href="{{
                             url_for('admin.home') }}" class="link-light">Admin Dashboard</a></button>
    </div>
    {% endif %}
</div>

<script>
    let errColor = '#E74C3C'

    $(document).ready(() => {
        $('#drop-link').click((e) => {
            e.preventDefault()
        let id = {{ id }}
            drop(id)
        })
    })

</script>
{% endblock %}