Much work.
This commit is contained in:
63
app/views/users/edit.html.erb
Normal file
63
app/views/users/edit.html.erb
Normal file
@@ -0,0 +1,63 @@
|
||||
<div class="mx-auto md:w-2/3 w-full">
|
||||
<div class="flex items-center mb-6">
|
||||
<%= link_to "← Back to Users", users_path, class: "text-blue-600 hover:text-blue-800" %>
|
||||
</div>
|
||||
|
||||
<h1 class="font-bold text-3xl mb-6">Edit User</h1>
|
||||
|
||||
<% if notice = flash[:notice] %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<% if alert = flash[:alert] %>
|
||||
<p class="py-2 px-3 bg-red-50 mb-5 text-red-500 font-medium rounded-lg inline-block" id="alert"><%= alert %></p>
|
||||
<% end %>
|
||||
|
||||
<div class="bg-white shadow rounded-lg p-6">
|
||||
<div class="mb-6">
|
||||
<h2 class="text-lg font-medium text-gray-900 mb-4">User Information</h2>
|
||||
|
||||
<div class="grid grid-cols-1 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Email Address</label>
|
||||
<div class="mt-1 text-sm text-gray-900"><%= @user.email_address %></div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Created</label>
|
||||
<div class="mt-1 text-sm text-gray-900"><%= @user.created_at.strftime("%B %d, %Y at %I:%M %p") %></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= form_with(model: @user, class: "contents") do |form| %>
|
||||
<div class="mb-6">
|
||||
<h2 class="text-lg font-medium text-gray-900 mb-4">Role Assignment</h2>
|
||||
|
||||
<div class="space-y-3">
|
||||
<div class="flex items-center">
|
||||
<%= form.radio_button :role, "admin", class: "h-4 w-4 text-purple-600 focus:ring-purple-500 border-gray-300" %>
|
||||
<%= form.label :role_admin, "Admin", class: "ml-3 block text-sm font-medium text-gray-700" %>
|
||||
<span class="ml-2 text-sm text-gray-500">- Full system access, user management, project creation</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center">
|
||||
<%= form.radio_button :role, "user", class: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300" %>
|
||||
<%= form.label :role_user, "User", class: "ml-3 block text-sm font-medium text-gray-700" %>
|
||||
<span class="ml-2 text-sm text-gray-500">- Read/write access to projects</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center">
|
||||
<%= form.radio_button :role, "viewer", class: "h-4 w-4 text-gray-600 focus:ring-gray-500 border-gray-300" %>
|
||||
<%= form.label :role_viewer, "Viewer", class: "ml-3 block text-sm font-medium text-gray-700" %>
|
||||
<span class="ml-2 text-sm text-gray-500">- Read-only access to all projects</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end">
|
||||
<%= form.submit "Update User", class: "rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white font-medium cursor-pointer" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
62
app/views/users/index.html.erb
Normal file
62
app/views/users/index.html.erb
Normal file
@@ -0,0 +1,62 @@
|
||||
<div class="mx-auto md:w-4/5 w-full">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h1 class="font-bold text-3xl">User Management</h1>
|
||||
<div class="text-sm text-gray-600">
|
||||
Total users: <%= @users.count %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if notice = flash[:notice] %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<% if alert = flash[:alert] %>
|
||||
<p class="py-2 px-3 bg-red-50 mb-5 text-red-500 font-medium rounded-lg inline-block" id="alert"><%= alert %></p>
|
||||
<% end %>
|
||||
|
||||
<div class="bg-white shadow overflow-hidden sm:rounded-md">
|
||||
<ul class="divide-y divide-gray-200">
|
||||
<% @users.each do |user| %>
|
||||
<li>
|
||||
<div class="px-4 py-4 sm:px-6 hover:bg-gray-50">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<div class="h-10 w-10 rounded-full bg-gray-300 flex items-center justify-center">
|
||||
<span class="text-sm font-medium text-gray-700">
|
||||
<%= user.email_address.first.upcase %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ml-4">
|
||||
<div class="text-sm font-medium text-gray-900">
|
||||
<%= user.email_address %>
|
||||
</div>
|
||||
<div class="text-sm text-gray-500">
|
||||
Joined <%= user.created_at.strftime("%B %d, %Y") %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
|
||||
<% if user.admin? %>bg-purple-100 text-purple-800
|
||||
<% elsif user.viewer? %>bg-gray-100 text-gray-800
|
||||
<% else %>bg-blue-100 text-blue-800<% end %>">
|
||||
<%= user.role.capitalize %>
|
||||
</span>
|
||||
<%= link_to "Edit", edit_user_path(user),
|
||||
class: "inline-flex items-center px-3 py-1.5 border border-gray-300 shadow-sm text-xs font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<% if @users.empty? %>
|
||||
<div class="text-center py-12">
|
||||
<p class="text-gray-500">No users found.</p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
4
app/views/users/show.html.erb
Normal file
4
app/views/users/show.html.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<div>
|
||||
<h1 class="font-bold text-4xl">Users#show</h1>
|
||||
<p>Find me in app/views/users/show.html.erb</p>
|
||||
</div>
|
||||
4
app/views/users/update.html.erb
Normal file
4
app/views/users/update.html.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<div>
|
||||
<h1 class="font-bold text-4xl">Users#update</h1>
|
||||
<p>Find me in app/views/users/update.html.erb</p>
|
||||
</div>
|
||||
Reference in New Issue
Block a user