(ns lineup.components.schedule.slot
  (:require
   [lineup.events :as events]
   [re-com.core :as re-com]
   [re-frame.core :as re-frame]))

(defn- corner [index task]
  (if (:complete? task)
    [:i
     {:class "zmdi zmdi-check-circle zmdi-hc-3x slot-corner complete"}]
    [:div
     {:class "slot-corner number"}
     (inc index)]))

(defn slot [index task]
  [re-com/box
   :width "300px"
   :height "300px"
   :class "slot"
   :style {:border-color (if (:complete? task) "green" "black")}
   :align :center
   :justify :center
   :attr {:on-click #(re-frame/dispatch [::events/toggle-task-complete index])}
   :child
   [:div
    [re-com/v-box
     :align :center
     :children
     [[re-com/box
       :width "200px"
       :height "200px"
       :max-width "200px"
       :max-height "200px"
       :justify :center
       :style {:flex-flow "revert"}
       :child
       [:img
        {:src (:image task)}]]
      [re-com/title
       :label (:name task)
       :level :level2]]]
    [corner index task]]])
