@{
    ViewData["Title"] = "회원 등급";

    var data = ViewBag.Data as IEnumerable<dynamic>;
    var total = ViewBag.Total.ToString("N0");
}

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

    <partial name="_StatusMessage" />

    <div class="row g-2 align-items-end">
        <div class="col">
            Total : @total
        </div>
        <div class="col text-end">
            <a class="btn btn-sm btn-success" href="/Member/Grade/Write">추가</a>
        </div>
    </div>

    <div class="table-responsive">
        <table class="table table-striped table-bordered table-hover mt-3">
            <colgroup>
                <col width="*"/>
                <col width="*"/>
                <col width="20%"/>
                <col width="*"/>
                <col width="*"/>
                <col width="*"/>
                <col width="*"/>
                <col width="*"/>
                <col width="*"/>
                <col width="*"/>
                <col width="10%"/>
            </colgroup>
            <thead>
                <tr>
                    <th>ID</th>
                    <th>이미지</th>
                    <th>등급명</th>
                    <th>순서</th>
                    <th>회원 수</th>
                    <th>요구 경험치</th>
                    <th>요구 코인</th>
                    <th>사용 여부</th>
                    <th>등록일시</th>
                    <th>수정일시</th>
                    <th>비고</th>
                </tr>
            </thead>
            <tbody>
                @if (data == null || !data.Any())
                {
                    <tr>
                        <td colspan="11">No Data.</td>
                    </tr>
                }
                else
                {
                    @foreach (var row in data)
                    {
                        <tr>
                            <td>@row.ID</td>
                            <td>
                                @if (!string.IsNullOrEmpty(row.Image))
                                {
                                    <img src="@row.Image" class="img-thumbnail" alt="@row.Name" />
                                } else {
                                    <text>-</text>
                                }
                            </td>
                            <td>@row.Name</td>
                            <td>@row.Order</td>
                            <td>@row.MemberRows</td>
                            <td>@row.RequiredExp</td>
                            <td>@row.RequiredCoin</td>
                            <td>@row.IsActive</td>
                            <td>@row.CreatedAt</td>
                            <td>@row.UpdatedAt</td>
                            <td>
                                <div class="d-grid gap-2 d-block d-xxl-inline">
                                    <a class="btn btn-sm btn-outline-info" href="@row.EditURL">수정</a>
                                    <a class="btn btn-sm btn-outline-danger btn-row-delete" href="@row.DeleteURL">삭제</a>
                                </div>
                            </td>
                        </tr>
                    }
                }
            </tbody>
        </table>
    </div>
</div>
