@page
@model IndexModel
@{
    ViewData["Title"] = "Please select your Class";
}

@if (Model.isTeacher)
{
    <div class="row-cols-auto">
        <div class="col-auto">
            You are recognized as a teacher. You may toggle membership of any class<br /><br />
        </div>
    </div>
    <div class="row-cols-auto" >
        <div class="col-auto">
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>Current Groups and Classes</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            @foreach (var item in Model.currentGroups)
                            {

                                @item.name<br />
                            }
                        </td>
                    </tr>
                </tbody>
            </table>

        </div>
    </div>
    <div class="row-cols-auto">
        <div class="col-auto">
            <form method="post">
                <input type="hidden" name="action" value="toggleclass" />
                <select class="form-select" name="target" onchange="javascript:this.form.submit()">
                    <option selected>Please select your class</option>
                    @foreach (var item in Model.availableGroups)
                    {
                        @if (item.name.Contains("-CSD-"))
                        {
                            <option value="@item.id">@item.name</option>
                        }
                    }
                </select>
            </form>
            <br>
            You have to log out to activate the new settings<br>
            <form method="post">
                <input type="hidden" name="action" value="logout" />
                <input type="submit" class="btn btn-warning" value="Logout">
            </form>
        </div>
    </div>
}
else
{
    <div class="row-cols-auto">
        <div class="col-auto">
            Your current Class is: @Model.ucnData.theClass[0]<br /><br />
        </div>
    </div>
    <div class="row-cols-auto">
        <div class="col-auto">
            <form method="post">
                <input type="hidden" name="action" value="selectclass" />
                <select class="form-select" name="target" onchange="javascript:this.form.submit()">
                    <option selected>Please select your class</option>
                    @foreach (var item in Model.availableGroups)
                    {
                        @if (item.name.Contains("-CSD-"))
                        {
                            <option value="@item.id">@item.name</option>
                        }
                    }
                </select>
            </form>
        </div>
    </div>
}
