Skip to content

Commit

Permalink
smallthings
Browse files Browse the repository at this point in the history
  • Loading branch information
Darguima committed Jan 10, 2025
1 parent df9605b commit 535cd47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
19 changes: 4 additions & 15 deletions lib/safira_web/live/auth/components/user_profile_settings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule SafiraWeb.UserAuth.Components.UserProfileSettings do
|> assign(:user, user)
|> assign(:profile_form, to_form(profile_changeset))
|> assign(:current_password, nil)
|> assign(:trigger_submit, false)
|> assign(:trigger_form_action, false)

{:ok, socket}
end
Expand All @@ -37,7 +37,8 @@ defmodule SafiraWeb.UserAuth.Components.UserProfileSettings do

{:noreply,
socket
|> assign(profile_form: to_form(changeset, action: :validate))}
|> assign(profile_form: to_form(changeset, action: :validate))
|> assign(:current_password, current_password)}
end

def handle_event("update_profile", params, socket) do
Expand Down Expand Up @@ -80,6 +81,7 @@ defmodule SafiraWeb.UserAuth.Components.UserProfileSettings do
|> assign(profile_form: profile_changeset)
|> assign(user: applied_user)
|> assign(:current_password, nil)
|> assign(trigger_form_action: password_changed?)
|> put_flash(:info, info)}

{:error, changeset} ->
Expand All @@ -93,17 +95,4 @@ defmodule SafiraWeb.UserAuth.Components.UserProfileSettings do
|> put_flash(:error, "An unexpected error happened while updating the profile.")}
end
end

# case Accounts.update_user_password(user, password, user_params) do
# {:ok, user} ->
# password_form =
# user
# |> Accounts.change_user_password(user_params)
# |> to_form()
#
# {:noreply,
# socket
# # TODO: Fix the redirect page
# |> assign(trigger_submit: true, password_form: password_form)
# |> put_flash(:info, "Password updated successfully.")}
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
phx-submit="update_profile"
action={~p"/users/log_in?_action=password_updated"}
method="post"
phx-trigger-action={@trigger_submit}
phx-trigger-action={@trigger_form_action}
phx-target={@myself}
>
<div class="flex flex-col w-full mt-[0px]">
Expand Down

0 comments on commit 535cd47

Please sign in to comment.