defmodule ToweropsWeb.Admin.DashboardLive do
  @moduledoc """
  Admin dashboard showing system statistics and recent audit logs.
  """
  use ToweropsWeb, :live_view

  alias Towerops.Admin

  @impl true
  def mount(_params, _session, socket) do
    user_count = Admin.count_users()
    org_count = Admin.count_organizations()
    recent_logs = Admin.list_audit_logs(limit: 10)

    {:ok,
     socket
     |> assign(:page_title, "Admin Dashboard")
     |> assign(:user_count, user_count)
     |> assign(:org_count, org_count)
     |> assign(:recent_logs, recent_logs)}
  end
end
