defmodule CanneryWeb.Components.InviteCard do @moduledoc """ Display card for an invite """ use CanneryWeb, :component alias Cannery.Invites.Invite alias CanneryWeb.Endpoint attr :invite, Invite, required: true slot(:inner_block) slot(:code_actions) def invite_card(assigns) do assigns = assigns |> assign_new(:code_actions, fn -> [] end) ~H"""

<%= @invite.name %>

<%= if @invite.disabled_at |> is_nil() do %>

<%= gettext("Uses Left:") %> <%= @invite.uses_left || "Unlimited" %>

<% else %>

<%= gettext("Invite Disabled") %>

<% end %>
<%= Routes.user_registration_url(Endpoint, :new, invite: @invite.token) %> <%= render_slot(@code_actions) %>
<%= if @inner_block do %>
<%= render_slot(@inner_block) %>
<% end %>
""" end end