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

160 lines
4.8 KiB
Plaintext
Raw Normal View History

2022-02-25 22:13:35 -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-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>
2022-11-16 21:11:02 -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
<% else %>
2022-11-16 21:11:02 -05:00
<.link patch={Routes.invite_index_path(Endpoint, :new)} class="btn btn-primary">
2022-11-17 22:30:01 -05:00
<%= dgettext("actions", "create invite") %>
2022-11-16 21:11:02 -05:00
</.link>
2022-02-25 22:13:35 -05:00
<% end %>
<div class="w-full flex flex-row flex-wrap justify-center items-center">
<%= for invite <- @invites do %>
<.invite_card invite={invite}>
<:code_actions>
<form phx-submit="copy_to_clipboard">
<button
type="submit"
class="mx-2 my-1 btn btn-primary"
2022-07-25 19:31:54 -04:00
phx-click={JS.dispatch("memex:clipcopy", to: "#code-#{invite.id}")}
2022-02-25 22:13:35 -05:00
>
<%= dgettext("actions", "Copy to clipboard") %>
</button>
</form>
</:code_actions>
2022-11-16 21:11:02 -05:00
<.link
patch={Routes.invite_index_path(Endpoint, :edit, invite)}
class="text-primary-400 link"
data-qa={"edit-#{invite.id}"}
>
2022-02-25 22:13:35 -05:00
<i class="fa-fw fa-lg fas fa-edit"></i>
2022-11-16 21:11:02 -05:00
</.link>
2022-02-25 22:13:35 -05:00
2022-11-16 21:11:02 -05:00
<.link
href="#"
class="text-primary-400 link"
phx-click="delete_invite"
phx-value-id={invite.id}
data-confirm={
2022-11-17 22:30:01 -05:00
dgettext("prompts", "are you sure you want to delete the invite for %{invite_name}?",
2022-11-16 21:11:02 -05:00
invite_name: invite.name
)
}
data-qa={"delete-#{invite.id}"}
>
2022-02-25 22:13:35 -05:00
<i class="fa-fw fa-lg fas fa-trash"></i>
2022-11-16 21:11:02 -05:00
</.link>
2022-02-25 22:13:35 -05:00
<%= if invite.disabled_at |> is_nil() do %>
<a href="#" class="btn btn-primary" phx-click="disable_invite" phx-value-id={invite.id}>
2022-11-17 22:30:01 -05:00
<%= gettext("disable") %>
2022-02-25 22:13:35 -05:00
</a>
<% else %>
<a href="#" class="btn btn-primary" phx-click="enable_invite" phx-value-id={invite.id}>
2022-11-17 22:30:01 -05:00
<%= gettext("enable") %>
2022-02-25 22:13:35 -05:00
</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}
data-confirm={
2022-11-17 22:30:01 -05:00
dgettext("prompts", "are you sure you want to make %{invite_name} unlimited?",
2022-05-05 21:47:22 -04:00
invite_name: invite.name
2022-02-25 22:13:35 -05:00
)
}
>
2022-11-17 22:30:01 -05:00
<%= gettext("set unlimited") %>
2022-02-25 22:13:35 -05:00
</a>
<% end %>
</.invite_card>
<% end %>
</div>
<%= unless @admins |> Enum.empty?() do %>
<hr class="hr" />
2022-07-25 22:04:10 -04:00
<h1 class="title text-2xl text-primary-400">
2022-02-25 22:13:35 -05:00
<%= gettext("Admins") %>
</h1>
<div class="w-full flex flex-row flex-wrap justify-center items-center">
<%= for admin <- @admins do %>
<.user_card user={admin}>
2022-11-16 21:11:02 -05:00
<.link
href="#"
class="text-primary-400 link"
phx-click="delete_user"
phx-value-id={admin.id}
data-confirm={
dgettext(
"prompts",
2022-11-17 22:30:01 -05:00
"are you sure you want to delete %{email}? This action is permanent!",
2022-11-16 21:11:02 -05:00
email: admin.email
)
}
>
2022-02-25 22:13:35 -05:00
<i class="fa-fw fa-lg fas fa-trash"></i>
2022-11-16 21:11:02 -05:00
</.link>
2022-02-25 22:13:35 -05:00
</.user_card>
<% end %>
</div>
<% end %>
<%= unless @users |> Enum.empty?() do %>
<hr class="hr" />
2022-07-25 22:04:10 -04:00
<h1 class="title text-2xl text-primary-400">
2022-11-17 22:30:01 -05:00
<%= gettext("users") %>
2022-02-25 22:13:35 -05:00
</h1>
<div class="w-full flex flex-row flex-wrap justify-center items-center">
<%= for user <- @users do %>
<.user_card user={user}>
2022-11-16 21:11:02 -05:00
<.link
href="#"
class="text-primary-400 link"
phx-click="delete_user"
phx-value-id={user.id}
data-confirm={
dgettext(
"prompts",
2022-11-17 22:30:01 -05:00
"are you sure you want to delete %{email}? This action is permanent!",
2022-11-16 21:11:02 -05:00
email: user.email
)
}
>
2022-02-25 22:13:35 -05:00
<i class="fa-fw fa-lg fas fa-trash"></i>
2022-11-16 21:11:02 -05:00
</.link>
2022-02-25 22:13:35 -05:00
</.user_card>
<% end %>
</div>
<% end %>
</div>
<%= if @live_action in [:new, :edit] do %>
<.modal return_to={Routes.invite_index_path(Endpoint, :index)}>
<.live_component
2022-07-25 19:31:54 -04:00
module={MemexWeb.InviteLive.FormComponent}
2022-02-25 22:13:35 -05:00
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>
<% end %>