2024-07-21 22:03:50 +05:00
|
|
|
|
defmodule ComfycampWeb.NavBar do
|
|
|
|
|
use Phoenix.Component
|
2024-07-28 18:03:48 +05:00
|
|
|
|
use ComfycampWeb, :verified_routes
|
2024-07-21 22:03:50 +05:00
|
|
|
|
|
|
|
|
|
alias Comfycamp.Accounts.User
|
|
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
|
Navigation bar.
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
<.navbar current_user={@current_user} />
|
|
|
|
|
"""
|
|
|
|
|
attr :current_user, User, required: false
|
|
|
|
|
|
|
|
|
|
def navbar(assigns) do
|
|
|
|
|
~H"""
|
|
|
|
|
<nav class="limiter navbar">
|
2024-07-28 18:03:48 +05:00
|
|
|
|
<.link href={~p"/"}>Главная</.link>
|
2024-07-29 18:07:44 +05:00
|
|
|
|
<.link href={~p"/notes"}>Заметки</.link>
|
|
|
|
|
<.link href={~p"/cinema"}>Кинотеатр</.link>
|
2024-07-21 22:03:50 +05:00
|
|
|
|
|
|
|
|
|
<div class="space" />
|
|
|
|
|
|
|
|
|
|
<%= if @current_user do %>
|
2024-07-28 21:52:12 +05:00
|
|
|
|
<.link :if={@current_user.is_admin} href={~p"/admin"}>
|
|
|
|
|
Админка
|
|
|
|
|
</.link>
|
2024-08-31 13:47:03 +05:00
|
|
|
|
<.link navigate={~p"/users/settings"}>
|
2024-07-21 22:03:50 +05:00
|
|
|
|
Настройки
|
|
|
|
|
</.link>
|
|
|
|
|
|
2024-07-28 18:03:48 +05:00
|
|
|
|
<.link href={~p"/users/log_out"} method="delete">
|
2024-07-21 22:03:50 +05:00
|
|
|
|
Выйти
|
|
|
|
|
</.link>
|
|
|
|
|
<% else %>
|
2024-08-31 13:47:03 +05:00
|
|
|
|
<.link navigate={~p"/users/register"}>
|
2024-07-21 22:03:50 +05:00
|
|
|
|
Зарегистрироваться
|
|
|
|
|
</.link>
|
|
|
|
|
|
2024-08-31 13:47:03 +05:00
|
|
|
|
<.link navigate={~p"/users/log_in"}>
|
2024-07-21 22:03:50 +05:00
|
|
|
|
Войти
|
|
|
|
|
</.link>
|
|
|
|
|
<% end %>
|
|
|
|
|
</nav>
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
end
|