(ns auto-ap.views.components.invoices.side-bar
  (:require [re-frame.core :as re-frame]
            [reagent.core :as r]
            [clojure.string :as str]
            [clojure.spec.alpha :as s]
            [cljs-time.core :as c]
            [goog.string :as gstring]
            [bidi.bidi :as bidi]
            [auto-ap.routes :as routes]
            [auto-ap.views.utils :refer [active-when dispatch-event bind-field horizontal-field date->str str->date pretty standard]]
            [auto-ap.subs :as subs]
            [auto-ap.events :as events]))

(defn invoices-side-bar [params & rest]
  (let [ap @(re-frame/subscribe [::subs/active-page])
        user @(re-frame/subscribe [::subs/user])]
    [:div
    [:div [:p.menu-label "Type"]
     [:ul.menu-list
      [:li.menu-item
       [:a.item {:href (bidi/path-for routes/routes :unpaid-invoices)
                 :class [(active-when ap = :unpaid-invoices)]}
        [:span {:class "icon icon-accounting-invoice-mail" :style {:font-size "25px"}}]
        [:span {:class "name"} "Unpaid Invoices"]]]
      [:li.menu-item
       [:a.item {:href (bidi/path-for routes/routes :paid-invoices)
                 :class [(active-when ap = :paid-invoices)]}

        [:span {:class "icon icon-check-payment-give" :style {:font-size "25px"}}]
        
        [:span {:class "name"} "Paid Invoices"]]]
      [:li.menu-item
       [:a.item {:href (bidi/path-for routes/routes :voided-invoices)
                 :class [(active-when ap = :voided-invoices)]}

        [:span {:class "icon icon-bin-2" :style {:font-size "25px"}}]
        
        [:span {:class "name"} "Voided Invoices"]]]
      (when (= "admin" (:user/role user))
        [:li.menu-item
         [:a.item {:href (bidi/path-for routes/routes :import-invoices)
                   :class [(active-when ap = :import-invoices)]}

          [:span {:class "icon icon-accounting-document" :style {:font-size "25px"}}]
          
          [:span {:class "name"} "Import Invoices"]]])]]
    [:div
     rest]
    [:div {:class "compose has-text-centered"}
     [:a {:class "button is-danger is-block is-bold" #_#_:href (bidi/path-for routes/routes :index)
          :on-click (dispatch-event [::events/modal-status :auto-ap.views.main/user-editing-vendor {:visible? true}])}
      [:span {:class "compose"} "New Vendor"]]]]))
