Add admin dashboard

This commit is contained in:
yodalightsabr 2025-05-05 14:03:16 -07:00
parent 097e567042
commit ff99f9df09
3 changed files with 35 additions and 0 deletions

View file

@ -0,0 +1,19 @@
class AdminController < ApplicationController
before_action :require_authentication
before_action :authenticate_user
def dashboard
@users = User.all
@posts = Post.all
@projects = Project.all
end
private
def authenticate_user
unless current_user && current_user.admin?
redirect_to root_path
end
end
end

View file

@ -0,0 +1,10 @@
<h1 class="text-3xl font-bold mb-4">Admin Dashboard</h1>
<h1 class="text-2xl font-bold mb-4">Projects</h1>
<%= (ap @projects).html_safe %>
<h1 class="text-2xl font-bold mb-4">Users</h1>
<%= (ap @users).html_safe %>
<h1 class="text-2xl font-bold mb-4">Posts</h1>
<%= (ap @posts).html_safe %>

View file

@ -20,6 +20,12 @@ Rails.application.routes.draw do
get "/dashboard", to: "landing#dashboard", as: :dashboard
get "/leaderboards", to: "landing#leaderboards", as: :leaderboards
resources :admin, only: [] do
collection do
get "/dashboard", to: "admin#dashboard", as: :dashboard
end
end
# otp auth + session
# resources :sessions