Skip to content

Commit

Permalink
fix: cart page
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRodrigues10 committed Dec 23, 2023
1 parent 1cc26a6 commit 35df548
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/store_web/live/cart_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ defmodule StoreWeb.CartLive.Index do

@impl true
def mount(_params, _session, socket) do
order = Inventory.list_user_draft_order(socket.assigns.current_user.id)
user_id = socket.assigns.current_user.id
order = Inventory.list_user_draft_order(user_id)

{:ok,
socket
|> assign(:order, order)
|> assign(:order_products, Inventory.list_order_products(order.id))}
order_products =
case order do
nil ->
[]

_ ->
Inventory.list_order_products(order.id)
end

{:ok, socket |> assign(:order, order) |> assign(:order_products, order_products)}
end

@impl true
Expand Down

0 comments on commit 35df548

Please sign in to comment.