(ns auto-ap.views.pages.paid-invoices (:require [re-frame.core :as re-frame] [auto-ap.subs :as subs] [auto-ap.events :as events])) (def paid-invoices-page (with-meta (fn [] (let [invoices (re-frame/subscribe [::subs/unpaid-invoices]) status (re-frame/subscribe [::subs/status])] [:div [:h1.title "Paid invoices"] (if (:loading @status) [:div [:h1.title [:i.fa.fa-spin.fa-spinner]]] [:table {:class "table", :style {:width "100%"}} [:thead [:tr [:th "Vendor"] [:th "Customer"] [:th "Invoice #"] [:th "Date"] [:th "Amount"]]] [:tbody (for [{:keys [company invoice-number date total id vendor] :as i} @invoices] ^{:key (str company "-" invoice-number "-" date "-" total "-" id)} [:tr [:td (:name vendor)] [:td (:name company)] [:td invoice-number] [:td date] [:td total]])]])])) {:component-will-mount #(re-frame/dispatch-sync [::events/view-unpaid-invoices]) }))