From 4313c45870d842b6f65a6258ef08098c60b687f5 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 27 Mar 2023 13:17:30 +0200 Subject: [PATCH] :bug: Fix sending invitation to existing members --- backend/src/app/rpc/commands/teams.clj | 8 +++++++- frontend/src/app/main/ui/dashboard/team.cljs | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/src/app/rpc/commands/teams.clj b/backend/src/app/rpc/commands/teams.clj index 2d6f6e22e..483f94266 100644 --- a/backend/src/app/rpc/commands/teams.clj +++ b/backend/src/app/rpc/commands/teams.clj @@ -729,8 +729,13 @@ (let [perms (get-permissions conn profile-id team-id) profile (db/get-by-id conn :profile profile-id) team (db/get-by-id conn :team team-id) - emails (cond-> (or emails #{}) (string? email) (conj email))] + ;; Members emails. We don't re-send inviation to already existing members + member? (into #{} + (map :email) + (db/exec! conn [sql:team-members team-id])) + + emails (cond-> (or emails #{}) (string? email) (conj email))] (run! (partial quotes/check-quote! conn) (list {::quotes/id ::quotes/invitations-per-team @@ -754,6 +759,7 @@ (let [cfg (assoc cfg ::db/conn conn) invitations (->> emails + (remove member?) (map (fn [email] {:email (str/lower email) :team team diff --git a/frontend/src/app/main/ui/dashboard/team.cljs b/frontend/src/app/main/ui/dashboard/team.cljs index adbc6b0f8..1df6d70ee 100644 --- a/frontend/src/app/main/ui/dashboard/team.cljs +++ b/frontend/src/app/main/ui/dashboard/team.cljs @@ -177,7 +177,9 @@ :on-submit on-submit}]] [:div.action-buttons - [:& fm/submit-button {:label (tr "modals.invite-member-confirm.accept")}]]]])) + [:& fm/submit-button {:label (tr "modals.invite-member-confirm.accept") + :disabled (and (boolean (some current-data-emails current-members-emails)) + (empty? (remove current-members-emails current-data-emails)))}]]]])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; MEMBERS SECTION