             [salava.core.i18n :refer [t]]
             [salava.core.helper :refer [dump]]
             [salava.admin.ui.helper :refer [message-form email-select status-handler]]
-            [salava.core.time :refer [date-from-unix-time]]))
+            [salava.core.time :refer [date-from-unix-time]]
+            [salava.admin.ui.admintool :refer [open-admintool-modal]]))
 
 (defn text-shorter [text length]
   (let [sorted-text (subs text 0 (min (count text) length))

                     :init-data init-data
                     :status ""})]
    (ajax/GET
     (path-for (str "/obpv1/admin/user/" user-id))
     {:handler (fn [data]
                 (do
                   (let [primary-email (first (filter #(:primary_address %) (get-in data [:info :emails])))]
                     (swap! state assoc :name (:name data)
                            :image_file (:image_file data)
                            :user (:item_owner data)
                            :user_id (:item_owner_id data)
                            :selected-email (:email primary-email)
                            :info (:info data))))
                 (m/modal! [ticket-modal state init-data]))})))



(defn ticket [ticket-data state]

                 :on-click #(do
                              (.preventDefault %)
                              (ajax/POST
                                (path-for (str "/obpv1/admin/close_ticket/" id))
                                {:response-format :json
                                 :keywords? true
                                 :params {:new-status (if open? "closed" "open")}
                                 :handler (fn [data]
                                            (if open?
                                              (init-data state)
                                              (get-closed-tickets state))
                                            )
                                 :error-handler (fn [{:keys [status status-text]}])}))}
        (if open? (t :admin/Done) (t :admin/Restore))]]]]))

(defn ticket-visible? [element state]
  (if (or (> (count
               (intersection
                 (into #{} (:types-selected @state))
                 #{(:report_type element)}))
             0)
          (= (:types-all @state)
             true))
