memEx/lib/memex_web/controllers/user_settings_html/edit.html.heex
2024-07-28 13:00:40 -04:00

151 lines
5.0 KiB
Plaintext

<div class="mx-auto pb-8 max-w-3xl flex flex-col justify-center items-stretch text-right space-y-4">
<h1 class="title text-primary-400 text-xl text-left">
<%= gettext("settings") %>
</h1>
<hr class="hr" />
<.form
:let={f}
for={@email_changeset}
action={~p"/users/settings"}
class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center"
>
<h3 class="title text-primary-400 text-lg text-center col-span-3">
<%= dgettext("actions", "change email") %>
</h3>
<div
:if={@email_changeset.action && not @email_changeset.valid?}
class="alert alert-danger col-span-3"
>
<%= dgettext("errors", "oops, something went wrong! please check the errors below") %>
</div>
<%= hidden_input(f, :action, name: "action", value: "update_email") %>
<%= label(f, :email, gettext("email"), class: "title text-lg text-primary-400") %>
<%= email_input(f, :email, required: true, class: "mx-2 my-1 input input-primary col-span-2") %>
<%= error_tag(f, :email, "col-span-3") %>
<%= label(f, :current_password, gettext("current password"),
for: "current_password_for_email",
class: "mx-2 my-1 title text-lg text-primary-400"
) %>
<%= password_input(f, :current_password,
required: true,
name: "current_password",
id: "current_password_for_email",
class: "mx-2 my-1 input input-primary col-span-2"
) %>
<%= error_tag(f, :current_password, "col-span-3") %>
<%= submit(dgettext("actions", "change email"),
class: "mx-auto btn btn-primary col-span-3"
) %>
</.form>
<hr class="hr" />
<.form
:let={f}
for={@password_changeset}
action={~p"/users/settings"}
class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center"
>
<h3 class="title text-primary-400 text-lg text-center col-span-3">
<%= dgettext("actions", "change password") %>
</h3>
<p
:if={@password_changeset.action && not @password_changeset.valid?}
class="alert alert-danger col-span-3"
>
<%= dgettext("errors", "oops, something went wrong! please check the errors below.") %>
</p>
<%= hidden_input(f, :action, name: "action", value: "update_password") %>
<%= label(f, :password, gettext("new password"), class: "title text-lg text-primary-400") %>
<%= password_input(f, :password,
required: true,
class: "mx-2 my-1 input input-primary col-span-2"
) %>
<%= error_tag(f, :password, "col-span-3") %>
<%= label(f, :password_confirmation, gettext("confirm new password"),
class: "title text-lg text-primary-400"
) %>
<%= password_input(f, :password_confirmation,
required: true,
class: "mx-2 my-1 input input-primary col-span-2"
) %>
<%= error_tag(f, :password_confirmation, "col-span-3") %>
<%= label(f, :current_password, gettext("current password"),
for: "current_password_for_password",
class: "title text-lg text-primary-400"
) %>
<%= password_input(f, :current_password,
required: true,
name: "current_password",
id: "current_password_for_password",
class: "mx-2 my-1 input input-primary col-span-2"
) %>
<%= error_tag(f, :current_password, "col-span-3") %>
<%= submit(dgettext("actions", "change password"),
class: "mx-auto btn btn-primary col-span-3"
) %>
</.form>
<hr class="hr" />
<.form
:let={f}
for={@locale_changeset}
action={~p"/users/settings"}
class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center"
>
<%= label(f, :locale, dgettext("actions", "change language"),
class: "title text-primary-400 text-lg text-center col-span-3"
) %>
<div
:if={@locale_changeset.action && not @locale_changeset.valid?}
class="alert alert-danger col-span-3"
>
<%= dgettext("errors", "oops, something went wrong! please check the errors below") %>
</div>
<%= hidden_input(f, :action, name: "action", value: "update_locale") %>
<%= select(f, :locale, [{gettext("english"), "en_US"}, {"spanish", "es"}],
class: "mx-2 my-1 min-w-md input input-primary col-start-2"
) %>
<%= error_tag(f, :locale, "col-span-3") %>
<%= submit(dgettext("actions", "change language"),
class: "whitespace-nowrap mx-auto btn btn-primary col-span-3",
data: [qa: dgettext("prompts", "are you sure you want to change your language?")]
) %>
</.form>
<hr class="hr" />
<div class="flex justify-end items-center">
<.link href={~p"/export/json"} class="mx-4 my-2 btn btn-primary" target="_blank">
<%= dgettext("actions", "export data as json") %>
</.link>
<.link
href={~p"/users/settings/#{@current_user}"}
method="delete"
class="mx-4 my-2 btn btn-alert"
data-confirm={dgettext("prompts", "are you sure you want to delete your account?")}
>
<%= dgettext("actions", "delete user") %>
</.link>
</div>
</div>