memEx/lib/memex_web/live/invite_live/index.html.heex

166 lines
4.8 KiB
Plaintext
Raw Normal View History

2023-02-14 01:04:15 -05:00
<div class="mx-auto flex flex-col justify-center items-stretch space-y-4 max-w-3xl">
<h1 class="title text-xl title-primary-500">
2022-11-17 22:30:01 -05:00
<%= gettext("invites") %>
2022-02-25 22:13:35 -05:00
</h1>
<%= if @invites |> Enum.empty?() do %>
2022-07-25 22:04:10 -04:00
<h1 class="title text-xl text-primary-400">
2022-11-17 22:30:01 -05:00
<%= gettext("no invites 😔") %>
2022-02-25 22:13:35 -05:00
</h1>
2023-01-26 00:28:34 -05:00
<.link patch={Routes.invite_index_path(Endpoint, :new)} class="btn btn-primary">
2022-11-17 22:30:01 -05:00
<%= dgettext("actions", "invite someone new!") %>
2022-11-16 21:11:02 -05:00
</.link>
2022-02-25 22:13:35 -05:00
<% end %>
2023-02-14 01:04:15 -05:00
<div class="flex flex-col justify-center items-stretch space-y-4">
2023-03-18 13:46:26 -04:00
<.invite_card
:for={invite <- @invites}
invite={invite}
current_user={@current_user}
use_count={Map.get(@use_counts, invite.id)}
>
2023-02-04 11:29:06 -05:00
<:code_actions>
<form phx-submit="copy_to_clipboard">
<button
type="submit"
2023-02-14 01:04:15 -05:00
class="mx-2 my-1 btn btn-secondary"
2023-02-04 11:29:06 -05:00
phx-click={JS.dispatch("memex:clipcopy", to: "#code-#{invite.id}")}
aria-label={
dgettext("actions", "copy invite link for %{invite_name}", invite_name: invite.name)
}
2023-02-04 11:29:06 -05:00
>
2023-02-14 01:04:15 -05:00
<%= dgettext("actions", "copy") %>
2023-02-04 11:29:06 -05:00
</button>
</form>
</:code_actions>
<.link
patch={Routes.invite_index_path(Endpoint, :edit, invite)}
class="text-primary-400 link"
aria-label={
dgettext("actions", "edit invite for %{invite_name}", invite_name: invite.name)
}
2023-02-04 11:29:06 -05:00
>
<i class="fa-fw fa-lg fas fa-edit"></i>
</.link>
2022-02-25 22:13:35 -05:00
2023-02-04 11:29:06 -05:00
<.link
href="#"
class="text-primary-400 link"
phx-click="delete_invite"
phx-value-id={invite.id}
data-confirm={
dgettext("prompts", "are you sure you want to delete the invite for %{invite_name}?",
invite_name: invite.name
)
}
aria-label={
dgettext("actions", "delete invite for %{invite_name}", invite_name: invite.name)
}
2023-02-04 11:29:06 -05:00
>
<i class="fa-fw fa-lg fas fa-trash"></i>
</.link>
2022-02-25 22:13:35 -05:00
2023-03-18 00:46:03 -04:00
<.link
2023-02-04 11:29:06 -05:00
href="#"
2023-02-14 01:04:15 -05:00
class="btn btn-secondary"
2023-02-04 11:29:06 -05:00
phx-click={if invite.disabled_at, do: "enable_invite", else: "disable_invite"}
phx-value-id={invite.id}
>
<%= if invite.disabled_at, do: gettext("enable"), else: gettext("disable") %>
2023-03-18 00:46:03 -04:00
</.link>
2022-02-25 22:13:35 -05:00
2023-03-18 00:46:03 -04:00
<.link
2023-02-04 11:29:06 -05:00
:if={invite.disabled_at |> is_nil() and not (invite.uses_left |> is_nil())}
href="#"
2023-02-14 01:04:15 -05:00
class="btn btn-secondary"
2023-02-04 11:29:06 -05:00
phx-click="set_unlimited"
phx-value-id={invite.id}
data-confirm={
dgettext("prompts", "are you sure you want to make %{invite_name} unlimited?",
invite_name: invite.name
)
}
>
<%= gettext("set unlimited") %>
2023-03-18 00:46:03 -04:00
</.link>
2023-02-04 11:29:06 -05:00
</.invite_card>
2023-02-14 01:04:15 -05:00
<.link
:if={@invites != []}
patch={Routes.invite_index_path(Endpoint, :new)}
class="btn btn-primary ml-auto"
>
<%= dgettext("actions", "create invite") %>
</.link>
2022-02-25 22:13:35 -05:00
</div>
<%= unless @admins |> Enum.empty?() do %>
<hr class="hr" />
2023-02-14 01:04:15 -05:00
<h1 class="title text-xl text-primary-400">
2023-02-26 01:47:26 -05:00
<%= gettext("admins") %>
2022-02-25 22:13:35 -05:00
</h1>
2023-02-14 01:04:15 -05:00
<div class="flex flex-col justify-center items-stretch space-y-4">
2023-02-04 11:29:06 -05:00
<.user_card :for={admin <- @admins} user={admin}>
<.link
href="#"
class="text-primary-400 link"
phx-click="delete_user"
phx-value-id={admin.id}
data-confirm={
dgettext(
"prompts",
2023-02-26 01:47:26 -05:00
"are you sure you want to delete %{email}? this action is permanent!",
2023-02-04 11:29:06 -05:00
email: admin.email
)
}
>
<i class="fa-fw fa-lg fas fa-trash"></i>
</.link>
</.user_card>
2022-02-25 22:13:35 -05:00
</div>
<% end %>
<%= unless @users |> Enum.empty?() do %>
<hr class="hr" />
2023-02-14 01:04:15 -05:00
<h1 class="title text-xl text-primary-400">
2022-11-17 22:30:01 -05:00
<%= gettext("users") %>
2022-02-25 22:13:35 -05:00
</h1>
2023-02-14 01:04:15 -05:00
<div class="flex flex-col justify-center items-stretch space-y-4">
2023-02-04 11:29:06 -05:00
<.user_card :for={user <- @users} user={user}>
<.link
href="#"
class="text-primary-400 link"
phx-click="delete_user"
phx-value-id={user.id}
data-confirm={
dgettext(
"prompts",
2023-02-26 01:47:26 -05:00
"are you sure you want to delete %{email}? this action is permanent!",
2023-02-04 11:29:06 -05:00
email: user.email
)
}
>
<i class="fa-fw fa-lg fas fa-trash"></i>
</.link>
</.user_card>
2022-02-25 22:13:35 -05:00
</div>
<% end %>
</div>
2023-02-04 11:29:06 -05:00
<.modal :if={@live_action in [:new, :edit]} return_to={Routes.invite_index_path(Endpoint, :index)}>
<.live_component
module={MemexWeb.InviteLive.FormComponent}
id={@invite.id || :new}
title={@page_title}
action={@live_action}
invite={@invite}
return_to={Routes.invite_index_path(Endpoint, :index)}
current_user={@current_user}
/>
</.modal>