Skip to content

Commit

Permalink
Show only Open Bounties by default (#68)
Browse files Browse the repository at this point in the history
* show `'open'` bounties by default at root path

* set filter to '`none`' to fetch all bounties

* show custom msg if no open bounties are found
  • Loading branch information
JuzerShakir authored Aug 13, 2024
1 parent 100ff02 commit ccb36dc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/controllers/bounties_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class BountiesController < ApplicationController

# GET /bounties or /bounties.json
def index
params[:filter] = "open" if params[:filter].nil?
@bounties = Bounty.sorted
@filter, @bounties = params[:filter], @bounties.filtered(params[:filter]) if Bounty::STATUSES.include?(params[:filter])
@pagy, @bounties = pagy(@bounties)
Expand Down
20 changes: 15 additions & 5 deletions app/views/bounties/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@
<div class="my-8 flex gap-2 items-center justify-between">
<h2 class="m-0"><%= (@filter || "All").titleize %> Bounties</h2>
<nav class="flex gap-2">
<%= link_to "All", bounties_path, class: class_names("font-bold" => @filter.blank?) %>
<%= link_to "All", bounties_path(filter: "none"), class: class_names("font-bold" => @filter.blank?) %>
<% Bounty::STATUSES.each do |status| %>
<%= link_to status.titleize, bounties_path(filter: status), class: class_names("font-bold" => status == @filter) %>
<% end %>
</nav>
</div>

<div id="bounties">
<%= render @bounties %>
</div>
<% if @bounties.present? %>
<div id="bounties">
<%= render @bounties %>
</div>

<%== pagy_nav(@pagy).html_safe %>
<%== pagy_nav(@pagy).html_safe %>
<% else %>
<% if @filter == "open" %>
<p class="m-8 md:m-12 text-center italic text-lg md:text-xl">
There are no open bounties right now.
<br>
Spread the word that we need people to post new Beginner Bounties!
</p>
<% end %>
<% end %>

0 comments on commit ccb36dc

Please sign in to comment.