             [salava.core.i18n :refer [t]]
             [salava.metabadge.ui.metabadge :as mb]
             [salava.core.ui.modal :as mo]
-            [salava.core.time :refer [date-from-unix-time]]))
+            [salava.core.time :refer [date-from-unix-time]]
+            [salava.core.ui.error :as err]
+            [salava.badge.ui.modal :refer []]))
 
 (defn current-badge [metabadge]
   (let [{:keys [milestone? required_badges badge]} (-> metabadge first)]

(def ^:export modalroutes
  {:metabadge {:metadata handler
               :multiblock multi-block
               :dummy dummy-badge}})

         :aria-valuemax "100"}
        (str completed "%")]]]
     [:div.col-md-9
      [:div.col-md-12
       [:h1.uppercase-header (:name metabadge)]
       [:div.description (:description badge)]
       [:div {:style {:margin-top "10px"}}[:label (str (t :metabadge/Minimumrequired) ": ")] min_required]
       [:div [:label (str (t :metabadge/Amountearned)": ")] amount_received]
       [:div.panel
        [:div.panel-body
         [:div.panel-heading [:span [:i {:class "fa fa-puzzle-piece"}] (if (empty? (rest required_badges)) (t :metabadge/Requiredbadge) (t :metabadge/Requiredbadges))]]
         [:hr]
         [:div.icons
          (reduce (fn [result badge]
                    (let [{:keys [badge-info received current user_badge]} badge
                          {:keys [name image criteria]} badge-info
                          {:keys [id issued_on status]} user_badge]
                      (conj result
                            (if received
                              (if (= "declined" status)
                                [:a {:href "#" :on-click #(mo/open-modal [:metabadge :declined] badge)} [:img.img-circle {:src image :alt name :title name :class (if current "img-thumbnail" "")}]]
                                [:a {:href "#" :on-click #(mo/open-modal [:badge :info] {:badge-id id})} [:img.img-circle {:src image :alt name :title name :class (if current "img-thumbnail" "")}]])
                              [:a {:href "#" :on-click #(mo/open-modal [:metabadge :dummy] badge)}
                               [:img.not-received.img-circle {:src image :alt name :title name} ]]))
                      )) [:div] (sort-by :received required_badges))]]]
       [:div {:class "row criteria-html"}
        [:div.col-md-12
         [:h2.uppercase-header (t :badge/Criteria)]
         [:div {:dangerouslySetInnerHTML {:__html (:criteria badge)}}]]]
       ]]]))

(defn history [metabadge]
  (let [{:keys [badge required_badges milestone? min_required]} metabadge
