Adds support for more than one email address.

This commit is contained in:
2022-03-24 15:45:49 -07:00
parent 5d17091847
commit 1e7f8f9b0a
9 changed files with 58 additions and 16 deletions

View File

@@ -223,20 +223,22 @@ Please download it by clicking this link: " report-url)))
(let [selected-clients (-> db ::forms/forms ::form :data :clients)
single-client? (= (count selected-clients)
1)
client-email (when single-client?
client-emails (when single-client?
(-> clients-by-id
(get (:id (first selected-clients)))
:email))]
:emails))]
{:dispatch [::modal/modal-requested {:title "Your report is ready"
:body [:div
[:div "Click "
[:a {:href (-> result :profit-and-loss-pdf :report-url) :target "_new"} "here"] " to view it."]
(when single-client?
(when (and single-client? (seq client-emails))
[:div "Once you've confirmed you're happy with it, click "
[:a {:href (str "mailto:" (or client-email "client@xyz.com") "?body=" (email-body (-> result :profit-and-loss-pdf :report-url)))}
"here"] " to open your email client and to send it to " (str (or client-email "client@xyz.com")) "."])]}]})))
[:a {:href (str "mailto:" (str/join ";" (map :email client-emails)) "?body=" (email-body (-> result :profit-and-loss-pdf :report-url)))}
"here"] " to open your email client and to send it to " (str/join "," (map (fn [e]
(str (:email e) " (" (:description e) ")"))
client-emails)) "."])]}]})))
(re-frame/reg-event-fx
::export-pdf
[with-user (forms/in-form ::form)]