forked from shibao/cannery
90 lines
3.0 KiB
Plaintext
90 lines
3.0 KiB
Plaintext
<div class="flex flex-col space-y-8 justify-center items-center">
|
|
<h1 class="title text-2xl title-primary-500">
|
|
Listing Invites
|
|
</h1>
|
|
|
|
<%= if @invites |> Enum.empty?() do %>
|
|
<div class="flex flex-col space-y-4 justify-center items-center">
|
|
<h1 class="title text-xl text-primary-500">
|
|
No invites 😔
|
|
</h1>
|
|
|
|
<%= live_patch to: Routes.invite_index_path(@socket, :new),
|
|
class: "btn btn-primary" do %>
|
|
Invite someone new!
|
|
<% end %>
|
|
</div>
|
|
<% else %>
|
|
<%= live_patch to: Routes.invite_index_path(@socket, :new),
|
|
class: "btn btn-primary" do %>
|
|
Invite
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<div class="flex flex-row flex-wrap space-x-4 space-y-4">
|
|
<%= for invite <- @invites do %>
|
|
<div class="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">
|
|
<h1 class="title text-xl text-primary-500">
|
|
<%= invite.name %>
|
|
</h1>
|
|
|
|
<%= if invite.disabled_at |> is_nil() do %>
|
|
<h2 class="title text-md text-primary-500">
|
|
Uses Left: <%= invite.uses_left || "Unlimited" %>
|
|
</h2>
|
|
<% else %>
|
|
<h2 class="title text-md text-primary-500">
|
|
Invite Disabled
|
|
</h2>
|
|
<% end %>
|
|
|
|
<code class="text-xs px-4 py-2 rounded-lg text-gray-100 bg-primary-800">
|
|
<%= Routes.user_registration_url(@socket, :new, invite: invite.token) %>
|
|
</code>
|
|
|
|
<div class="flex space-x-4 justify-center items-center">
|
|
<%= live_patch "Edit", to: Routes.invite_index_path(@socket, :edit, invite),
|
|
class: "text-primary-500 link" %>
|
|
|
|
<%= link "Delete", to: "#",
|
|
class: "text-primary-500 link",
|
|
phx_click: "delete",
|
|
phx_value_id: invite.id,
|
|
data: [confirm: "Are you sure?"] %>
|
|
|
|
<%= if invite.disabled_at |> is_nil() do %>
|
|
<a href="#" class="text-primary-500 link"
|
|
phx-click="disable" phx-value-id="<%= invite.id %>">
|
|
Disable
|
|
</a>
|
|
<% else %>
|
|
<a href="#" class="text-primary-500 link"
|
|
phx-click="enable" phx-value-id="<%= invite.id %>">
|
|
Enable
|
|
</a>
|
|
<% end %>
|
|
|
|
<%= if invite.disabled_at |> is_nil() and not(invite.uses_left |> is_nil()) do %>
|
|
<a href="#" class="text-primary-500 link"
|
|
phx-click="set_unlimited" phx-value-id="<%= invite.id %>"
|
|
data-confirm="Are you sure you want to make this invite unlimited?">
|
|
Set Unlimited
|
|
</a>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<%= 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 %>
|