defmodule SimpleshopThemeWeb.Shop.Cart do
  use SimpleshopThemeWeb, :live_view

  alias SimpleshopTheme.Cart

  @impl true
  def mount(_params, _session, socket) do
    {:ok, assign(socket, :page_title, "Cart")}
  end

  @impl true
  def render(assigns) do
    assigns = assign(assigns, :cart_page_subtotal, Cart.calculate_subtotal(assigns.cart_items))

    ~H"""
    <SimpleshopThemeWeb.PageTemplates.cart {assigns} />
    """
  end
end
