fixing a number of bugs

This commit is contained in:
Bryce Covert
2018-04-08 14:46:23 -07:00
parent c5344a27eb
commit 9dabb633a7
15 changed files with 462 additions and 81 deletions

View File

@@ -2,6 +2,8 @@
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [re-frame.core :as re-frame]
[cljs-http.client :as http]
[cljs-time.coerce :as c]
[cljs-time.core :as time]
[cljs.core.async :refer [<!]]
[auto-ap.history :as p]
[pushy.core :as pushy]))
@@ -19,6 +21,16 @@
(.setItem js/localStorage name value)
(.removeItem js/localStorage name ))))
(defn dates->date-times [x]
(cond (map? x)
(into {} (map (fn [[k v]]
[k (if (instance? js/Date v)
(time/to-default-time-zone (c/from-date v))
v)])
x))
(list? x)
(map dates->date-times x)))
(re-frame/reg-fx
:http
(fn [{:keys [method uri on-success body headers token]}]
@@ -33,5 +45,6 @@
:url uri})
(<! )
:body
(dates->date-times)
(conj on-success)
(re-frame/dispatch))))))

View File

@@ -4,10 +4,13 @@
[reagent.core :as reagent]
[auto-ap.subs :as subs]
[auto-ap.events.admin.reminders :as events]
[auto-ap.views.utils :refer [login-url dispatch-value-change dispatch-event]]
[auto-ap.views.utils :refer [login-url dispatch-value-change dispatch-event date-time->str date->str]]
[cljs.reader :as edn]
[auto-ap.routes :as routes]
[bidi.bidi :as bidi]))
(defn reminders-table []
(let [reminders (or @(re-frame/subscribe [::subs/reminders]) [])]
[:table {:class "table", :style {:width "100%"}}
@@ -20,9 +23,9 @@
^{:key id}
[:tr
[:td vendor-name]
[:td (str scheduled)]
[:td (date->str scheduled)]
[:td (when sent
[:span [:span.icon [:i.fa.fa-check]] "Sent " (str sent)]) ]])]]))
[:span [:span.icon [:i.fa.fa-check]] "Sent " (date-time->str sent)]) ]])]]))
(defn admin-reminders-page []

View File

@@ -1,5 +1,6 @@
(ns auto-ap.views.utils
(:require [re-frame.core :as re-frame]))
(:require [re-frame.core :as re-frame]
[cljs-time.format :as format]))
(defn active-when= [active-page candidate]
(when (= active-page candidate) " active"))
@@ -18,3 +19,12 @@
(fn [e]
(.preventDefault e)
(re-frame/dispatch event)))
(def pretty-long (format/formatter "MM/dd/yyyy HH:mm:ss"))
(def pretty (format/formatter "MM/dd/yyyy"))
(defn date->str [d]
(format/unparse pretty d))
(defn date-time->str [d]
(format/unparse pretty-long d))