defmodule PhoenixKit.Modules.Shop.Web.Dashboard do @moduledoc """ E-Commerce module dashboard LiveView. Displays e-commerce statistics and quick access to management features. """ use PhoenixKitWeb, :live_view alias PhoenixKit.Modules.Shop alias PhoenixKit.Utils.Routes @impl true def mount(_params, _session, socket) do if connected?(socket), do: :timer.send_interval(30_000, self(), :refresh_stats) stats = Shop.get_dashboard_stats() socket = socket |> assign(:page_title, "E-Commerce") |> assign(:stats, stats) |> assign(:enabled, Shop.enabled?()) {:ok, socket} end @impl true def handle_info(:refresh_stats, socket) do stats = Shop.get_dashboard_stats() {:noreply, assign(socket, :stats, stats)} end @impl true def render(assigns) do ~H"""
<%!-- Header --%>
<.link navigate={Routes.path("/admin")} class="btn btn-outline btn-primary btn-sm shrink-0" > <.icon name="hero-arrow-left" class="w-4 h-4 mr-2" /> Back

E-Commerce

Manage your e-commerce store

<%!-- Controls Bar --%>
<.link navigate={Routes.path("/admin/shop/products/new")} class="btn btn-primary"> <.icon name="hero-plus" class="w-4 h-4 mr-2" /> Add Product
<%!-- Stats Grid --%>
<%!-- Total Products --%>

Total Products

{@stats.total_products}

<.icon name="hero-cube" class="w-8 h-8 text-primary" />
<%!-- Active Products --%>

Active Products

{@stats.active_products}

<.icon name="hero-check-circle" class="w-8 h-8 text-success" />
<%!-- Draft Products --%>

Draft Products

{@stats.draft_products}

<.icon name="hero-pencil-square" class="w-8 h-8 text-warning" />
<%!-- Categories --%>

Categories

{@stats.total_categories}

<.icon name="hero-folder" class="w-8 h-8 text-info" />
<%!-- Product Types Grid --%>
<%!-- Physical Products --%>

<.icon name="hero-truck" class="w-6 h-6" /> Physical Products

{@stats.physical_products}

Products requiring shipping

<%!-- Digital Products --%>

<.icon name="hero-arrow-down-tray" class="w-6 h-6" /> Digital Products

{@stats.digital_products}

Downloadable products

<%!-- Quick Actions --%>

Quick Actions

<.link navigate={Routes.path("/admin/shop/products")} class="btn btn-outline btn-lg justify-start" > <.icon name="hero-cube" class="w-5 h-5 mr-2" /> Products <.link navigate={Routes.path("/admin/shop/categories")} class="btn btn-outline btn-lg justify-start" > <.icon name="hero-folder" class="w-5 h-5 mr-2" /> Categories <.link navigate={Routes.path("/admin/shop/carts")} class="btn btn-outline btn-lg justify-start" > <.icon name="hero-shopping-cart" class="w-5 h-5 mr-2" /> Carts <.link navigate={Routes.path("/admin/shop/imports")} class="btn btn-outline btn-lg justify-start" > <.icon name="hero-cloud-arrow-up" class="w-5 h-5 mr-2" /> CSV Import <.link navigate={Routes.path("/admin/shop/settings")} class="btn btn-outline btn-lg justify-start" > <.icon name="hero-cog-6-tooth" class="w-5 h-5 mr-2" /> Settings
""" end end