<%= gettext("Listing Invites") %>

<%= if @invites |> Enum.empty?() do %>

<%= gettext("No invites") %> 😔

<%= live_patch dgettext("actions", "Invite someone new!"), to: Routes.invite_index_path(@socket, :new), class: "btn btn-primary" %> <% else %> <%= live_patch dgettext("actions", "Create Invite"), to: Routes.invite_index_path(@socket, :new), class: "btn btn-primary" %> <% end %>
<%= for invite <- @invites do %>

<%= 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(@socket, :new, invite: invite.token) %>
<%= live_patch to: Routes.invite_index_path(@socket, :edit, invite), class: "text-primary-500 link" do %> <% end %> <%= link to: "#", class: "text-primary-500 link", phx_click: "delete", phx_value_id: invite.id, data: [confirm: dgettext("prompts", "Are you sure you want to delete the invite for %{name}?", name: invite.name)] do %> <% end %> <%= if invite.disabled_at |> is_nil() do %> <%= gettext("Disable") %> <% else %> <%= gettext("Enable") %> <% end %> <%= if invite.disabled_at |> is_nil() and not(invite.uses_left |> is_nil()) do %> <%= gettext("Set Unlimited") %> <% end %>
<% end %>
<%= if @live_action in [:new, :edit] do %> <%= live_modal CanneryWeb.InviteLive.FormComponent, id: @invite.id || :new, title: @page_title, action: @live_action, invite: @invite, return_to: Routes.invite_index_path(@socket, :index), current_user: @current_user %> <% end %>