<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<ul class="project-list">
    <c:forEach var="project" items="${projects}">
        <li class="project">
            <div class="panel panel-info">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        <span class="project-name">${project.name}</span>
                        <span class="delete-project glyphicon glyphicon-trash"></span>
                    </h3>
                </div>

                <table class="table project-info">
                    <tr>
                        <td>Created by</td>
                        <td>${project.createdBy}</td>
                    </tr>

                    <tr>
                        <td>Created date</td>
                        <td><fmt:formatDate value="${project.createdDate}" pattern="dd MMM yyyy" /></td>
                    </tr>

                    <tr>
                        <td>Last open date</td>
                        <td><fmt:formatDate value="${project.lastOpenDate}" pattern="dd MMM yyyy" /></td>
                    </tr>

                    <tr>
                        <td></td>

                        <td>
                            <c:if test="${project.name eq cookie['currentProject'].value or project.name eq currentProject}">
                                <button type="button" class="btn btn-success btn-sm load-project-btn" >
                                    Project loaded
                                </button>
                            </c:if>

                            <c:if test="${project.name ne cookie['currentProject'].value and project.name ne currentProject}">
                                <button type="button" class="btn btn-secondary btn-sm load-project-btn" >
                                    Load project
                                </button>
                            </c:if>

                            <button type="button" class="btn btn-danger btn-sm unfollow-project-btn" >
                                Unfollow
                            </button>
                        </td>
                    </tr>
                </table>
            </div>
        </li>
    </c:forEach>
</ul>