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 --%>

E-Commerce

Manage your e-commerce store

<.link navigate={Routes.path("/admin/shop/products/new")} class="btn btn-primary" > <.icon name="hero-plus" class="w-5 h-5 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" /> Manage 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" /> Manage Categories <.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
<%!-- Phase 2 Placeholder --%>
<.icon name="hero-rocket-launch" class="w-12 h-12 mx-auto mb-3" />

Coming in Phase 2

Variants, Inventory, Cart, Orders

""" end end