@page
@model Admin.Pages.Member.Grade.IndexModel
@{
    ViewData["Title"] = "회원 등급";
}

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

    <partial name="_StatusMessage" />

    <div class="row g-2 align-items-end">
        <div class="col">
            Total : @Model.Total.ToString("N0")
        </div>
        <div class="col text-end">
            <a class="btn btn-success" href="/Member/Grade/Write">추가</a>
        </div>
    </div>

    <div class="table-responsive">
        <table class="table table-striped table-bordered mt-3">
            <colgroup>
                <col width="*"/>
                <col width="140px"/>
                <col width="20%"/>
                <col width="*"/>
                <col width="*"/>
                <col width="*"/>
                <col width="*"/>
                <col width="10%"/>
            </colgroup>
            <thead>
                <tr>
                    <th>No</th>
                    <th rowspan="2">이미지</th>
                    <th rowspan="2">등급명</th>
                    <th>순서</th>
                    <th>누적 후원 수</th>
                    <th rowspan="2">사용 여부</th>
                    <th>등록일시</th>
                    <th rowspan="2">비고</th>
                </tr>
                <tr>
                    <th>ID</th>
                    <th>회원 수</th>
                    <th>누적 후원금</th>
                    <th>수정일시</th>
                </tr>
            </thead>
            @if (Model.Data == null || Model.Data.Count <= 0)
            {
                <tr>
                    <td colspan="8">No Data.</td>
                </tr>
            }
            else
            {
                @foreach (var row in Model.Data)
                {
                <tbody class="striped">
                    <tr>
                        <td>@row.Num</td>
                        <td rowspan="2">
                            @if (!string.IsNullOrEmpty(row.Image))
                            {
                                <img src="@row.Image" class="img-thumbnail" alt="@row.Name" />
                            } else {
                                <text>-</text>
                            }
                        </td>
                        <td rowspan="2">
                            <span style="color: @row.TextColor;">@row.Name</span>
                        </td>
                        <td>@row.Order</td>
                        <td>@row.TotalDonationCount</td>
                        <td rowspan="2">@row.IsActive</td>
                        <td>@row.CreatedAt</td>
                        <td rowspan="2">
                            <div class="d-grid gap-2 d-block d-xxl-inline">
                                <a class="btn btn-sm btn-outline-info" href="@row.EditURL">수정</a>
                                <input type="checkbox" name="ids[]" id="ids_@row.ID" class="form-check-input list-check-box" value="@row.ID" form="fAdminList" hidden />
                                <button type="button" class="btn btn-sm btn-outline-danger btn-row-delete" data-id="@row.ID">삭제</button>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>@row.ID</td>
                        <td>@row.MemberRows</td>
                        <td>@row.TotalDonationAmount</td>
                        <td>@row.UpdatedAt</td>
                    </tr>
                </tbody>
                }
            }
        </table>
    </div>
</div>

<!-- 삭제를 위한 -->
<form id="fAdminList" method="post" accept-charset="utf-8" asp-page-handler="Delete">
    @Html.AntiForgeryToken()
</form>