{% include 'header.html' %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css">

<div class="contact-section" style="height: 100%;">
    <div class="container">
        <div class="row" style="margin-top: 10%;">
            <h1>Hi {{ name }}!</h1>
            {% if waitlisted %}
                <h1>You are waitlisted, if space opens up we ill let you know...</h1>
            {% else %}
                <h1>You are fully registered! We look forward to seeing you!</h1>
            {% endif %}
            <br>
            <a href="#" id="drop-link"><p class="sub-button btn waves-effect waves-light grey darken-1">Drop Application :(</p></a>
            {% if admin %}
                <a href="/admin"><p class="btn">Admin Dashboard</p></a>
            {% endif %}
            <br>
            Please sit tight, while we improve the UI of this page :P
        </div>
    </div>
</div>

<script>
    let errColor = '#E74C3C'

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

    const drop = (id) =>
    {
        swal({
            title: 'Drop your application?',
            text: 'Are you sure you wish to drop your application? This cannot be undone. (patiently wait after clicking the button)',
            type: 'warning',
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonText: 'Yes, drop!',
            confirmButtonColor: errColor
        }, () => {
            $.get('/drop?mlh_id=' + id, (data) => {
            let title = ''
            let msg = ''
            let type = ''
            if (data.status === 'success'
    )
        {
            title = 'Dropped!'
            msg = 'Your application was successfully dropped!'
            type = 'success'
        }
    else
        {
            title = 'Error!'
            msg = JSON.stringify(data)
            type = 'error'
        }
        swal(title, msg, type)
        if (data.status === 'success') {
            setTimeout(() => {window.location = '/'
        },
            5000
        )
        }
    })
    })
    }
</script>

{% include 'footer.html' %}