Skip to content

Commit 8251ccf

Browse files
committed
feat: org transactions page (#32)
1 parent 54e00af commit 8251ccf

File tree

9 files changed

+582
-65
lines changed

9 files changed

+582
-65
lines changed

lib/algora/accounts/schemas/user.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,9 @@ defmodule Algora.Accounts.User do
308308
def url(%{handle: handle, type: :individual}), do: "/@/#{handle}"
309309
def url(%{handle: handle, type: :organization}), do: "/org/#{handle}"
310310
def url(%{provider_login: handle}), do: "https://github.com/#{handle}"
311+
312+
def last_context(%{last_context: nil}), do: default_context()
313+
def last_context(%{last_context: last_context}), do: last_context
314+
315+
def default_context, do: "personal"
311316
end

lib/algora/integrations/github/command.ex

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,10 @@ defmodule Algora.Github.Command do
7676
def parse(input) when is_binary(input) do
7777
case parse_raw(input) do
7878
{:ok, [], _, _, _, _} ->
79-
{:ok, %{}}
79+
{:ok, []}
8080

8181
{:ok, parsed, _, _, _, _} ->
82-
{:ok,
83-
parsed
84-
|> Enum.reject(&is_nil/1)
85-
|> Map.new()}
82+
{:ok, Enum.reject(parsed, &is_nil/1)}
8683

8784
{:error, reason, _, _, _, _} ->
8885
{:error, reason}

lib/algora_web/controllers/user_auth.ex

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ defmodule AlgoraWeb.UserAuth do
66
import Plug.Conn
77

88
alias Algora.Accounts
9+
alias Algora.Accounts.User
910
alias Phoenix.LiveView
1011

1112
def on_mount(:current_user, _params, session, socket) do
@@ -185,12 +186,15 @@ defmodule AlgoraWeb.UserAuth do
185186

186187
defp maybe_store_return_to(conn), do: conn
187188

189+
def signed_in_path_from_context("personal"), do: ~p"/home"
190+
def signed_in_path_from_context(org_handle), do: ~p"/org/#{org_handle}"
191+
192+
def signed_in_path(%User{} = user) do
193+
signed_in_path_from_context(User.last_context(user))
194+
end
195+
188196
def signed_in_path(conn) do
189-
case get_session(conn, :last_context) do
190-
nil -> ~p"/home"
191-
"personal" -> ~p"/home"
192-
org_handle -> ~p"/org/#{org_handle}"
193-
end
197+
signed_in_path_from_context(get_session(conn, :last_context, User.default_context()))
194198
end
195199

196200
defp login_code_ttl, do: 3600

lib/algora_web/live/org/nav.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ defmodule AlgoraWeb.Org.Nav do
7474
icon: "tabler-users",
7575
label: "Team"
7676
},
77+
%{
78+
href: "/org/#{org_handle}/transactions",
79+
tab: :transactions,
80+
icon: "tabler-credit-card",
81+
label: "Transactions"
82+
},
7783
%{
7884
href: "/org/#{org_handle}/analytics",
7985
tab: :analytics,

0 commit comments

Comments
 (0)