Listing Invites

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

No invites 😔

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

<%= invite.name %>

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

Uses Left: <%= invite.uses_left || "Unlimited" %>

<% else %>

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: "Are you sure you want to delete the invite for #{invite.name}?"] do %> <% end %> <%= if invite.disabled_at |> is_nil() do %> Disable <% else %> Enable <% end %> <%= if invite.disabled_at |> is_nil() and not(invite.uses_left |> is_nil()) do %> 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 %>