Skip to content

Commit

Permalink
Add owner name on rounds show page for audiences
Browse files Browse the repository at this point in the history
Add round name on audience vote page
Change styling a bit
  • Loading branch information
kangkyu committed Jul 2, 2024
1 parent 2837517 commit 74dae9e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
4 changes: 4 additions & 0 deletions app/views/contestants/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<%= turbo_stream_from "audience_contestants" %>

<div class="max-w-md mx-auto mt-5">
<h2 class="text-2xl font-semibold mb-4"><%= link_to @round.title, round_path(@round) %>” round contestants</h2>
</div>

<%= turbo_frame_tag "contestants" do %>
<% if @contestants.any? %>
<ul class="w-full text-sm font-medium text-gray-900 bg-white border border-gray-200 dark:bg-gray-700 dark:border-gray-600 dark:text-white" id="audience_contestant">
Expand Down
Empty file.
11 changes: 3 additions & 8 deletions app/views/owner/contestants/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,16 @@
<% end %>
</ul>

<% unless current_page?(owner_round_results_path(@round)) %>

<div class="min-h-full flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
<div class="max-w-md w-full space-y-8">
<%= form_with(url: owner_round_contestants_path(@round), method: :post, model: [@round, @round.contestants.build], class: "mt-8 space-y-6") do |f| %>
<div class="flex space-x-2">
<%= f.text_field :name, autofocus: true, required: true, placeholder: "Name", class: "appearance-none rounded-l-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm" %>
<%= f.text_field :location, placeholder: "Location", class: "appearance-none rounded-r-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm" %>
<%= f.text_field :name, autofocus: true, required: true, placeholder: "Name", class: "appearance-none rounded-l-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm" %>
<%= f.text_field :location, placeholder: "Location", class: "appearance-none rounded-r-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm" %>
</div>
<div>
<%= f.submit "Add", class: "group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
<%= f.submit "Add", class: "group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md bg-blue-500 hover:bg-blue-700 text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" %>
</div>
<% end %>
</div>
</div>


<% end %>
27 changes: 16 additions & 11 deletions app/views/rounds/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
<div class="max-w-md mx-auto mt-5">
<h2 class="text-2xl font-semibold mb-4">Welcome to “<%= @round.title %>” round</h2>
<% if current_user.owner?(@round) %>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<p class="text-md font-bold mb-2">Owner menu</p>
<ul class="list-disc list-inside">
<li><%= link_to "list of audiences", owner_round_audiences_path(@round) %></li>
<li><%= link_to "list of contestants", owner_round_contestants_path(@round) %></li>
</ul>
</div>
<% if current_user.owner?(@round) %>
<div>
<p class="text-md font-bold mb-2">Owner menu</p>
<ul class="list-disc list-inside">
<li><%= link_to "list of audiences", owner_round_audiences_path(@round) %></li>
<li><%= link_to "list of contestants", owner_round_contestants_path(@round) %></li>
</ul>
</div>
<% else %>
<div>
<p class="text-md mb-2">User <span class="font-bold"><%= @round.owner.username %></span> started it</p>
<% if !current_user.audience?(@round) %>
<%= button_to "Join the audience", new_round_audience_path(@round), method: :get, class: "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4" %>
<% end %>
</div>
<% end %>
</div>
<% elsif !current_user.audience?(@round) %>
<%= button_to "Join the audience", new_round_audience_path(@round), method: :get, class: "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4" %>
<% end %>
</div>

0 comments on commit 74dae9e

Please sign in to comment.