@@ -452,7 +452,7 @@ defmodule AlgoraWeb.Org.JobLive do
452
452
:critical
453
453
)
454
454
455
- { :noreply , put_flash ( socket , :info , "#{ dev . provider_login } is invited to an interview " ) }
455
+ { :noreply , put_flash ( socket , :info , "Invitation sent! " ) }
456
456
end
457
457
458
458
@ impl true
@@ -461,42 +461,50 @@ defmodule AlgoraWeb.Org.JobLive do
461
461
% { "user_id" => user_id , "type" => "contract" , "contract_type" => contract_type } ,
462
462
socket
463
463
) do
464
- developer = Enum . find ( socket . assigns . developers , & ( & 1 . id == user_id ) )
465
- match = Enum . find ( socket . assigns . matches , & ( & 1 . user . id == user_id ) )
466
- hourly_rate = match [ :hourly_rate ]
464
+ if socket . assigns . current_org . hiring_subscription == :active do
465
+ developer = Enum . find ( socket . assigns . developers , & ( & 1 . id == user_id ) )
466
+ match = Enum . find ( socket . assigns . matches , & ( & 1 . user . id == user_id ) )
467
+ hourly_rate = match [ :hourly_rate ]
467
468
468
- hours_per_week = developer . hours_per_week || 30
469
+ hours_per_week = developer . hours_per_week || 30
469
470
470
- { :noreply ,
471
- socket
472
- |> assign ( :main_contract_form_open? , true )
473
- |> assign (
474
- :main_contract_form ,
475
- % ContractForm {
476
- contract_type: String . to_existing_atom ( contract_type ) ,
477
- contractor: match [ :user ] || developer
478
- }
479
- |> ContractForm . changeset ( % {
480
- amount: if ( hourly_rate , do: Money . mult! ( hourly_rate , hours_per_week ) ) ,
481
- hourly_rate: hourly_rate ,
482
- contractor_handle: developer . provider_login ,
483
- hours_per_week: hours_per_week ,
484
- title: "#{ socket . assigns . current_org . name } OSS Development" ,
485
- description: "Open source contribution to #{ socket . assigns . current_org . name } for a week"
486
- } )
487
- |> to_form ( )
488
- ) }
471
+ { :noreply ,
472
+ socket
473
+ |> assign ( :main_contract_form_open? , true )
474
+ |> assign (
475
+ :main_contract_form ,
476
+ % ContractForm {
477
+ contract_type: String . to_existing_atom ( contract_type ) ,
478
+ contractor: match [ :user ] || developer
479
+ }
480
+ |> ContractForm . changeset ( % {
481
+ amount: if ( hourly_rate , do: Money . mult! ( hourly_rate , hours_per_week ) ) ,
482
+ hourly_rate: hourly_rate ,
483
+ contractor_handle: developer . provider_login ,
484
+ hours_per_week: hours_per_week ,
485
+ title: "#{ socket . assigns . current_org . name } OSS Development" ,
486
+ description: "Open source contribution to #{ socket . assigns . current_org . name } for a week"
487
+ } )
488
+ |> to_form ( )
489
+ ) }
490
+ else
491
+ { :noreply , push_patch ( socket , to: ~p" /#{ socket . assigns . job . user . handle } /jobs/#{ socket . assigns . job . id } /activate" ) }
492
+ end
489
493
end
490
494
491
495
@ impl true
492
496
def handle_event ( "share_opportunity" , % { "user_id" => user_id , "type" => type } , socket ) do
493
- developer = Enum . find ( socket . assigns . developers , & ( & 1 . id == user_id ) )
497
+ if socket . assigns . current_org . hiring_subscription == :active do
498
+ developer = Enum . find ( socket . assigns . developers , & ( & 1 . id == user_id ) )
494
499
495
- { :noreply ,
496
- socket
497
- |> assign ( :selected_developer , developer )
498
- |> assign ( :share_drawer_type , type )
499
- |> assign ( :show_share_drawer , true ) }
500
+ { :noreply ,
501
+ socket
502
+ |> assign ( :selected_developer , developer )
503
+ |> assign ( :share_drawer_type , type )
504
+ |> assign ( :show_share_drawer , true ) }
505
+ else
506
+ { :noreply , push_patch ( socket , to: ~p" /#{ socket . assigns . job . user . handle } /jobs/#{ socket . assigns . job . id } /activate" ) }
507
+ end
500
508
end
501
509
502
510
@ impl true
@@ -630,12 +638,13 @@ defmodule AlgoraWeb.Org.JobLive do
630
638
end
631
639
632
640
# Sort matches by total contributions (0 if no heatmap) and take top 6
633
- sorted_matches =
641
+ sorted_matches =
634
642
all_matches
635
643
|> Enum . sort_by ( fn match ->
636
644
heatmap_data = Map . get ( heatmaps_map , match . user . id )
637
645
total_contributions = if heatmap_data , do: get_in ( heatmap_data , [ "totalContributions" ] ) || 0 , else: 0
638
- - total_contributions # negative for descending sort
646
+ # negative for descending sort
647
+ - total_contributions
639
648
end )
640
649
|> Enum . take ( 6 )
641
650
0 commit comments