2023-02-26 18:21:14 -05:00
|
|
|
<div class="mx-auto flex flex-col justify-center items-center space-y-4 max-w-3xl">
|
2022-02-12 02:28:27 -05:00
|
|
|
<h1 class="title text-2xl title-primary-500">
|
2022-02-15 17:33:07 -05:00
|
|
|
<%= gettext("Invites") %>
|
2022-02-12 02:28:27 -05:00
|
|
|
</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("😔") %>
|
2022-02-12 02:28:27 -05:00
|
|
|
</h1>
|
|
|
|
|
2023-04-14 23:34:11 -04:00
|
|
|
<.link patch={~p"/invites/new"} class="btn btn-primary">
|
2022-11-07 22:36:38 -05:00
|
|
|
<%= dgettext("actions", "Invite someone new!") %>
|
|
|
|
</.link>
|
2022-02-12 02:28:27 -05:00
|
|
|
<% else %>
|
2023-04-14 23:34:11 -04:00
|
|
|
<.link patch={~p"/invites/new"} class="btn btn-primary">
|
2022-11-07 22:36:38 -05:00
|
|
|
<%= dgettext("actions", "Create Invite") %>
|
|
|
|
</.link>
|
2022-02-12 02:28:27 -05:00
|
|
|
<% end %>
|
|
|
|
|
2023-02-26 18:21:14 -05:00
|
|
|
<div class="flex flex-col justify-center items-stretch space-y-4">
|
2023-03-18 21:06:00 -04:00
|
|
|
<.invite_card
|
|
|
|
:for={invite <- @invites}
|
|
|
|
invite={invite}
|
|
|
|
current_user={@current_user}
|
|
|
|
use_count={Map.get(@use_counts, invite.id)}
|
|
|
|
>
|
2023-02-04 10:28:13 -05:00
|
|
|
<:code_actions>
|
|
|
|
<form phx-submit="copy_to_clipboard">
|
|
|
|
<button
|
|
|
|
type="submit"
|
|
|
|
class="mx-2 my-1 btn btn-primary"
|
|
|
|
phx-click={JS.dispatch("cannery:clipcopy", to: "#code-#{invite.id}")}
|
2023-03-17 21:00:24 -04:00
|
|
|
aria-label={
|
|
|
|
dgettext("actions", "Copy invite link for %{invite_name}", invite_name: invite.name)
|
|
|
|
}
|
2023-02-04 10:28:13 -05:00
|
|
|
>
|
|
|
|
<%= dgettext("actions", "Copy to clipboard") %>
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</:code_actions>
|
|
|
|
<.link
|
2023-04-14 23:34:11 -04:00
|
|
|
patch={~p"/invites/#{invite}/edit"}
|
2023-02-04 10:28:13 -05:00
|
|
|
class="text-primary-600 link"
|
2023-03-17 21:00:24 -04:00
|
|
|
aria-label={
|
|
|
|
dgettext("actions", "Edit invite for %{invite_name}", invite_name: invite.name)
|
|
|
|
}
|
2023-02-04 10:28:13 -05:00
|
|
|
>
|
|
|
|
<i class="fa-fw fa-lg fas fa-edit"></i>
|
|
|
|
</.link>
|
2022-02-12 02:28:27 -05:00
|
|
|
|
2023-02-04 10:28:13 -05:00
|
|
|
<.link
|
|
|
|
href="#"
|
|
|
|
class="text-primary-600 link"
|
|
|
|
phx-click="delete_invite"
|
|
|
|
phx-value-id={invite.id}
|
|
|
|
data-confirm={
|
2023-02-04 16:46:37 -05:00
|
|
|
dgettext("prompts", "Are you sure you want to delete the invite for %{invite_name}?",
|
|
|
|
invite_name: invite.name
|
2023-02-04 10:28:13 -05:00
|
|
|
)
|
|
|
|
}
|
2023-03-17 21:00:24 -04:00
|
|
|
aria-label={
|
|
|
|
dgettext("actions", "Delete invite for %{invite_name}", invite_name: invite.name)
|
|
|
|
}
|
2023-02-04 10:28:13 -05:00
|
|
|
>
|
|
|
|
<i class="fa-fw fa-lg fas fa-trash"></i>
|
|
|
|
</.link>
|
2022-02-12 02:28:27 -05:00
|
|
|
|
2023-03-18 01:03:55 -04:00
|
|
|
<.link
|
2023-02-04 10:28:13 -05:00
|
|
|
href="#"
|
|
|
|
class="btn btn-primary"
|
|
|
|
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 01:03:55 -04:00
|
|
|
</.link>
|
2022-02-12 02:28:27 -05:00
|
|
|
|
2023-03-18 01:03:55 -04:00
|
|
|
<.link
|
2023-02-04 10:28:13 -05:00
|
|
|
:if={invite.disabled_at |> is_nil() and not (invite.uses_left |> is_nil())}
|
|
|
|
href="#"
|
|
|
|
class="btn btn-primary"
|
|
|
|
phx-click="set_unlimited"
|
|
|
|
phx-value-id={invite.id}
|
|
|
|
data-confirm={
|
2023-02-04 16:46:37 -05:00
|
|
|
dgettext("prompts", "Are you sure you want to make %{invite_name} unlimited?",
|
|
|
|
invite_name: invite.name
|
2023-02-04 10:28:13 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<%= dgettext("actions", "Set Unlimited") %>
|
2023-03-18 01:03:55 -04:00
|
|
|
</.link>
|
2023-02-04 10:28:13 -05:00
|
|
|
</.invite_card>
|
2022-02-12 02:28:27 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<%= unless @admins |> Enum.empty?() do %>
|
2022-02-17 21:24:59 -05:00
|
|
|
<hr class="hr" />
|
2022-02-12 02:28:27 -05:00
|
|
|
|
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-12 02:28:27 -05:00
|
|
|
|
2023-02-26 18:21:14 -05:00
|
|
|
<div class="flex flex-col justify-center items-stretch space-y-4">
|
2023-02-04 10:28:13 -05:00
|
|
|
<.user_card :for={admin <- @admins} user={admin}>
|
|
|
|
<.link
|
|
|
|
href="#"
|
|
|
|
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
|
|
|
|
)
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<i class="fa-fw fa-lg fas fa-trash"></i>
|
|
|
|
</.link>
|
|
|
|
</.user_card>
|
2022-02-12 02:28:27 -05:00
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
<%= unless @users |> Enum.empty?() do %>
|
2022-02-17 21:24:59 -05:00
|
|
|
<hr class="hr" />
|
2022-02-12 02:28:27 -05:00
|
|
|
|
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-12 02:28:27 -05:00
|
|
|
|
2023-02-26 18:21:14 -05:00
|
|
|
<div class="flex flex-col justify-center items-stretch space-y-4">
|
2023-02-04 10:28:13 -05:00
|
|
|
<.user_card :for={user <- @users} user={user}>
|
|
|
|
<.link
|
|
|
|
href="#"
|
|
|
|
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
|
|
|
|
)
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<i class="fa-fw fa-lg fas fa-trash"></i>
|
|
|
|
</.link>
|
|
|
|
</.user_card>
|
2022-02-12 02:28:27 -05:00
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
|
2023-04-14 23:34:11 -04:00
|
|
|
<.modal :if={@live_action in [:new, :edit]} return_to={~p"/invites"}>
|
2023-02-04 10:28:13 -05:00
|
|
|
<.live_component
|
|
|
|
module={CanneryWeb.InviteLive.FormComponent}
|
|
|
|
id={@invite.id || :new}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
invite={@invite}
|
2023-04-14 23:34:11 -04:00
|
|
|
return_to={~p"/invites"}
|
2023-02-04 10:28:13 -05:00
|
|
|
current_user={@current_user}
|
|
|
|
/>
|
|
|
|
</.modal>
|