@extends('admin.layouts.app')

@section('content')
<div class="container-fluid">
    <h2>게시판 그룹 관리 - 관리자</h2>
    <hr/>
    @include('admin.messages')
    @if($boardGroupID)
        @include('admin.board.group.navTabs')
    @endif

    <div class="row mb-2">
        <div class="col align-self-center">
            <label>전체 : {{ $boardGroupAdminData->rows }}</label>
        </div>
        <div class="col text-end">
            <button type="button" class="btn btn-outline-dark btn-list-delete btn-list-selected disabled" data-list-delete-url="/admin/board/group/manager/destroy">선택삭제</button>
        </div>
    </div>

    <form name="f_admin_list" id="fAdminList" method="post">
        @csrf
        <input type="hidden" name="board_group_id" id="boardGroupID" value="{{ $boardGroupID }}" />
        <div class="table-responsive">
            <table class="table table-hover table-bordered table-nowrap">
                <colgroup>
                    <col width="1%" />
                    <col width="3%" />
                    <col width="*" />
                    <col width="20%" />
                </colgroup>
                <thead>
                    <tr>
                        <th><input type="checkbox" name="chk_all" id="chkAll" class="form-check-input" value="1"/></th>
                        <th>PK</th>
                        <th>ID</th>
                        <th>이름</th>
                        <th>닉네임</th>
                        <th>이메일</th>
                        <th>등록일시</th>
                    </tr>
                </thead>
                <tbody>
                    @if($boardGroupAdminData->rows > 0)
                        @foreach($boardGroupAdminData->list as $row)
                        <tr>
                            <td>
                                <input type="checkbox" name="chk[]" id="chk_{{ $row->id }}" class="form-check-input list-check-box" value="{{ $row->id }}" />
                            </td>
                            <td>{{ $row->id }}</td>
                            <td>{{ $row->sid }}</td>
                            <td>{{ $row->name ?? '-' }}</td>
                            <td>{{ $row->nickname ?? '-' }}</td>
                            <td>{{ $row->email }}</td>
                            <td>{{ $row->created_at }}</td>
                        </tr>
                        @endforeach
                    @else
                        <tr>
                            <td colspan="7">
                                No data.
                            </td>
                        </tr>
                    @endif
                </tbody>
            </table>
        </div>
    </form>

    <form name="f_admin_write" id="fAdminWrite" method="post" action="{{ $actionURL }}">
        @csrf
        <div class="row">
            <label for="sid" class="col-auto col-form-label">회원 ID</label>
            <div class="col-sm-4">
                <div class="input-group">
                    <input type="text" name="sid" id="sid" class="form-control" placeholder="회원 ID를 입력해주세요."/>
                    <input type="hidden" name="board_group_id" id="boardGroupID" value="{{ $boardGroupID }}" />
                    <button type="submit" class="btn btn-success btn-sm">추가하기</button>
                </div>
            </div>
        </div>
    </form>
</div>

<script type="module">
$("#fAdminWrite").validate({
    rules: {
        sid: {required: true}
    }
});
</script>
@endsection
