@@ -8,15 +8,19 @@ defmodule AlgoraWeb.Org.BountiesLive do
88 on_mount AlgoraWeb.Org.BountyHook
99
1010 def mount ( _params , _session , socket ) do
11- bounties = Bounties . list_bounties ( owner_id: socket . assigns . current_org . id , limit: 10 )
11+ open_bounties = Bounties . list_bounties ( owner_id: socket . assigns . current_org . id , limit: 10 , status: :open )
12+ paid_bounties = Bounties . list_bounties ( owner_id: socket . assigns . current_org . id , limit: 10 , status: :paid )
13+
14+ # TODO:
1215 claims = [ ]
1316
1417 { :ok ,
1518 socket
16- |> assign ( :bounties , bounties )
19+ |> assign ( :open_bounties , open_bounties )
20+ |> assign ( :paid_bounties , paid_bounties )
1721 |> assign ( :claims , claims )
18- |> assign ( :open_count , length ( bounties ) )
19- |> assign ( :completed_count , 0 )
22+ |> assign ( :open_count , length ( open_bounties ) )
23+ |> assign ( :completed_count , length ( paid_bounties ) )
2024 |> assign ( :new_bounty_form , to_form ( % { "github_issue_url" => "" , "amount" => "" } ) ) }
2125 end
2226
@@ -49,9 +53,11 @@ defmodule AlgoraWeb.Org.BountiesLive do
4953 < button
5054 type = "button "
5155 role = "tab "
52- aria-selected = "true "
53- class = "inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium data-[state=active]:bg-indigo-600 data-[state=active]:text-white "
54- data-state = "active "
56+ aria-selected = { @ current_tab == :open }
57+ class = { "inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium #{ if @ current_tab == :open , do: "bg-indigo-600 text-white" , else: "hover:bg-indigo-600/50" } " }
58+ data-state = { if @ current_tab == :open , do: "active" , else: "inactive" }
59+ phx-click = "change-tab "
60+ phx-value-tab = "open "
5561 >
5662 < div class = "relative flex items-center gap-2.5 text-sm md:text-base " >
5763 < div class = "truncate " > Open</ div >
@@ -63,9 +69,11 @@ defmodule AlgoraWeb.Org.BountiesLive do
6369 < button
6470 type = "button "
6571 role = "tab "
66- aria-selected = "false "
67- class = "inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium hover:bg-indigo-600/50 "
68- data-state = "inactive "
72+ aria-selected = { @ current_tab == :completed }
73+ class = { "inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium #{ if @ current_tab == :completed , do: "bg-indigo-600 text-white" , else: "hover:bg-indigo-600/50" } " }
74+ data-state = { if @ current_tab == :completed , do: "active" , else: "inactive" }
75+ phx-click = "change-tab "
76+ phx-value-tab = "completed "
6977 >
7078 < div class = "relative flex items-center gap-2.5 text-sm md:text-base " >
7179 < div class = "truncate " > Completed</ div >
@@ -76,39 +84,14 @@ defmodule AlgoraWeb.Org.BountiesLive do
7684 </ button >
7785 </ div >
7886 </ div >
79- <!-- Checkboxes for hiding claimed and attempted bounties -->
80- < div class = "mt-3 flex items-center space-x-4 " >
81- < div class = "flex items-center space-x-4 " >
82- < div class = "flex items-center space-x-2 " >
83- < input
84- type = "checkbox "
85- id = "hide-claimed "
86- class = "h-6 w-6 rounded-sm border bg-gray-600 "
87- />
88- < label for = "hide-claimed " class = "text-sm font-medium leading-none " >
89- Hide claimed
90- </ label >
91- </ div >
92- < div class = "flex items-center space-x-2 " >
93- < input
94- type = "checkbox "
95- id = "hide-attempted "
96- class = "h-6 w-6 rounded-sm border bg-gray-600 "
97- />
98- < label for = "hide-attempted " class = "text-sm font-medium leading-none " >
99- Hide attempted
100- </ label >
101- </ div >
102- </ div >
103- </ div >
10487 </ div >
10588 </ div >
10689 </ div >
10790 < div class = "overflow-hidden rounded-xl border border-white/15 " >
10891 < div class = "scrollbar-thin w-full overflow-auto " >
10992 < table class = "w-full caption-bottom text-sm " >
11093 < tbody class = "[&_tr:last-child]:border-0 " >
111- <%= for bounty <- @ bounties do %>
94+ <%= for bounty <- ( if @ current_tab == :open , do: @ open_bounties , else: @ paid_bounties ) do %>
11295 < tr
11396 class = "bg-white/[2%] from-white/[2%] via-white/[2%] to-white/[2%] border-b border-white/15 bg-gradient-to-br transition-colors data-[state=selected]:bg-gray-100 hover:bg-gray-100/50 dark:data-[state=selected]:bg-gray-800 dark:hover:bg-white/[2%] "
11497 data-state = "false "
@@ -257,4 +240,24 @@ defmodule AlgoraWeb.Org.BountiesLive do
257240 </ div >
258241 """
259242 end
243+
244+ def handle_event ( "change-tab" , % { "tab" => "completed" } , socket ) do
245+ { :noreply , push_patch ( socket , to: ~p" /org/#{ socket . assigns . current_org . handle } /bounties?status=completed" ) }
246+ end
247+
248+ def handle_event ( "change-tab" , % { "tab" => "open" } , socket ) do
249+ { :noreply , push_patch ( socket , to: ~p" /org/#{ socket . assigns . current_org . handle } /bounties?status=open" ) }
250+ end
251+
252+ def handle_params ( params , _uri , socket ) do
253+ { :noreply , assign ( socket , :current_tab , get_current_tab ( params ) ) }
254+ end
255+
256+ defp get_current_tab ( params ) do
257+ case params [ "status" ] do
258+ "open" -> :open
259+ "completed" -> :completed
260+ _ -> :open
261+ end
262+ end
260263end
0 commit comments