(ns auto-ap.client-routes)

(def routes ["/" {"" :index
                  "login" :login
                  "login/" :login
                  "needs-activation/" :needs-activation
                  "needs-activation" :needs-activation
                  "payments/" :payments
                  "admin/" {"" :admin
                            "clients/" {"" :admin-clients
                                        [:id] {"" :admin-specific-client
                                               "/bank-accounts/" {[:bank-account] :admin-specific-bank-account}}}
                            "users" :admin-users
                            "rules" :admin-rules
                            "accounts" :admin-accounts
                            "import-batches" :admin-import-batches
                            "jobs" :admin-jobs
                            "vendors" :admin-vendors
                            "excel-import" :admin-excel-import
                            }
                  "invoices/" {""  :invoices
                               "import" :import-invoices
                               "unpaid" :unpaid-invoices
                               "paid" :paid-invoices
                               "voided" :voided-invoices
                               "new" :new-invoice}
                  "pos/" {"sales-orders"  :sales-orders
                          "expected-deposits" :expected-deposits}
                  "transactions/" {"" :transactions
                                   "unapproved" :unapproved-transactions
                                   "approved" :approved-transactions
                                   "requires-feedback" :requires-feedback-transactions
                                   "excluded" :excluded-transactions}
                  "reports/" {"" :reports}
                  "company/" {"other" :company-other
                              "export-vendors" :company-export-vendors}
                  "plaid" :plaid
                  "yodlee2" :yodlee2
                  "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))))
