@extends('admin.layouts.app')

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

    <div class="row mb-2">
        <div class="col align-self-center">
            <label>전체 : {{ $boardAdminData->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/board/manager/destroy">선택삭제</button>
        </div>
    </div>

    <form name="f_admin_list" id="fAdminList" method="post">
        @csrf
        <input type="hidden" name="board_id" value="{{ $boardID }}" />
        <div class="table-responsive">
            <table class="table table-hover table-bordered table-nowrap">
                <thead>
                    <tr>
                        <th><input type="checkbox" name="chk_all" id="chkAll" class="form-check-input" value="1"/></th>
                        <th>번호</th>
                        <th>ID</th>
                        <th>이름</th>
                        <th>닉네임</th>
                        <th>이메일</th>
                        <th>등록일시</th>
                    </tr>
                </thead>
                <tbody>
                    @if($boardAdminData->rows > 0)
                        @foreach($boardAdminData->list as $i => $row)
                        <tr>
                            <td>
                                <input type="checkbox" name="chk[]" id="chk_{{ $row->id }}" class="form-check-input list-check-box" value="{{ $row->id }}" />
                            </td>
                            <td>{{ ++$i }}</td>
                            <td>{{ $row->sid }}</td>
                            <td>{{ $row->email }}</td>
                            <td>{{ $row->name ?? '-' }}</td>
                            <td>{{ $row->nickname ?? '-' }}</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" class="form-control" value="" placeholder="회원 ID를 입력해주세요."/>
                    <input type="hidden" name="board_id" value="{{ $boardID }}" />
                    <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
