Skip to content

Commit 3e52ef7

Browse files
committed
feat: link contract creation achievement to contract drawer
1 parent 006c768 commit 3e52ef7

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

lib/algora_web/components/achievement.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ defmodule AlgoraWeb.Components.Achievement do
44

55
import AlgoraWeb.CoreComponents
66

7+
def link_attrs(path) when is_binary(path), do: [navigate: path]
8+
def link_attrs(opts) when is_list(opts), do: opts
9+
def link_attrs(_opts), do: []
10+
711
def achievement(%{achievement: %{status: :completed}} = assigns) do
812
~H"""
913
<div class="group flex items-center gap-3">
@@ -19,7 +23,7 @@ defmodule AlgoraWeb.Components.Achievement do
1923

2024
def achievement(%{achievement: %{status: :upcoming}} = assigns) do
2125
~H"""
22-
<.maybe_link navigate={@achievement.path}>
26+
<.maybe_link {link_attrs(@achievement.path)}>
2327
<div class={
2428
classes([
2529
"group flex items-center gap-3",
@@ -50,7 +54,7 @@ defmodule AlgoraWeb.Components.Achievement do
5054

5155
def achievement(%{achievement: %{status: :current}} = assigns) do
5256
~H"""
53-
<.maybe_link navigate={@achievement.path}>
57+
<.maybe_link {link_attrs(@achievement.path)}>
5458
<div
5559
class={[
5660
"group flex items-start",

lib/algora_web/live/org/dashboard_live.ex

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ defmodule AlgoraWeb.Org.DashboardLive do
132132

133133
transactions = Payments.list_hosted_transactions(current_org.id, limit: page_size())
134134

135+
socket =
136+
if params["action"] == "create_contract" do
137+
assign(socket, :main_contract_form_open?, true)
138+
else
139+
socket
140+
end
141+
135142
{:noreply,
136143
socket
137144
|> assign(:current_status, current_status)
@@ -1126,15 +1133,26 @@ defmodule AlgoraWeb.Org.DashboardLive do
11261133
defp achievement_todo(%{achievement: %{id: :connect_github_status}} = assigns) do
11271134
~H"""
11281135
<.button :if={!@current_user.provider_login} href={Github.authorize_url()} class="ml-auto gap-2">
1129-
<Logos.github class="w-4 h-4 mr-2 -ml-1" /> Connect GitHub
1136+
<Logos.github class="w-4 h-4 -ml-1" /> Connect GitHub
11301137
</.button>
11311138
"""
11321139
end
11331140

11341141
defp achievement_todo(%{achievement: %{id: :install_app_status}} = assigns) do
11351142
~H"""
11361143
<.button phx-click="install_app" class="ml-auto gap-2">
1137-
<Logos.github class="w-4 h-4 mr-2 -ml-1" /> Install GitHub App
1144+
<Logos.github class="w-4 h-4 -ml-1" /> Install GitHub App
1145+
</.button>
1146+
"""
1147+
end
1148+
1149+
defp achievement_todo(%{achievement: %{id: :create_contract_status}} = assigns) do
1150+
~H"""
1151+
<.button
1152+
patch={~p"/#{@current_org.handle}/dashboard?action=create_contract"}
1153+
class="ml-auto gap-2"
1154+
>
1155+
<.icon name="tabler-user-dollar" class="w-4 h-4 -ml-1" /> Create a contract
11381156
</.button>
11391157
"""
11401158
end
@@ -1154,7 +1172,8 @@ defmodule AlgoraWeb.Org.DashboardLive do
11541172
{&install_app_status/1, "Install Algora in #{current_org.name}", nil},
11551173
{&create_bounty_status/1, "Create a bounty", nil},
11561174
{&reward_bounty_status/1, "Reward a bounty", nil},
1157-
{&create_contract_status/1, "Contract a developer", nil},
1175+
{&create_contract_status/1, "Contract a developer",
1176+
[patch: ~p"/#{current_org.handle}/dashboard?action=create_contract"]},
11581177
{&share_with_friend_status/1, "Share Algora with a friend", nil}
11591178
]
11601179

@@ -1625,6 +1644,7 @@ defmodule AlgoraWeb.Org.DashboardLive do
16251644
<.achievement_todo
16261645
achievement={achievement}
16271646
current_user={@current_user}
1647+
current_org={@current_org}
16281648
secret={@secret}
16291649
login_form={@login_form}
16301650
/>

0 commit comments

Comments
 (0)