Update the navbar and routes to check the User's role.
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-04-11 11:07:05 +03:00
parent 2456b48929
commit 92a090575c
2 changed files with 7 additions and 2 deletions
@@ -4,6 +4,7 @@ defmodule DecentralisedBookIndexWeb.Components.MyPartials.Navbar do
import DecentralisedBookIndexWeb.Components.MyComponents.Buttons
alias Phoenix.LiveView.JS
alias DecentralisedBookIndex.Accounts.Role
attr :page_title, :string, required: true
attr :current_user, :map, default: nil
@@ -28,10 +29,12 @@ defmodule DecentralisedBookIndexWeb.Components.MyPartials.Navbar do
<li>
<a href={~p"/authors/"} class={selected_navbar_link_css(@page_title, "Listing Authors")} aria-current="page">Authors</a>
</li>
<%= if @current_user != nil do %>
<%= if @current_user != nil and Role.can_moderate?(@current_user.role) do %>
<li>
<a href={~p"/publishers/"} class={selected_navbar_link_css(@page_title, "Listing Publishers")} aria-current="page">Publishers</a>
</li>
<% end %>
<%= if @current_user != nil and Role.can_administrate?(@current_user.role) do %>
<li>
<a href={~p"/servers/"} class={selected_navbar_link_css(@page_title, "Listing Server")} aria-current="page">Servers</a>
</li>