@page
@model Admin.Pages.Director.User.IndexModel
@{
    ViewData["Title"] = "관리자";
}

<div class="container">
    <h3>@ViewData["Title"]</h3>
    <hr />

    <partial name="_StatusMessage" />
    <small>관리자 가입 회원들입니다. 메뉴 접근 권한을 관리할 수 있습니다.</small>

    <div class="row g-2">
        <div class="col align-self-end">
            Total : @Model.Total.ToString("N0")
        </div>
        <div class="col text-end">
            <a class="btn btn-primary" asp-page="/Director/Role/Index">역할 관리</a>
        </div>
    </div>

    <div class="table-responsive">
        <table class="table table-striped table-bordered table-hover mt-3">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Mail</th>
                    <th>Name</th>
                    <th>Role</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                @if (Model.List == null || !Model.List.Any())
                {
                    <tr>
                        <td colspan="5">No Data.</td>
                    </tr>
                }
                else
                {
                    @foreach (var user in Model.List)
                    {
                        <tr>
                            <td>
                                @user.ID<br/>
                                @if (user.IsDeleted)
                                {
                                    <span class="badge bg-danger text-white">폐쇄</span>
                                }
                                @if (user.LockoutEnd)
                                {
                                    <span class="badge bg-warning text-white">차단</span>
                                }
                                @if (user.EmailConfirmed)
                                {
                                    <span class="badge bg-success text-white">인증</span>
                                }
                            </td>
                            <td>@user.Email</td>
                            <td>@(user.Name ?? "-")</td>
                            <td>
                                @if (user.Roles.Any())
                                {
                                    @string.Join(", ", user.Roles)
                                }
                                else
                                {
                                    <span>-</span>
                                }
                            </td>
                            <td>
                                <div class="d-xl-flex gap-2 justify-content-center d-grid">
                                    <a class="btn btn-sm btn-info text-white" asp-page="/Director/User/Edit" asp-route-id="@user.ID">수정</a>
                                    <a class="btn btn-sm btn-danger" asp-page="/Director/User/Roles" asp-route-id="@user.ID">권한</a>
                                </div>
                            </td>
                        </tr>
                    }
                }
            </tbody>
        </table>
    </div>
</div>

@section Scripts {
    @{

    }
}