Users pages have been stylized to fit in line with the app

This commit is contained in:
Ben 2024-02-16 15:13:09 -06:00
parent 12a9641ca7
commit e52a9da39c
3 changed files with 76 additions and 51 deletions

View File

@ -1,27 +1,26 @@
<%= form_with(model: user, local: true) do |form| %>
<% if user.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% user.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= form.label :email %><br>
<%= form.email_field :email, id: :user_email %>
</div>
<div class="field">
<%= form.label :admin %><br>
<%= form.check_box :admin %>
</div>
<div class="actions">
<%= form.submit 'Save', class: 'btn btn-primary' %>
<%= form_with(model: user, local: true, html: { class: 'needs-validation', novalidate: true }) do |form| %>
<% if user.errors.any? %>
<div id="error_explanation" class="alert alert-danger" role="alert">
<h4><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h4>
<ul>
<% user.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="mb-3">
<%= form.label :email, class: 'form-label' %>
<%= form.email_field :email, id: :user_email, class: 'form-control' %>
</div>
<div class="mb-3 form-check">
<%= form.check_box :admin, class: 'form-check-input', id: :user_admin %>
<%= form.label :admin, class: 'form-check-label' %>
</div>
<div class="actions">
<%= form.submit 'Save', class: 'btn btn-dark' %>
</div>
<% end %>

View File

@ -1,5 +1,14 @@
<h1>Edit User</h1>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<h1 class="mb-4 text-center">Edit User</h1>
<%= render 'form', user: @user %>
<%= render 'form', user: @user %>
<%= link_to 'Back to Users', users_path, class: 'btn btn-secondary' %>
<div class="mt-3 d-flex justify-content-between">
<%= link_to 'Back to Users', users_path, class: 'btn btn-secondary' %>
<%= link_to 'Delete User', user_path(@user), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
</div>
</div>
</div>
</div>

View File

@ -1,23 +1,40 @@
<h1>Users</h1>
<table class="table">
<thead>
<tr>
<th>Email</th>
<th>Admin</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= user.email %></td>
<td><%= user.admin? ? 'Yes' : 'No' %></td>
<td>
<%= link_to 'Edit', edit_user_path(user), class: 'btn btn-info' %>
<%= link_to 'Delete', user_path(user), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div class="container mt-5">
<div class="row">
<div class="col-12">
<h1 class="mb-4 text-center">Users</h1>
</div>
<div class="col-12 mb-4">
<table class="table">
<thead class="table-light">
<tr>
<th>Email</th>
<th>Admin</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= user.email %></td>
<td><%= user.admin? ? 'Yes' : 'No' %></td>
<td>
<%= link_to edit_user_path(user), class: 'btn btn-info btn-sm' do %>
<i class="bi bi-pencil-fill" style="color: white;"></i>
<% end %>
<%= link_to user_path(user), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-sm' do %>
<i class="bi bi-trash-fill"></i>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<!-- Optionally, include action buttons or links here -->
<div class="row">
<div class="col-12 d-flex justify-content-between mb-4">
<%= link_to 'Back to Home', root_path, class: "btn btn-secondary" %> <!-- Adjust as needed -->
</div>
</div>
</div>