@@ -8,15 +8,19 @@ defmodule AlgoraWeb.Org.BountiesLive do
8
8
on_mount AlgoraWeb.Org.BountyHook
9
9
10
10
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:
12
15
claims = [ ]
13
16
14
17
{ :ok ,
15
18
socket
16
- |> assign ( :bounties , bounties )
19
+ |> assign ( :open_bounties , open_bounties )
20
+ |> assign ( :paid_bounties , paid_bounties )
17
21
|> 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 ) )
20
24
|> assign ( :new_bounty_form , to_form ( % { "github_issue_url" => "" , "amount" => "" } ) ) }
21
25
end
22
26
@@ -49,9 +53,11 @@ defmodule AlgoraWeb.Org.BountiesLive do
49
53
< button
50
54
type = "button "
51
55
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 "
55
61
>
56
62
< div class = "relative flex items-center gap-2.5 text-sm md:text-base " >
57
63
< div class = "truncate " > Open</ div >
@@ -63,9 +69,11 @@ defmodule AlgoraWeb.Org.BountiesLive do
63
69
< button
64
70
type = "button "
65
71
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 "
69
77
>
70
78
< div class = "relative flex items-center gap-2.5 text-sm md:text-base " >
71
79
< div class = "truncate " > Completed</ div >
@@ -76,39 +84,14 @@ defmodule AlgoraWeb.Org.BountiesLive do
76
84
</ button >
77
85
</ div >
78
86
</ 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 >
104
87
</ div >
105
88
</ div >
106
89
</ div >
107
90
< div class = "overflow-hidden rounded-xl border border-white/15 " >
108
91
< div class = "scrollbar-thin w-full overflow-auto " >
109
92
< table class = "w-full caption-bottom text-sm " >
110
93
< 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 %>
112
95
< tr
113
96
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%] "
114
97
data-state = "false "
@@ -257,4 +240,24 @@ defmodule AlgoraWeb.Org.BountiesLive do
257
240
</ div >
258
241
"""
259
242
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
260
263
end
0 commit comments