@@ -174,6 +174,10 @@ defmodule AlgoraWeb.ClaimLive do
174
174
end
175
175
176
176
@ impl true
177
+ def handle_params ( _params , _url , % { assigns: % { current_user: nil } } = socket ) do
178
+ { :noreply , socket }
179
+ end
180
+
177
181
def handle_params ( % { "context" => context_id } , _url , socket ) do
178
182
{ :noreply , socket |> assign_selected_context ( context_id ) |> assign_line_items ( ) }
179
183
end
@@ -203,6 +207,15 @@ defmodule AlgoraWeb.ClaimLive do
203
207
|> assign_line_items ( ) }
204
208
end
205
209
210
+ def handle_event ( "split_bounty" , _params , socket ) do
211
+ # TODO: Implement split bounty
212
+ Logger . error (
213
+ "Attempt to split bounty #{ socket . assigns . target . repository . user . provider_login } /#{ socket . assigns . target . repository . name } #{ socket . assigns . target . number } "
214
+ )
215
+
216
+ { :noreply , socket }
217
+ end
218
+
206
219
def handle_event ( "pay_with_stripe" , % { "reward_bounty_form" => params } , socket ) do
207
220
changeset = RewardBountyForm . changeset ( % RewardBountyForm { } , params )
208
221
@@ -267,7 +280,7 @@ defmodule AlgoraWeb.ClaimLive do
267
280
Bounties . create_bounty ( % {
268
281
creator: socket . assigns . current_user ,
269
282
owner: socket . assigns . selected_context ,
270
- amount: data . amount ,
283
+ amount: Money . new! ( :USD , data . amount ) ,
271
284
ticket_ref: ticket_ref ( socket )
272
285
} )
273
286
@@ -281,7 +294,7 @@ defmodule AlgoraWeb.ClaimLive do
281
294
282
295
Bounties . reward_bounty (
283
296
% {
284
- creator : socket . assigns . current_user ,
297
+ owner : socket . assigns . selected_context ,
285
298
amount: final_amount ,
286
299
bounty_id: bounty . id ,
287
300
claims: socket . assigns . claims
@@ -383,7 +396,8 @@ defmodule AlgoraWeb.ClaimLive do
383
396
< . card_title >
384
397
Authors
385
398
</ . card_title >
386
- < . button variant = "secondary " >
399
+ <!-- TODO: hide if user is not an admin -->
400
+ < . button variant = "secondary " phx-click = "split_bounty " >
387
401
Split bounty
388
402
</ . button >
389
403
</ div >
@@ -497,7 +511,7 @@ defmodule AlgoraWeb.ClaimLive do
497
511
</ div >
498
512
</ div >
499
513
</ div >
500
- < . drawer show = { @ show_reward_bounty_modal } on_cancel = "close_drawer " >
514
+ < . drawer :if = { @ current_user } show = { @ show_reward_bounty_modal } on_cancel = "close_drawer " >
501
515
< . drawer_header >
502
516
< . drawer_title > Reward Bounty</ . drawer_title >
503
517
< . drawer_description >
@@ -519,27 +533,18 @@ defmodule AlgoraWeb.ClaimLive do
519
533
< . card_content >
520
534
< div class = "space-y-4 " >
521
535
<%= if Enum . empty? ( @ available_bounties ) do %>
522
- < div class = "flex flex-col gap-4 " >
523
- < . alert variant = "destructive " >
524
- < . alert_title > No bounties available</ . alert_title >
525
- < . alert_description >
526
- You don't have any bounties available. Would you like to create one?
527
- </ . alert_description >
528
- </ . alert >
529
-
530
- < . input
531
- label = "Amount "
532
- icon = "tabler-currency-dollar "
533
- field = { @ reward_bounty_form [ :amount ] }
534
- />
535
- </ div >
536
- <% else %>
537
- < . input
538
- label = "Amount "
539
- icon = "tabler-currency-dollar "
540
- field = { @ reward_bounty_form [ :amount ] }
541
- />
536
+ < . alert variant = "destructive " >
537
+ < . alert_title > No bounties available</ . alert_title >
538
+ < . alert_description >
539
+ You didn't post a bounty for this issue. Would you like to create one now?
540
+ </ . alert_description >
541
+ </ . alert >
542
542
<% end %>
543
+ < . input
544
+ label = "Amount "
545
+ icon = "tabler-currency-dollar "
546
+ field = { @ reward_bounty_form [ :amount ] }
547
+ />
543
548
544
549
< div >
545
550
< . label > On behalf of</ . label >
0 commit comments