<!DOCTYPE html>
<html lang="ko"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layout/layout}">
<th:block layout:fragment="script">
  <script type="text/javascript" th:src="@{/js/board/contentList.js}"></script>
</th:block>
<div layout:fragment="content" class="pt-3">
  <main class="pt-3">
  <h4>사용자 메인 페이지</h4>
    <div class="row mx-0">
      <div class="col-12 card">
        <div class="card-body">
          <div class="row justify-content-start">
            <div class="col-7">
              <div class="row-cols-6">
                <table class="table table-striped table-hover">
                  <thead>
                  <tr>
                    <th></th>
                    <th>제목</th>
                    <th>파일 수</th>
                    <th>작성자</th>
                    <th>작성일</th>
                    <th>조회수</th>
                  </tr>
                  </thead>
                  <tbody>
                  <th:block th:each="content:${contentList}">
                    <tr class="categoryTr" th:data-categoryseq="${content.categorySeq}">
                      <td class="p-0 fs-6" colspan="7" th:text="${content.categoryName}"></td>
                    </tr>
                    <tr class="contentTr">
                      <td>
                        <input type="checkbox" class="contentCheckBox" th:value="${content.contentSeq}">
                      </td>
                      <td th:text="${content.title}"></td>
                      <td th:text="${content.fileCnt}"></td>
                      <td th:text="${content.createName}"></td>
                      <th:block th:if="${#dates.format(#dates.createNow(), 'yyyy-MM-dd')} == ${#temporals.format(content.createDate, 'yyyy-MM-dd')}">
                        <td th:text="${#temporals.format(content.createDate, 'HH:mm:ss')}"></td>
                      </th:block>
                      <th:block th:if="${#dates.format(#dates.createNow(), 'yyyy-MM-dd')} != ${#temporals.format(content.createDate, 'yyyy-MM-dd')}">
                        <td th:text="${#temporals.format(content.createDate, 'yyyy-MM-dd')}"></td>
                      </th:block>
                      <td class="viewCntTd" th:text="${content.viewCnt}"></td>
                    </tr>
                  </th:block>
                  </tbody>
                </table>
              </div>
              <div class="row justify-content-center">
                <div class="col-auto">
                  <nav aria-label="Page navigation">
                    <ul class="pagination">
                      <th:block th:if="${searchParams.pageIndex>3}">
                        <li class="page-item" th:data-pageindex="${(searchParams.pageIndex)-3}">
                          <a class="page-link" href="#" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                          </a>
                        </li>
                      </th:block>
                      <th:block th:each="num : ${#numbers.sequence(searchParams.startNum, searchParams.endNum)}">
                        <li class="page-item" th:data-pageindex="${num}" th:classappend="${searchParams.pageIndex==num?'active':''}">
                          <a class="page-link" href="#" th:text="${num}"></a>
                        </li>
                      </th:block>
                      <th:block th:if="${searchParams.maxNum>searchParams.endNum+2}">
                        <li class="page-item" th:data-pageindex="${(searchParams.pageIndex)+3}">
                          <a class="page-link" href="#" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                          </a>
                        </li>
                      </th:block>
                    </ul>
                  </nav>
                </div>
              </div>
            </div>
            <div class="col-5">
              <ul class="nav nav-tabs" id="boardTab" role="tablist">
                <li class="nav-item" role="presentation">
                  <button class="nav-link active" id="contentTab" data-bs-toggle="tab" data-bs-target="#contentDiv" type="button" role="tab">내용</button>
                </li>
                <li class="nav-item" role="presentation">
                  <button class="nav-link" id="logTab" data-bs-toggle="tab" data-bs-target="#logDiv" type="button" role="tab">이력</button>
                </li>
              </ul>
              <div class="tab-content border border-top-0" id="boardDiv">
                <div class="tab-pane fade show active" id="contentDiv" role="tabpanel" aria-labelledby="contentTab">
                  <div class="py-5 text-center">
                    <h3>왼쪽 목록에서 선택해주세요.</h3>
                  </div>
                </div>
                <div class="tab-pane fade" id="logDiv" role="tabpanel" aria-labelledby="logTab">
                  <div class="py-5 text-center">
                    <h3>왼쪽 목록에서 선택해주세요.</h3>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </main>
</div>
</html>