memEx/lib/memex_web/components/invite_card.ex

50 lines
1.4 KiB
Elixir
Raw Normal View History

2022-07-25 19:31:54 -04:00
defmodule MemexWeb.Components.InviteCard do
2022-02-25 21:52:17 -05:00
@moduledoc """
Display card for an invite
"""
2022-07-25 19:31:54 -04:00
use MemexWeb, :component
2022-02-25 21:52:17 -05:00
def invite_card(assigns) do
~H"""
2022-05-05 21:07:02 -04:00
<div class="mx-4 my-2 px-8 py-4 flex flex-col justify-center items-center space-y-4
2022-02-25 21:52:17 -05:00
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
2022-05-05 21:07:02 -04:00
transition-all duration-300 ease-in-out">
2022-02-25 21:52:17 -05:00
<h1 class="title text-xl">
<%= @invite.name %>
</h1>
<%= if @invite.disabled_at |> is_nil() do %>
<h2 class="title text-md">
<%= gettext("Uses Left:") %>
2022-11-17 22:30:01 -05:00
<%= @invite.uses_left || gettext("unlimited") %>
2022-02-25 21:52:17 -05:00
</h2>
<% else %>
<h2 class="title text-md">
2022-11-17 22:30:01 -05:00
<%= gettext("invite disabled") %>
2022-02-25 21:52:17 -05:00
</h2>
<% end %>
<div class="flex flex-row flex-wrap justify-center items-center">
<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 %>
</div>
<%= if @inner_block do %>
<div class="flex space-x-4 justify-center items-center">
<%= render_slot(@inner_block) %>
</div>
<% end %>
</div>
"""
end
end