diff --git a/lib/algora_web/live/org/bounties_live.ex b/lib/algora_web/live/org/bounties_live.ex
index 9dccffbd2..d26f14a90 100644
--- a/lib/algora_web/live/org/bounties_live.ex
+++ b/lib/algora_web/live/org/bounties_live.ex
@@ -220,7 +220,10 @@ defmodule AlgoraWeb.Org.BountiesLive do
<% end %>
-
+
<.button
phx-click="edit-bounty-amount"
phx-value-id={bounty.id}
@@ -415,7 +418,7 @@ defmodule AlgoraWeb.Org.BountiesLive do
def handle_event("delete-bounty", %{"id" => bounty_id}, socket) do
cond do
- socket.assigns.current_user_role in [:admin, :mod] ->
+ can_manage_bounties?(socket.assigns.current_user_role) ->
bounty =
Bounty
|> Repo.get(bounty_id)
@@ -475,7 +478,7 @@ defmodule AlgoraWeb.Org.BountiesLive do
def handle_event("edit-bounty-amount", %{"id" => bounty_id}, socket) do
cond do
- socket.assigns.current_user_role in [:admin, :mod] ->
+ can_manage_bounties?(socket.assigns.current_user_role) ->
[bounty] = Bounties.list_bounties(id: bounty_id)
changeset = edit_amount_changeset(%{amount: bounty.amount})
@@ -706,4 +709,6 @@ defmodule AlgoraWeb.Org.BountiesLive do
assign(socket, :bounty_rows, to_bounty_rows(bounties))
end
+
+ defp can_manage_bounties?(role), do: role in [:admin, :mod]
end
|