(ns auto-ap.client-routes)

(def routes ["/" {"" :index
                  "login" :login
                  "login/" :login
                  "needs-activation/" :needs-activation
                  "needs-activation" :needs-activation
                  "payments/" :payments
                  "admin/" {"vendors" :admin-vendors}
                  "vendor/" {"new" :new-vendor}
                  
                  "transactions/" {"" :transactions
                                   "unapproved" :unapproved-transactions
                                   "approved" :approved-transactions
                                   "requires-feedback" :requires-feedback-transactions
                                   "excluded" :excluded-transactions}
                  "reports/" {"" :reports}
                  "ledger/" {"" :ledger
                             "profit-and-loss" :profit-and-loss
                             "cash-flows" :cash-flows
                             "profit-and-loss-detail" :profit-and-loss-detail
                             "balance-sheet" :balance-sheet
                             "external" :external-ledger
                             "external-import" :external-import-ledger}}])

(defn all-handle-keys [routes]
  (let [vals (vals routes)
        result (filter keyword? vals)
        deeper (filter map? vals)]
    (apply concat result
           (map all-handle-keys deeper))))

(def all-matches (set (all-handle-keys (second routes))))
