refactor: use assigns spread in page LiveView render functions
Replace verbose explicit attr passing with {assigns} spread for
home, contact, cart, product show and checkout success LiveViews.
Collection skipped (inline rendering, no template component).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5a43cfc761
commit
db02c0b414
@ -65,22 +65,10 @@ defmodule SimpleshopThemeWeb.ShopLive.Cart do
|
|||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
cart_page_subtotal = Cart.calculate_subtotal(assigns.cart_items)
|
assigns = assign(assigns, :cart_page_subtotal, Cart.calculate_subtotal(assigns.cart_items))
|
||||||
assigns = assign(assigns, :cart_page_subtotal, cart_page_subtotal)
|
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<SimpleshopThemeWeb.PageTemplates.cart
|
<SimpleshopThemeWeb.PageTemplates.cart {assigns} />
|
||||||
theme_settings={@theme_settings}
|
|
||||||
logo_image={@logo_image}
|
|
||||||
header_image={@header_image}
|
|
||||||
cart_items={@cart_items}
|
|
||||||
cart_page_subtotal={@cart_page_subtotal}
|
|
||||||
mode={@mode}
|
|
||||||
cart_count={@cart_count}
|
|
||||||
cart_subtotal={@cart_subtotal}
|
|
||||||
cart_drawer_open={@cart_drawer_open}
|
|
||||||
cart_status={@cart_status}
|
|
||||||
/>
|
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -65,18 +65,7 @@ defmodule SimpleshopThemeWeb.ShopLive.CheckoutSuccess do
|
|||||||
@impl true
|
@impl true
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<SimpleshopThemeWeb.PageTemplates.checkout_success
|
<SimpleshopThemeWeb.PageTemplates.checkout_success {assigns} />
|
||||||
theme_settings={@theme_settings}
|
|
||||||
logo_image={@logo_image}
|
|
||||||
header_image={@header_image}
|
|
||||||
mode={@mode}
|
|
||||||
cart_items={@cart_items}
|
|
||||||
cart_count={@cart_count}
|
|
||||||
cart_subtotal={@cart_subtotal}
|
|
||||||
cart_drawer_open={@cart_drawer_open}
|
|
||||||
cart_status={@cart_status}
|
|
||||||
order={@order}
|
|
||||||
/>
|
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -38,17 +38,7 @@ defmodule SimpleshopThemeWeb.ShopLive.Contact do
|
|||||||
@impl true
|
@impl true
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<SimpleshopThemeWeb.PageTemplates.contact
|
<SimpleshopThemeWeb.PageTemplates.contact {assigns} />
|
||||||
theme_settings={@theme_settings}
|
|
||||||
logo_image={@logo_image}
|
|
||||||
header_image={@header_image}
|
|
||||||
mode={@mode}
|
|
||||||
cart_items={@cart_items}
|
|
||||||
cart_count={@cart_count}
|
|
||||||
cart_subtotal={@cart_subtotal}
|
|
||||||
cart_drawer_open={@cart_drawer_open}
|
|
||||||
cart_status={@cart_status}
|
|
||||||
/>
|
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -44,18 +44,7 @@ defmodule SimpleshopThemeWeb.ShopLive.Home do
|
|||||||
@impl true
|
@impl true
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<SimpleshopThemeWeb.PageTemplates.home
|
<SimpleshopThemeWeb.PageTemplates.home {assigns} />
|
||||||
theme_settings={@theme_settings}
|
|
||||||
logo_image={@logo_image}
|
|
||||||
header_image={@header_image}
|
|
||||||
preview_data={@preview_data}
|
|
||||||
mode={@mode}
|
|
||||||
cart_items={@cart_items}
|
|
||||||
cart_count={@cart_count}
|
|
||||||
cart_subtotal={@cart_subtotal}
|
|
||||||
cart_drawer_open={@cart_drawer_open}
|
|
||||||
cart_status={@cart_status}
|
|
||||||
/>
|
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -173,25 +173,7 @@ defmodule SimpleshopThemeWeb.ShopLive.ProductShow do
|
|||||||
@impl true
|
@impl true
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<SimpleshopThemeWeb.PageTemplates.pdp
|
<SimpleshopThemeWeb.PageTemplates.pdp {assigns} />
|
||||||
theme_settings={@theme_settings}
|
|
||||||
logo_image={@logo_image}
|
|
||||||
header_image={@header_image}
|
|
||||||
product={@product}
|
|
||||||
gallery_images={@gallery_images}
|
|
||||||
related_products={@related_products}
|
|
||||||
quantity={@quantity}
|
|
||||||
mode={@mode}
|
|
||||||
cart_items={@cart_items}
|
|
||||||
cart_count={@cart_count}
|
|
||||||
cart_subtotal={@cart_subtotal}
|
|
||||||
cart_drawer_open={@cart_drawer_open}
|
|
||||||
cart_status={@cart_status}
|
|
||||||
option_types={@option_types}
|
|
||||||
selected_options={@selected_options}
|
|
||||||
available_options={@available_options}
|
|
||||||
display_price={@display_price}
|
|
||||||
/>
|
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user