Skip to content

Commit d8f7182

Browse files
committed
feat: showcase most recent >$500 transactions on homepage hero
1 parent cb4ec72 commit d8f7182

File tree

1 file changed

+106
-4
lines changed

1 file changed

+106
-4
lines changed

lib/algora_web/live/home_live.ex

Lines changed: 106 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@ defmodule AlgoraWeb.HomeLive do
5555
featured_devs = Accounts.list_featured_developers()
5656
featured_collabs = list_featured_collabs()
5757

58+
transactions =
59+
Repo.all(
60+
from tx in Transaction,
61+
where: tx.type == :credit,
62+
where: not is_nil(tx.succeeded_at),
63+
where:
64+
fragment(
65+
"? >= ('USD', 500)::money_with_currency",
66+
tx.net_amount
67+
),
68+
join: u in assoc(tx, :user),
69+
join: b in assoc(tx, :bounty),
70+
join: t in assoc(b, :ticket),
71+
join: r in assoc(t, :repository),
72+
join: o in assoc(r, :user),
73+
join: ltx in assoc(tx, :linked_transaction),
74+
join: ltx_user in assoc(ltx, :user),
75+
select_merge: %{
76+
user: u,
77+
bounty: %{b | ticket: %{t | repository: %{r | user: o}}},
78+
linked_transaction: %{ltx | user: ltx_user}
79+
},
80+
order_by: [desc: tx.succeeded_at],
81+
limit: 5
82+
)
83+
5884
case socket.assigns[:current_user] do
5985
nil ->
6086
{:ok,
@@ -75,7 +101,8 @@ defmodule AlgoraWeb.HomeLive do
75101
|> assign(:total_countries, total_countries)
76102
|> assign(:selected_developer, nil)
77103
|> assign(:share_drawer_type, nil)
78-
|> assign(:show_share_drawer, false)}
104+
|> assign(:show_share_drawer, false)
105+
|> assign(:transactions, transactions)}
79106

80107
user ->
81108
{:ok, redirect(socket, to: AlgoraWeb.UserAuth.signed_in_path(user))}
@@ -156,16 +183,22 @@ defmodule AlgoraWeb.HomeLive do
156183
<section class="relative isolate min-h-[100svh] bg-gradient-to-b from-background to-black">
157184
<.pattern />
158185
<div class="mx-auto max-w-7xl pt-24 pb-12 xl:pt-20">
159-
<div class="mx-auto lg:mx-0 lg:flex lg:max-w-none lg:items-center">
160-
<div class="px-6 lg:px-8 lg:pr-0 xl:pb-20 relative w-full lg:max-w-xl lg:shrink-0 xl:max-w-3xl 2xl:max-w-3xl">
186+
<div class="mx-auto lg:mx-0 lg:flex lg:max-w-none">
187+
<div class={
188+
classes([
189+
"px-6 lg:px-8 lg:pr-0 xl:py-20 relative w-full lg:max-w-xl lg:shrink-0 xl:max-w-3xl 2xl:max-w-3xl",
190+
@screenshot? && "pt-24"
191+
])
192+
}>
193+
<.wordmark :if={@screenshot?} class="h-8 mb-6" />
161194
<h1 class="font-display text-3xl sm:text-4xl md:text-5xl xl:text-7xl font-semibold tracking-tight text-foreground">
162195
The open source Upwork for engineers
163196
</h1>
164197
<p class="mt-4 sm:mt-8 text-base sm:text-lg xl:text-2xl/8 font-medium text-muted-foreground sm:max-w-md lg:max-w-none">
165198
Discover GitHub bounties, contract work and jobs.<br class="hidden sm:block" />
166199
Hire the top 1% open source developers.
167200
</p>
168-
<div class="mt-6 sm:mt-10 flex gap-4">
201+
<div :if={!@screenshot?} class="mt-6 sm:mt-10 flex gap-4">
169202
<.button
170203
navigate={~p"/onboarding/org"}
171204
class="h-10 sm:h-14 rounded-md px-8 sm:px-12 text-sm sm:text-xl"
@@ -180,6 +213,9 @@ defmodule AlgoraWeb.HomeLive do
180213
Developers
181214
</.button>
182215
</div>
216+
<div class="flex flex-col gap-4 pt-6 sm:pt-10">
217+
<.events transactions={@transactions} />
218+
</div>
183219
</div>
184220
<!-- Featured devs -->
185221
<div class={
@@ -1630,4 +1666,70 @@ defmodule AlgoraWeb.HomeLive do
16301666
</div>
16311667
"""
16321668
end
1669+
1670+
defp events(assigns) do
1671+
~H"""
1672+
<ul class="w-full pl-10 relative space-y-8">
1673+
<li :for={{transaction, index} <- @transactions |> Enum.with_index()} class="relative">
1674+
<div>
1675+
<div class="relative -ml-[2.75rem]">
1676+
<span
1677+
:if={index != length(@transactions) - 1}
1678+
class="absolute left-2 top-6 -ml-px h-full w-0.5 block ml-[2.75rem] bg-muted-foreground/25"
1679+
aria-hidden="true"
1680+
>
1681+
</span>
1682+
<.link
1683+
rel="noopener"
1684+
target="_blank"
1685+
class="w-full group inline-flex"
1686+
href={transaction.bounty.ticket.url}
1687+
>
1688+
<div class="w-full relative flex space-x-3">
1689+
<div class="w-full flex min-w-0 flex-1 justify-between space-x-4 pt-1.5">
1690+
<div class="w-full flex items-center gap-3">
1691+
<div class="flex -space-x-1 ring-8 ring-[#050505]">
1692+
<span class="relative shrink-0 overflow-hidden flex h-9 w-9 items-center justify-center rounded-xl ring-4 ring-white bg-gray-950 ring-[#050505]">
1693+
<img
1694+
class="aspect-square h-full w-full"
1695+
alt={transaction.user.name}
1696+
src={transaction.user.avatar_url}
1697+
/>
1698+
</span>
1699+
<span class="relative shrink-0 overflow-hidden flex h-9 w-9 items-center justify-center rounded-xl ring-4 ring-white bg-gray-950 ring-[#050505]">
1700+
<img
1701+
class="aspect-square h-full w-full"
1702+
alt={transaction.linked_transaction.user.name}
1703+
src={transaction.linked_transaction.user.avatar_url}
1704+
/>
1705+
</span>
1706+
</div>
1707+
<div class="w-full z-10 flex gap-3 items-start xl:items-end">
1708+
<p class="text-xs transition-colors text-muted-foreground group-hover:text-white sm:text-base">
1709+
<strong class="font-bold">
1710+
{transaction.linked_transaction.user.name}
1711+
</strong>
1712+
awarded <strong class="font-bold">{transaction.user.name}</strong>
1713+
a
1714+
<strong class="font-bold font-display">
1715+
{Money.to_string!(transaction.net_amount)}
1716+
</strong>
1717+
bounty
1718+
</p>
1719+
<div class="ml-auto xl:ml-0 xl:mb-[2px] whitespace-nowrap text-xs text-muted-foreground sm:text-sm">
1720+
<time datetime={transaction.succeeded_at}>
1721+
{Algora.Util.time_ago(transaction.succeeded_at)}
1722+
</time>
1723+
</div>
1724+
</div>
1725+
</div>
1726+
</div>
1727+
</div>
1728+
</.link>
1729+
</div>
1730+
</div>
1731+
</li>
1732+
</ul>
1733+
"""
1734+
end
16331735
end

0 commit comments

Comments
 (0)