diff --git a/PROGRESS.md b/PROGRESS.md index 68483c8..ab81ec8 100644 --- a/PROGRESS.md +++ b/PROGRESS.md @@ -37,15 +37,14 @@ Plans: [admin-redesign.md](docs/plans/admin-redesign.md) | [setup-wizard.md](doc | ~~9~~ | ~~`Setup.setup_status/0` helper~~ | 2, 3 | 30m | done | | ~~10~~ | ~~ThemeHook gate (redirect to coming soon)~~ | 2, 8 | 30m | done | | ~~14~~ | ~~Go live / take offline toggle (on settings page)~~ | 2 | 30m | done | -| | **Admin shell chain (priority)** | | | | -| 1 | Filesystem restructure (consolidate live/ directories) | — | 2h | | -| 6 | Admin shell component (sidebar nav, header) | 1 | 2-3h | | -| 7 | Admin root + child layout templates | 1 | 1h | | -| 11 | Theme editor back-to-admin link | 6 | 30m | | -| 12 | Consolidate settings page | 6, 7 | 2-3h | | +| ~~1~~ | ~~Filesystem restructure (consolidate live/ directories)~~ | — | 2h | done | +| ~~6~~ | ~~Admin shell component (sidebar nav, header)~~ | 1 | 2-3h | done | +| ~~7~~ | ~~Admin root + child layout templates~~ | 1 | 1h | done | +| ~~11~~ | ~~Theme editor back-to-admin link~~ | 6 | 30m | done | +| ~~4~~ | ~~Admin bar on shop pages~~ | — | 1h | done | +| ~~12~~ | ~~Consolidate settings page~~ | 6, 7 | 2-3h | done | +| | **Next up** | | | | | 13 | Admin dashboard (+ setup checklist) | 6, 7, 9 | 2h | | -| | **Independent** | | | | -| 4 | Admin bar on shop pages | — | 1h | | | 5 | Search (functional search with results) | — | 3-4h | | | | **Needs admin stable** | | | | | 15 | Setup wizard + admin tests | 13 | 1.5h | | diff --git a/lib/simpleshop_theme/orders.ex b/lib/simpleshop_theme/orders.ex index 1375f60..6a51673 100644 --- a/lib/simpleshop_theme/orders.ex +++ b/lib/simpleshop_theme/orders.ex @@ -50,6 +50,16 @@ defmodule SimpleshopTheme.Orders do |> Map.new() end + @doc """ + Returns total revenue (in minor units) from paid orders. + """ + def total_revenue do + Order + |> where(payment_status: "paid") + |> select([o], sum(o.total)) + |> Repo.one() || 0 + end + @doc """ Creates an order with line items from hydrated cart data. diff --git a/lib/simpleshop_theme_web/components/layouts.ex b/lib/simpleshop_theme_web/components/layouts.ex index e350040..ae0c816 100644 --- a/lib/simpleshop_theme_web/components/layouts.ex +++ b/lib/simpleshop_theme_web/components/layouts.ex @@ -46,6 +46,10 @@ defmodule SimpleshopThemeWeb.Layouts do end @doc false + def admin_nav_active?(current_path, "/admin") do + if current_path == "/admin", do: "active", else: nil + end + def admin_nav_active?(current_path, link_path) do if String.starts_with?(current_path, link_path), do: "active", else: nil end diff --git a/lib/simpleshop_theme_web/components/layouts/admin.html.heex b/lib/simpleshop_theme_web/components/layouts/admin.html.heex index c4230db..a1811dd 100644 --- a/lib/simpleshop_theme_web/components/layouts/admin.html.heex +++ b/lib/simpleshop_theme_web/components/layouts/admin.html.heex @@ -34,7 +34,7 @@