<section class="full-center">
    <aside>
        <form class="content-grid columns4 toggle" action="/toggleCompleted" method="post" >
            <input type="hidden" name="path" value="/" />
            <label class="grid-item label" for="Toggle Style">Toggle Completed:</label>
            <label class="switch grid-item">
                <input type="checkbox" name="Toggle Completed" onchange="this.form.submit()" {{#if filterCompleted}} checked {{/if}}>
                <span class="slider"></span>
            </label>
        </form>
    </aside>
    <div>
        <form action='/add' method='get'>
            <input type='submit' value='Add Boulder Routes' autofocus/>
        </form>
    </div>
    <div>
        <p class="sort">Sort by: </p>
        <p class="content-grid columns3 sort">
            <a href="/sortByTitle" class="item grid-item">Title
                {{#if_eq orderBy "boulderRouteTitle"}}
                    {{sortOrderLookup orderDirection}}
            </a>
                {{/if_eq}}
            <a href="/sortByCreationDate" class="item grid-item">Date Created
                {{#if_eq orderBy "boulderRouteCreated"}}
                    {{sortOrderLookup orderDirection}}
                {{/if_eq}}
            </a>
            <a href="/sortByDifficulty" class="item grid-item">Difficulty
                {{#if_eq orderBy "routeDifficulty"}}
                    {{sortOrderLookup orderDirection}}
                {{/if_eq}}
            </a>
        </p>
    </div>
</section>
<section class="full-center flex">
        {{#each boulderRoutes}}
            <div class="flip-card">
                <a href="/{{this._id}}" class="item flip-card-inner {{#if this.boulderRouteDone}}content-completed{{/if}}">
                    <div class="flip-card-front">
                        <img src="./img/{{this.imgName}}" alt={{this.boulderRouteTitle}}/>
                    </div>
                    <div class="flip-card-back">
                        <form class="toggle" action="/add/{{this._id}}/" method="post" >
                            <label for="done">
                                <input type="checkbox" name="done" onchange="this.form.submit()" {{#if this.boulderRouteDone}}checked{{/if}} />
                                {{#if this.boulderRouteDone}}Completed!{{else}}Open{{/if}}
                            </label>
                        </form>
                        <h2>{{this.boulderRouteTitle}}</h2>
                        <div>{{difficultyLookup routeDifficulty}}</div>
                        <p>{{this.boulderRouteDescription}}</p>
                        
                    </div>
                </a>
            </div>
        {{else}}
            <div class=" flex">
                <p>No routes here! {{#if filterCompleted}} You completed every Route, well done!! 🥳🥳{{else}} Sorry, No Routes here, jet... {{/if}}</p>
            </div>
            <footer>
                {{#if filterCompleted}} 
                <img src="./img/boulder-win.gif" width="300px" alt="for good measure"/>
                {{else}}
                <img src="./img/boulder-fail.gif" width="300px" alt="for good measure"/>
                {{/if}}
            </footer>
        {{/each}}
</section>
