@extends('desktop.layouts.app')

@section('content')
<div id="accountComment" class="container">
    @include('desktop.account.navTabs')

    <h4>작성 댓글</h4>
    <hr/>

    <div class="row g-2 mb-2 align-items-center">
        <div class="col">
            <span>Total : {{ $comments->total }}</span>
        </div>
        <div class="col-auto">
            <button type="button" id="btnAccountCommentDelete" class="btn btn-dark">선택삭제</button>
        </div>
        <div class="col-auto text-end">
            <select name="per_page" id="perPage" class="form-select">
                <option value="10" @if($params->perPage == 10) selected @endif>10개씩</option>
                <option value="15" @if($params->perPage == 15) selected @endif>15개씩</option>
                <option value="20" @if($params->perPage == 20) selected @endif>20개씩</option>
                <option value="30" @if($params->perPage == 30) selected @endif>30개씩</option>
                <option value="40" @if($params->perPage == 40) selected @endif>40개씩</option>
                <option value="50" @if($params->perPage == 50) selected @endif>50개씩</option>
            </select>
        </div>
    </div>

    <table class="table table-bordered table-hover">
        <colgroup>
            <col width="4%"/>
            <col width="70px"/>
            <col width="*"/>
            <col width="130px"/>
            <col width="70px"/>
            <col width="70px"/>
        </colgroup>
        <thead>
            <tr>
                <th>
                    <input type="checkbox" name="chk_all" id="chkAll" class="form-check-input" value="1"/>
                </th>
                <th>번호</th>
                <th>댓글</th>
                <th>작성일시</th>
                <th>추천</th>
                <th>비추천</th>
            </tr>
        </thead>
        <tbody>
        @if($comments->total > 0)
            @foreach($comments->list as $row)
            <tr id="comment_{{ $row->num }}">
                <td>
                    <input type="checkbox" name="chk[]" class="form-check-input list-check-box" value="{{ $row->id }}"/>
                </td>
                <td>{{ $row->num }}</td>
                <td>
                    <p>
                        <a href="{{ $row->viewURL }}?id={{ $row->id }}&page={{ $row->page }}" hreflang="ko" referrerpolicy="origin" type="text/html" target="_self">
                            @if($row->is_secret)
                                <i class="fas fa-lock"></i> {!! $row->content !!}
                            @elseif($row->isBlame)
                                <i class="fas fa-ban"></i> <del>{!! $row->content !!}</del>
                            @else
                                {!! $row->content !!}
                            @endif
                        </a>
                    </p>
                    <p>
                        <a href="{{ $row->viewURL }}" hreflang="ko" referrerpolicy="origin" type="text/html" target="_self">
                            {{ $row->subject }}
                        </a>
                        @if($row->comment_rows > 0)
                            <var>[{{ $row->comment_rows }}]</var>
                        @endif
                        @if($row->file_rows > 0)
                            <i class="fas fa-save"></i>
                        @endif
                        @if($row->link_rows > 0)
                            <i class="fas fa-external-link-alt"></i>
                        @endif
                        @if($row->image_rows > 0)
                            <i class="fas fa-image"></i>
                        @endif
                    </p>
                </td>
                <td>{{ $row->createdAt }}</td>
                <td>{{ $row->like }}</td>
                <td>{{ $row->dislike }}</td>
            </tr>
            @endforeach
        @else
            <tr>
                <td colspan="6" class="p-5">
                    작성 댓글이 없습니다.
                </td>
            </tr>
        @endif
        </tbody>
    </table>

    @if($comments->total > 0)
    <div class="pagination">
        {{ $comments->list->onEachSide($params->pageCount)->links('component.pagination') }}
    </div>
    @endif

    <form name="f_account_comment" id="fAccountComment" method="post" action="{{ route('account.comment') }}" autocomplete="off" accept-charset="UTF-8">
        @csrf
        <input type="hidden" name="per_page" value="{{ $params->perPage }}"/>
    </form>
</div>
@endsection

@push('styles')
    <link rel="stylesheet" href="{{ asset('css/desktop/account/comment.css') }}"/>
@endpush

@push('scripts')
    <script src="{{ asset('js/account/comment.js') }}" defer></script>
@endpush
