Skip to content

Commit cf075de

Browse files
committed
fix: update total awarded subtext in organization home live view to fit in a line
1 parent c67903e commit cf075de

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/algora_web/live/org/home_live.ex

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ defmodule AlgoraWeb.Org.HomeLive do
2424
stats = Bounties.fetch_stats(org_id: org.id, current_user: socket.assigns[:current_user])
2525
transactions = Payments.list_hosted_transactions(org.id, limit: page_size())
2626

27+
total_awarded_subtext =
28+
[
29+
"#{stats.rewarded_bounties_count} #{ngettext("bounty", "bounties", stats.rewarded_bounties_count)}",
30+
if stats.rewarded_tips_count > 0 do
31+
"#{stats.rewarded_tips_count} #{ngettext("tip", "tips", stats.rewarded_tips_count)}"
32+
end,
33+
if stats.rewarded_contracts_count > 0 do
34+
"#{stats.rewarded_contracts_count} #{ngettext("contract", "contracts", stats.rewarded_contracts_count)}"
35+
end
36+
]
37+
|> Enum.reject(&is_nil/1)
38+
|> Enum.join(" / ")
39+
2740
socket =
2841
socket
2942
|> assign(:org, org)
@@ -32,6 +45,7 @@ defmodule AlgoraWeb.Org.HomeLive do
3245
|> assign(:transactions, transactions)
3346
|> assign(:top_earners, top_earners)
3447
|> assign(:stats, stats)
48+
|> assign(:total_awarded_subtext, total_awarded_subtext)
3549

3650
{:ok, socket}
3751
end
@@ -79,7 +93,7 @@ defmodule AlgoraWeb.Org.HomeLive do
7993
<.stat_card
8094
title="Total Awarded"
8195
value={Money.to_string!(@stats.total_awarded_amount)}
82-
subtext={"#{@stats.rewarded_bounties_count} #{ngettext("bounty", "bounties", @stats.rewarded_bounties_count)} / #{@stats.rewarded_tips_count} #{ngettext("tip", "tips", @stats.rewarded_tips_count)} / #{@stats.rewarded_contracts_count} #{ngettext("contract", "contracts", @stats.rewarded_contracts_count)}"}
96+
subtext={@total_awarded_subtext}
8397
navigate={~p"/#{@org.handle}/bounties?status=completed"}
8498
icon="tabler-gift"
8599
/>

0 commit comments

Comments
 (0)