cannery/lib/cannery_web/live/invite_live/index.html.heex

158 lines
4.9 KiB
Plaintext
Raw Normal View History

2022-02-15 18:44:07 -05:00
<div class="w-full flex flex-col space-y-8 justify-center items-center">
<h1 class="title text-2xl title-primary-500">
2022-02-15 17:33:07 -05:00
<%= gettext("Invites") %>
</h1>
<%= if @invites |> Enum.empty?() do %>
2022-02-17 22:29:01 -05:00
<h1 class="title text-xl text-primary-600">
2022-02-15 23:52:44 -05:00
<%= gettext("No invites") %>
<%= display_emoji("😔") %>
</h1>
<%= live_patch(dgettext("actions", "Invite someone new!"),
2022-02-17 22:31:37 -05:00
to: Routes.invite_index_path(Endpoint, :new),
class: "btn btn-primary"
) %>
<% else %>
<%= live_patch(dgettext("actions", "Create Invite"),
2022-02-17 22:31:37 -05:00
to: Routes.invite_index_path(Endpoint, :new),
class: "btn btn-primary"
) %>
<% end %>
2022-02-15 18:44:07 -05:00
<div class="w-full flex flex-row flex-wrap justify-center items-center">
<%= for invite <- @invites do %>
<.invite_card invite={invite}>
2022-02-15 19:50:48 -05:00
<:code_actions>
2022-02-18 17:43:22 -05:00
<form phx-submit="copy_to_clipboard">
2022-02-15 19:50:48 -05:00
<button
type="submit"
2022-02-15 23:52:44 -05:00
class="mx-2 my-1 btn btn-primary"
2022-02-18 17:43:22 -05:00
phx-click={JS.dispatch("cannery:clipcopy", to: "#code-#{invite.id}")}
2022-02-15 19:50:48 -05:00
>
<%= dgettext("actions", "Copy to clipboard") %>
</button>
</form>
</:code_actions>
<%= live_patch to: Routes.invite_index_path(Endpoint, :edit, invite),
2022-02-17 22:29:01 -05:00
class: "text-primary-600 link",
2022-02-16 22:39:53 -05:00
data: [qa: "edit-#{invite.id}"] do %>
<i class="fa-fw fa-lg fas fa-edit"></i>
<% end %>
<%= link to: "#",
2022-02-17 22:29:01 -05:00
class: "text-primary-600 link",
phx_click: "delete_invite",
phx_value_id: invite.id,
data: [
confirm:
dgettext("prompts", "Are you sure you want to delete the invite for %{name}?",
name: invite.name
2022-02-16 22:39:53 -05:00
),
qa: "delete-#{invite.id}"
] do %>
<i class="fa-fw fa-lg fas fa-trash"></i>
<% end %>
<%= if invite.disabled_at |> is_nil() do %>
<a href="#" class="btn btn-primary" phx-click="disable_invite" phx-value-id={invite.id}>
<%= gettext("Disable") %>
</a>
<% else %>
<a href="#" class="btn btn-primary" phx-click="enable_invite" phx-value-id={invite.id}>
<%= gettext("Enable") %>
</a>
<% end %>
<%= if invite.disabled_at |> is_nil() and not (invite.uses_left |> is_nil()) do %>
<a
href="#"
class="btn btn-primary"
phx-click="set_unlimited"
phx-value-id={invite.id}
2022-02-17 21:24:59 -05:00
data-confirm={
dgettext("prompts", "Are you sure you want to make %{name} unlimited?",
name: invite.name
)
}
>
<%= gettext("Set Unlimited") %>
</a>
<% end %>
</.invite_card>
<% end %>
</div>
<%= unless @admins |> Enum.empty?() do %>
2022-02-17 21:24:59 -05:00
<hr class="hr" />
2022-02-17 22:29:01 -05:00
<h1 class="title text-2xl text-primary-600">
2022-02-15 18:44:07 -05:00
<%= gettext("Admins") %>
</h1>
2022-02-15 18:44:07 -05:00
<div class="w-full flex flex-row flex-wrap justify-center items-center">
<%= for admin <- @admins do %>
<.user_card user={admin}>
<%= link to: "#",
2022-02-17 22:29:01 -05:00
class: "text-primary-600 link",
phx_click: "delete_user",
phx_value_id: admin.id,
data: [
confirm:
dgettext(
"prompts",
"Are you sure you want to delete %{email}? This action is permanent!",
email: admin.email
)
] do %>
<i class="fa-fw fa-lg fas fa-trash"></i>
<% end %>
</.user_card>
<% end %>
</div>
<% end %>
<%= unless @users |> Enum.empty?() do %>
2022-02-17 21:24:59 -05:00
<hr class="hr" />
2022-02-17 22:29:01 -05:00
<h1 class="title text-2xl text-primary-600">
2022-02-15 18:44:07 -05:00
<%= gettext("Users") %>
</h1>
2022-02-15 18:44:07 -05:00
<div class="w-full flex flex-row flex-wrap justify-center items-center">
<%= for user <- @users do %>
<.user_card user={user}>
<%= link to: "#",
2022-02-17 22:29:01 -05:00
class: "text-primary-600 link",
phx_click: "delete_user",
phx_value_id: user.id,
data: [
confirm:
dgettext(
"prompts",
"Are you sure you want to delete %{email}? This action is permanent!",
email: user.email
)
] do %>
<i class="fa-fw fa-lg fas fa-trash"></i>
<% end %>
</.user_card>
<% end %>
</div>
<% end %>
</div>
<%= if @live_action in [:new, :edit] do %>
2022-02-17 22:31:37 -05:00
<.modal return_to={Routes.invite_index_path(Endpoint, :index)}>
2022-02-14 01:26:51 -05:00
<.live_component
module={CanneryWeb.InviteLive.FormComponent}
id={@invite.id || :new}
title={@page_title}
action={@live_action}
invite={@invite}
2022-02-17 22:31:37 -05:00
return_to={Routes.invite_index_path(Endpoint, :index)}
2022-02-14 01:26:51 -05:00
current_user={@current_user}
/>
</.modal>
<% end %>