@page
@model Quizzer.Pages.CategoriesModel
@Html.AntiForgeryToken()
@{
    ViewData["Title"] = "Quizzer";
    Layout = "_Layout-teacher";
}
<div class="container-fluid">
    <div class="row">
        <div class="col-xl-12" style="background-color: lightgreen">
            <h1><center>Category Management</center></h1>
        </div>
    </div>
    <div class=row>
        <div class="col-xl-12" style="background-color: lemonchiffon">
            <form class="form-horizontal" method="post">
                @Html.Raw(Model.CatSelectList)
                <label for="newTag" class="form-label">New Tag</label>
                <input class="form-control" type="text" id="newTag" placeholder="Your new category" name="newCategory" aria-label="default input example" />
                <button type="submit" class="btn btn-primary" name="action" value="newCategory">Submit</button>
            </form>
        </div>
    </div>
    @if (Model.CatSelected != null)
    {
        <div class=row>
            <div class="col-xl-12" style="background-color: lightblue">
                <table style="width:100%">
                    <tr>
                        <td style="width:max-content">
                            <h5>@Model.CatSelected.Txt</h5>
                        </td>
                        <td>
                            <form asp-page="" method="post">
                                <input type="hidden" name="action" value="removeCategory" />
                                <input type="hidden" name="target" value="@Model.CatSelected.CId" />
                                <button type="submit" class="btn btn-sm btn-outline-danger"><i class="bi bi-trash"></i></button>
                                Remove category (incl children)
                            </form>
                        </td>
                    </tr>
                </table>             
                <form class="form-horizontal" method="post">
                    <input type="hidden" name="categoryParent" value="@Model.CatSelected.CId">
                    <label for="CatSelected_Descr" class="form-label">Quizz description</label>
                    @Html.TextAreaFor(m => Model.CatSelected.Descr, 10,40, htmlAttributes: new {style="width: 100%; max-width: 100%;" })<br>
                    <button type="submit" class="btn btn-primary" name="action" value="editCategory">Change description for @Model.CatSelected.Txt</button>
                </form>
            </div>
        </div>
    }

</div>