<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Make this playlist</title>
        <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
        {{ bootstrap.load_css() }}
    </head>
    <body>
        <div class="container">
            <h1>Make this playlist</h1>
            <p>You too, choose the music that will play tonight.</p>
            <div class="row">
                <div class="col-sm">
                    <h2>Join a room</h2>
                    <form method="POST" >
                        <div class="form-group">
                            <label for="roomID">Enter here the room id:</label>
                            <input type="text" class="form-control" name="roomID" placeholder="00000000" maxlength="8" minlength="8" />
                            <small id="roomIDHelp" class="form-text text-muted">If you don't have a room id, you can create one.</small>
                        </div>
                        <button type="submit" class="btn btn-primary">Join</button>
                    </form>
                </div>
                <div class="col-sm">
                    <h2>Create a room</h2>
                    <form method="POST" action="/create">
                        <div class="form-group">
                            <label for="roomName">Enter here the room name:</label>
                            <input type="text" class="form-control" name="roomName" placeholder="Room name" />
                            <small id="roomNameHelp" class="form-text text-muted">This will be the playlist name</small>
                        </div>
                        <button type="submit" class="btn btn-success">Create</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="sweetalert">
            <script>
                if ("{{ type }}" !== "") {
                    if ("{{ type }}" === "success") {
                        Swal.fire({
                            title: "{{ response }}",
                            text: "{{ comment }}",
                            icon: "{{ type }}",
                            confirmButtonText: "Let's get in!",
                        }).then(function() {
                            window.location = "/search/{{ roomid }}";
                        })
                    } else {
                        Swal.fire({
                            title: "{{ response }}",
                            text: "{{ comment }}",
                            icon: "{{ type }}",
                            confirmButtonText: "Try again",
                        }).then(function() {
                            window.location = "/";
                        })
                    }
                }
            </script>
        </div>
    </body>
</html>