update to liveview 0.18
This commit is contained in:
@ -7,6 +7,8 @@ defmodule LokalWeb.Components.InviteCard do
|
||||
alias LokalWeb.Endpoint
|
||||
|
||||
def invite_card(assigns) do
|
||||
assigns = assigns |> assign_new(:code_actions, fn -> [] end)
|
||||
|
||||
~H"""
|
||||
<div class="mx-4 my-2 px-8 py-4 flex flex-col justify-center items-center space-y-4
|
||||
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
|
||||
@ -17,8 +19,14 @@ defmodule LokalWeb.Components.InviteCard do
|
||||
|
||||
<%= if @invite.disabled_at |> is_nil() do %>
|
||||
<h2 class="title text-md">
|
||||
<%= gettext("Uses Left:") %>
|
||||
<%= @invite.uses_left || "Unlimited" %>
|
||||
<%= if @invite.uses_left do %>
|
||||
<%= gettext(
|
||||
"Uses Left: %{uses_left}",
|
||||
uses_left: @invite.uses_left
|
||||
) %>
|
||||
<% else %>
|
||||
<%= gettext("Uses Left: Unlimited") %>
|
||||
<% end %>
|
||||
</h2>
|
||||
<% else %>
|
||||
<h2 class="title text-md">
|
||||
@ -30,13 +38,9 @@ defmodule LokalWeb.Components.InviteCard do
|
||||
<code
|
||||
id={"code-#{@invite.id}"}
|
||||
class="mx-2 my-1 text-xs px-4 py-2 rounded-lg text-center break-all text-gray-100 bg-primary-800"
|
||||
>
|
||||
<%= Routes.user_registration_url(Endpoint, :new, invite: @invite.token) %>
|
||||
</code>
|
||||
|
||||
<%= if @code_actions do %>
|
||||
<%= render_slot(@code_actions) %>
|
||||
<% end %>
|
||||
phx-no-format
|
||||
><%= Routes.user_registration_url(Endpoint, :new, invite: @invite.token) %></code>
|
||||
<%= render_slot(@code_actions) %>
|
||||
</div>
|
||||
|
||||
<%= if @inner_block do %>
|
||||
|
@ -16,10 +16,12 @@ defmodule LokalWeb.Components.Topbar do
|
||||
<nav role="navigation" class="mb-8 px-8 py-4 w-full bg-primary-400">
|
||||
<div class="flex flex-col sm:flex-row justify-between items-center">
|
||||
<div class="mb-4 sm:mb-0 sm:mr-8 flex flex-row justify-start items-center space-x-2">
|
||||
<%= live_redirect("Lokal",
|
||||
to: Routes.live_path(Endpoint, HomeLive),
|
||||
class: "mx-2 my-1 leading-5 text-xl text-white hover:underline"
|
||||
) %>
|
||||
<.link
|
||||
navigate={Routes.live_path(Endpoint, HomeLive)}
|
||||
class="mx-2 my-1 leading-5 text-xl text-white hover:underline"
|
||||
>
|
||||
<%= gettext("Lokal") %>
|
||||
</.link>
|
||||
|
||||
<%= if @title_content do %>
|
||||
<span class="mx-2 my-1">
|
||||
@ -53,47 +55,59 @@ defmodule LokalWeb.Components.Topbar do
|
||||
</form>
|
||||
<%= if @current_user.role == :admin do %>
|
||||
<li class="mx-2 my-1">
|
||||
<%= live_redirect(gettext("Invites"),
|
||||
to: Routes.invite_index_path(Endpoint, :index),
|
||||
class: "text-white text-white hover:underline"
|
||||
) %>
|
||||
<.link
|
||||
navigate={Routes.invite_index_path(Endpoint, :index)}
|
||||
class="text-white text-white hover:underline"
|
||||
>
|
||||
<%= gettext("Invites") %>
|
||||
</.link>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="mx-2 my-1">
|
||||
<%= live_redirect(@current_user.email,
|
||||
to: Routes.user_settings_path(Endpoint, :edit),
|
||||
class: "text-white text-white hover:underline truncate"
|
||||
) %>
|
||||
<.link
|
||||
navigate={Routes.user_settings_path(Endpoint, :edit)}
|
||||
class="text-white text-white hover:underline truncate"
|
||||
>
|
||||
<%= @current_user.email %>
|
||||
</.link>
|
||||
</li>
|
||||
<li class="mx-2 my-1">
|
||||
<%= link to: Routes.user_session_path(Endpoint, :delete),
|
||||
method: :delete,
|
||||
data: [confirm: dgettext("prompts", "Are you sure you want to log out?")] do %>
|
||||
<.link
|
||||
href={Routes.user_session_path(Endpoint, :delete)}
|
||||
method="delete"
|
||||
data-confirm={dgettext("prompts", "Are you sure you want to log out?")}
|
||||
>
|
||||
<i class="fas fa-sign-out-alt"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</li>
|
||||
<%= if @current_user.role == :admin and function_exported?(Routes, :live_dashboard_path, 2) do %>
|
||||
<li class="mx-2 my-1">
|
||||
<%= live_redirect to: Routes.live_dashboard_path(Endpoint, :home),
|
||||
class: "text-white text-white hover:underline" do %>
|
||||
<.link
|
||||
navigate={Routes.live_dashboard_path(Endpoint, :home)}
|
||||
class="text-white text-white hover:underline"
|
||||
>
|
||||
<i class="fas fa-gauge"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</li>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= if Accounts.allow_registration?() do %>
|
||||
<li class="mx-2 my-1">
|
||||
<%= live_redirect(dgettext("actions", "Register"),
|
||||
to: Routes.user_registration_path(Endpoint, :new),
|
||||
class: "text-white text-white hover:underline truncate"
|
||||
) %>
|
||||
<.link
|
||||
navigate={Routes.user_registration_path(Endpoint, :new)}
|
||||
class="text-white text-white hover:underline truncate"
|
||||
>
|
||||
<%= dgettext("actions", "Register") %>
|
||||
</.link>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="mx-2 my-1">
|
||||
<%= live_redirect(dgettext("actions", "Log in"),
|
||||
to: Routes.user_session_path(Endpoint, :new),
|
||||
class: "text-white text-white hover:underline truncate"
|
||||
) %>
|
||||
<.link
|
||||
navigate={Routes.user_session_path(Endpoint, :new)}
|
||||
class="text-white text-white hover:underline truncate"
|
||||
>
|
||||
<%= dgettext("actions", "Log in") %>
|
||||
</.link>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
@ -19,16 +19,23 @@ defmodule LokalWeb.Components.UserCard do
|
||||
|
||||
<h3 class="px-4 py-2 rounded-lg title text-lg">
|
||||
<p>
|
||||
<%= if @user.confirmed_at |> is_nil() do %>
|
||||
Email unconfirmed
|
||||
<%= if @user.confirmed_at do %>
|
||||
<%= gettext(
|
||||
"User was confirmed at%{confirmed_datetime}",
|
||||
confirmed_datetime: ""
|
||||
) %>
|
||||
<.datetime datetime={@user.confirmed_at} />
|
||||
<% else %>
|
||||
User was confirmed at <%= @user.confirmed_at |> display_datetime() %>
|
||||
<%= gettext("Email unconfirmed") %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= gettext("User registered on") %>
|
||||
<%= @user.inserted_at |> display_datetime() %>
|
||||
<%= gettext(
|
||||
"User registered on%{registered_datetime}",
|
||||
registered_datetime: ""
|
||||
) %>
|
||||
<.datetime datetime={@user.inserted_at} />
|
||||
</p>
|
||||
</h3>
|
||||
|
||||
|
Reference in New Issue
Block a user