(ns wanijo.instance.view.starred
  (:require [hiccup.core :refer [h]]
            [wanijo.infrastructure.view :as view]
            [wanijo.infrastructure.routing :refer [path]]
            [wanijo.infrastructure.time :refer [prettify-dt]]))

(defn starred [instances req]
  (view/layout
    :request req
    :content
    [[:h1 "Starred instances"]
     [:table
      [:thead
       [:tr
        [:th "Name"]
        [:th "Starred"]
        [:th "Updated"]
        [:th "Created"]]]
      [:tbody
       (for [instance instances]
         [:tr
          [:td
           [:a {:href (path :instance-show instance)}
            (h (:name instance))]]
          [:td (prettify-dt (:starred_at instance))]
          [:td (prettify-dt (:updated_at instance))]
          [:td (prettify-dt (:created_at instance))]])]]]))
