defmodule DexiWeb.AccountComponents do
@moduledoc false
use DexiWeb, :html
alias Dexi.Accounts
attr :user, :any, required: true
def account_preview(assigns) do
~H"""
<.detail label="Public key" value={@user.pubkey} id="account-pubkey" wide monospace />
<.detail label="Name" value={@user.name || "Not provided"} id="account-name" />
<.detail label="Email" value={@user.email || "Not provided"} id="account-email" />
Email confirmed
<.detail label="Role" value={@user.role} id="account-role" capitalize />
Edit account
"""
end
attr :form, :any, required: true
def profile_editor(assigns) do
~H"""
Cancel editing
<.form
for={@form}
id="profile-form"
phx-change="validate"
phx-submit="save"
class={["space-y-5"]}
>
<.input
field={@form[:email]}
type="email"
label="Email (optional, we may reach out to you)"
/>
<.input field={@form[:name]} type="text" label="Name (optional)" />
Save account
"""
end
attr :user, :any, required: true
attr :form, :any, required: true
def email_confirmation_panel(assigns) do
~H"""
Confirm {@user.email}
Enter the six-digit code sent to your email. Codes expire after 15 minutes.
Send confirmation code
<.form
:if={Accounts.email_confirmation_active?(@user)}
for={@form}
id="email-confirmation-form"
phx-submit="confirm-email"
class={["mt-4 space-y-4"]}
>
<.input
field={@form[:code]}
type="text"
label="Confirmation code"
inputmode="numeric"
autocomplete="one-time-code"
maxlength="6"
required
/>
Confirm email
Resend code
"""
end
attr :label, :string, required: true
attr :value, :any, required: true
attr :id, :string, required: true
attr :wide, :boolean, default: false
attr :monospace, :boolean, default: false
attr :capitalize, :boolean, default: false
defp detail(assigns) do
~H"""
"""
end
end