From 1eda51f1dd9a632cd2ab95b276813ef6c0925d2d Mon Sep 17 00:00:00 2001 From: shibao Date: Tue, 15 Feb 2022 00:44:40 -0500 Subject: [PATCH] use changeset.valid? for errors --- lib/cannery_web/live/ammo_group_live/form_component.html.heex | 2 +- lib/cannery_web/live/ammo_type_live/form_component.html.heex | 2 +- lib/cannery_web/live/container_live/form_component.html.heex | 2 +- lib/cannery_web/live/invite_live/form_component.html.heex | 2 +- lib/cannery_web/live/tag_live/form_component.ex | 2 +- lib/cannery_web/live/tag_live/index.ex | 2 -- lib/cannery_web/templates/user_registration/new.html.heex | 2 +- lib/cannery_web/templates/user_reset_password/edit.html.heex | 2 +- 8 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/cannery_web/live/ammo_group_live/form_component.html.heex b/lib/cannery_web/live/ammo_group_live/form_component.html.heex index bd47fed..0e6bbcf 100644 --- a/lib/cannery_web/live/ammo_group_live/form_component.html.heex +++ b/lib/cannery_web/live/ammo_group_live/form_component.html.heex @@ -12,7 +12,7 @@ phx-submit="save" class="grid grid-cols-3 justify-center items-center space-y-4" > - <%= if @changeset.action do %> + <%= unless @changeset.valid? do %>
<%= changeset_errors(@changeset) %>
diff --git a/lib/cannery_web/live/ammo_type_live/form_component.html.heex b/lib/cannery_web/live/ammo_type_live/form_component.html.heex index 1f0f96c..654927b 100644 --- a/lib/cannery_web/live/ammo_type_live/form_component.html.heex +++ b/lib/cannery_web/live/ammo_type_live/form_component.html.heex @@ -11,7 +11,7 @@ phx-submit="save" class="grid grid-cols-3 justify-center items-center space-y-4" > - <%= if @changeset.action do %> + <%= unless @changeset.valid? do %>
<%= changeset_errors(@changeset) %>
diff --git a/lib/cannery_web/live/container_live/form_component.html.heex b/lib/cannery_web/live/container_live/form_component.html.heex index 2b5f438..32f6fa5 100644 --- a/lib/cannery_web/live/container_live/form_component.html.heex +++ b/lib/cannery_web/live/container_live/form_component.html.heex @@ -11,7 +11,7 @@ phx-change="validate" phx-submit="save" > - <%= if @changeset.action do %> + <%= unless @changeset.valid? do %>
<%= changeset_errors(@changeset) %>
diff --git a/lib/cannery_web/live/invite_live/form_component.html.heex b/lib/cannery_web/live/invite_live/form_component.html.heex index 13b7c5d..3a204ad 100644 --- a/lib/cannery_web/live/invite_live/form_component.html.heex +++ b/lib/cannery_web/live/invite_live/form_component.html.heex @@ -11,7 +11,7 @@ phx-change="validate" phx-submit="save" > - <%= if @changeset.action do %> + <%= unless @changeset.valid? do %>
<%= changeset_errors(@changeset) %>
diff --git a/lib/cannery_web/live/tag_live/form_component.ex b/lib/cannery_web/live/tag_live/form_component.ex index feb648e..8ed6a03 100644 --- a/lib/cannery_web/live/tag_live/form_component.ex +++ b/lib/cannery_web/live/tag_live/form_component.ex @@ -41,7 +41,7 @@ defmodule CanneryWeb.TagLive.FormComponent do phx-change="validate" phx-submit="save" > - <%= if @changeset.action do %> + <%= unless @changeset.valid? do %>
<%= changeset_errors(@changeset) %>
diff --git a/lib/cannery_web/live/tag_live/index.ex b/lib/cannery_web/live/tag_live/index.ex index e8ceb8a..12565d7 100644 --- a/lib/cannery_web/live/tag_live/index.ex +++ b/lib/cannery_web/live/tag_live/index.ex @@ -37,9 +37,7 @@ defmodule CanneryWeb.TagLive.Index do @impl true def handle_event("delete", %{"id" => id}, %{assigns: %{current_user: current_user}} = socket) do %{name: tag_name} = Tags.get_tag!(id, current_user) |> Tags.delete_tag!(current_user) - prompt = dgettext("prompts", "%{name} deleted succesfully", name: tag_name) - {:noreply, socket |> put_flash(:info, prompt) |> display_tags()} end diff --git a/lib/cannery_web/templates/user_registration/new.html.heex b/lib/cannery_web/templates/user_registration/new.html.heex index 9b2fcad..fe87f27 100644 --- a/lib/cannery_web/templates/user_registration/new.html.heex +++ b/lib/cannery_web/templates/user_registration/new.html.heex @@ -7,7 +7,7 @@ Routes.user_registration_path(@conn, :create), [class: "flex flex-col justify-center items-center space-y-4"], fn f -> %> - <%= if @changeset.action do %> + <%= unless @changeset.valid? do %>

<%= dgettext("errors", "Oops, something went wrong! Please check the errors below.") %> diff --git a/lib/cannery_web/templates/user_reset_password/edit.html.heex b/lib/cannery_web/templates/user_reset_password/edit.html.heex index 6adebaf..acf55ad 100644 --- a/lib/cannery_web/templates/user_reset_password/edit.html.heex +++ b/lib/cannery_web/templates/user_reset_password/edit.html.heex @@ -7,7 +7,7 @@ Routes.user_reset_password_path(@conn, :update, @token), [class: "flex flex-col justify-center items-center space-y-4"], fn f -> %> - <%= if @changeset.action do %> + <%= unless @changeset.valid? do %>

<%= dgettext("errors", "Oops, something went wrong! Please check the errors below.") %>