Skip to content

Commit

Permalink
Fixed the cart functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
MICHAELMUNAVU83 committed Nov 30, 2023
1 parent 82abdd5 commit fc93932
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions lib/elixir_conf_africa_web/live/home_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion test/elixir_conf_africa_web/live/home_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fc93932

Please sign in to comment.