From fc9393216b5bb5c703861bf3d286e4e885578a74 Mon Sep 17 00:00:00 2001 From: MICHAELMUNAVU83 Date: Thu, 30 Nov 2023 14:45:25 +0300 Subject: [PATCH] Fixed the cart functionality --- lib/elixir_conf_africa_web/live/home_live/index.ex | 7 +------ test/elixir_conf_africa_web/live/home_live_test.exs | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/elixir_conf_africa_web/live/home_live/index.ex b/lib/elixir_conf_africa_web/live/home_live/index.ex index 63e1063..bae9372 100644 --- a/lib/elixir_conf_africa_web/live/home_live/index.ex +++ b/lib/elixir_conf_africa_web/live/home_live/index.ex @@ -29,12 +29,7 @@ defmodule ElixirConfAfricaWeb.HomeLive.Index do cart_item_ids = Cart.cart_list_ids(socket.assigns.cart) if Enum.member?(cart_item_ids, String.to_integer(id)) do - updated_cart = Cart.add_to_cart(socket.assigns.cart, String.to_integer(id)) - - {:noreply, - socket - |> assign(:cart, updated_cart) - |> put_flash(:info, "Ticket already in cart , quantity increased by 1")} + {:noreply, put_flash(socket, :error, "Ticket already in cart")} else updated_cart = Cart.add_to_cart(socket.assigns.cart, String.to_integer(id)) diff --git a/test/elixir_conf_africa_web/live/home_live_test.exs b/test/elixir_conf_africa_web/live/home_live_test.exs index 3a4a799..133a533 100644 --- a/test/elixir_conf_africa_web/live/home_live_test.exs +++ b/test/elixir_conf_africa_web/live/home_live_test.exs @@ -53,7 +53,7 @@ defmodule ElixirConfAfricaWeb.HomeLiveTest do assert index_live |> element("#ticket_type-#{ticket_type.id}") - |> render_click() =~ "Ticket already in cart , quantity increased by 1" + |> render_click() =~ "Ticket already in cart" end end end