 (defn matches-query?
   [search-input course]
   (let [matches-input? (fn [key]
-                         (re-find (re-pattern (s/lower-case search-input))
-                                  (s/lower-case (key course))))]
+                         (re-find (re-pattern (string/lower-case search-input))
+                                  (string/lower-case (apply str (val course)))))]
     (if (= "" search-input)
       true
       (or (matches-input? :name)

 (fn [db]
   (reaction (:courses @db))))

#_(def db
    (clojure.edn/read-string (slurp "resources/db/db2015-1R.edn")))

(re-frame/register-handler
 :initialise-db
 (fn
   [_ _]
   {:courses [{:name "Beginner CSS" :number "CSS101" :time "Mon(2) Wed(2)"
               :credits "3" :type "Elective" :prof "Prof. A"}
              {:name "Intermediate CSS" :number "CSS201" :time "Tue(5) Thu(5)"
               :credits "3" :type "Elective" :prof "Prof. B"}
              {:name "Advanced Javascript" :number "JS406" :time "Mon(6) Wed(6)"
               :credits "3" :type "Major" :prof "Prof. C"}
              {:name "ClojureScript" :number "CLJS303" :time "Fri(1,2)"
               :credits "3" :type "Major" :prof "Prof. D"}
              {:name "Clojure" :number "CLJ505" :time "Tue(3,4) Thu(3,4)"
               :credits "3" :type "Major" :prof "Prof. D"}
              {:name "How to Train Your Dragon" :number "DR505" :prof "Prof. E"
               :time "Tue(7) Thu(7)" :credits "3" :type "Elective"}]
    :search-input ""}))

(defn handle-search-input-entered

    (fn []
      [:form {:style {:margin-bottom "1rem"}}
       [:div.row
        [:div {:class "five columns"}
         [:label {:for "search-courses"} "Course Search"]
         [:input.u-full-width
          {:id "search-courses"
           :type "search"
           :on-change #(re-frame/dispatch
                        [:search-input-entered (-> % .-target .-value)])
           :placeholder "Course ID, Title, Professor, etc..."}]]]])))

(defn course-component
  "Individual course in search result list"
  [course]
  [:li [:a (str
            (get-in (val course) [:kr :name])
            (get-in (val course) [:kr :number])
            (get-in (val course) [:kr :professor])
            (apply str (get-in (val course) [:kr :schedule]))
            (get-in (val course) [:kr :credit-hours])
            (get-in (val course) [:kr :classification]))]])

(defn courses-component
  []
