defmodule PowInvitation.Phoenix.InvitationHTML do @moduledoc false use Pow.Phoenix.Template # Credo will complain about unless statement but we want this first # credo:disable-for-next-line unless Pow.dependency_vsn_match?(:phoenix, "< 1.7.0") do template :new, :html, """
<.header class="text-center"> Invite <.simple_form :let={f} for={<%= "@changeset" %>} as={:user} action={<%= "@action" %>} phx-update="ignore"> <.error :if={<%= "@changeset.action" %>}>Oops, something went wrong! Please check the errors below. <.input field={<%= "f[\#{__user_id_field__("@changeset", :key)}]" %>} type={<%= __user_id_field__("@changeset", :type) %>} label={<%= __user_id_field__("@changeset", :label) %>} required /> <:actions> <.button phx-disable-with="Submitting..." class="w-full"> Submit
""" template :edit, :html, """
<.header class="text-center"> Register <:subtitle> Already have an account? <.link navigate={<%= __inline_route__(Pow.Phoenix.SessionController, :new) %>} class="font-semibold text-brand hover:underline"> Sign in now. <.simple_form :let={f} for={<%= "@changeset" %>} as={:user} action={<%= "@action" %>} phx-update="ignore"> <.error :if={<%= "@changeset.action" %>}>Oops, something went wrong! Please check the errors below. <.input field={<%= "f[\#{__user_id_field__("@changeset", :key)}]" %>} type={<%= __user_id_field__("@changeset", :type) %>} label={<%= __user_id_field__("@changeset", :label) %>} required /> <.input field={<%= "f[:password]" %>} type="password" label="Password" required /> <.input field={<%= "f[:password_confirmation]" %>} type="password" label="Confirm password" required /> <:actions> <.button phx-disable-with="Submitting..." class="w-full"> Submit
""" template :show, :html, """
<.header class="text-center"> Invitation URL <:subtitle> Please send the following URL to the invitee.
<.input name="invite-url" type="text" id="invite-url" value={<%= "@url" %>} class="mt-0" readonly /> <.button phx-click={JS.dispatch("phx:share", to: "#invite-url")} aria-label={"Share"} class="mt-2"> <.icon name="hero-arrow-up-on-square" class="w-6 h-6" />
""" else # TODO: Remove when Phoenix 1.7 required template :new, :html, """

Invite

<%= render_form([ {:text, {:changeset, :pow_user_id_field}} ]) %> """ template :edit, :html, """

Register

<%= render_form([ {:text, {:changeset, :pow_user_id_field}}, {:password, :password}, {:password, :password_confirmation} ]) %> <%%= link "Sign in", to: <%= __inline_route__(Pow.Phoenix.SessionController, :new) %> %> """ template :show, :html, """

Invitation

<%%= @url %>
""" end end