diff --git a/lib/microwaveprop/radio.ex b/lib/microwaveprop/radio.ex
index 93bde5cf..af24f89e 100644
--- a/lib/microwaveprop/radio.ex
+++ b/lib/microwaveprop/radio.ex
@@ -454,6 +454,19 @@ defmodule Microwaveprop.Radio do
|> Repo.update!()
end
+ @doc """
+ Returns all flagged-invalid contacts, newest first. Admin-only
+ viewer — the admin contact-edits page uses this to surface flagged
+ QSOs for review alongside pending edit requests.
+ """
+ @spec list_flagged_contacts() :: [Contact.t()]
+ def list_flagged_contacts do
+ Contact
+ |> where([c], c.flagged_invalid == true)
+ |> order_by([c], desc: c.inserted_at, desc: c.id)
+ |> Repo.all()
+ end
+
@spec change_contact(Contact.t(), map()) :: Ecto.Changeset.t()
def change_contact(contact, attrs \\ %{}) do
Contact.submission_changeset(contact, attrs)
diff --git a/lib/microwaveprop_web/live/admin/contact_edit_live.ex b/lib/microwaveprop_web/live/admin/contact_edit_live.ex
index 324ca537..8bf9cf74 100644
--- a/lib/microwaveprop_web/live/admin/contact_edit_live.ex
+++ b/lib/microwaveprop_web/live/admin/contact_edit_live.ex
@@ -48,6 +48,7 @@ defmodule MicrowavepropWeb.Admin.ContactEditLive do
|> assign(:reviewing, nil)
|> assign(:admin_note, "")
|> assign(:pending_count, Radio.pending_edit_count())
+ |> assign(:flagged_contacts, Radio.list_flagged_contacts())
|> assign(:data_provider, {Radio, :pending_edits_query, []})}
end
@@ -253,6 +254,42 @@ defmodule MicrowavepropWeb.Admin.ContactEditLive do
streams={@streams}
actions={actions()}
/>
+
+ <%= if @flagged_contacts != [] do %>
+
+
+ Flagged contacts ({length(@flagged_contacts)})
+
+
+
+
+
+ | Stations |
+ Band |
+ QSO (UTC) |
+ Added (UTC) |
+ |
+
+
+
+ <%= for c <- @flagged_contacts do %>
+
+ | {c.station1} / {c.station2} |
+ {format_band(c.band)} |
+ {format_ts(c.qso_timestamp)} |
+ {format_ts(c.inserted_at)} |
+
+ <.link navigate={~p"/contacts/#{c.id}"} class="btn btn-xs btn-ghost">
+ View
+
+ |
+
+ <% end %>
+
+
+
+
+ <% end %>
"""
end
diff --git a/test/microwaveprop_web/live/admin/contact_edit_live_test.exs b/test/microwaveprop_web/live/admin/contact_edit_live_test.exs
new file mode 100644
index 00000000..b4310b31
--- /dev/null
+++ b/test/microwaveprop_web/live/admin/contact_edit_live_test.exs
@@ -0,0 +1,74 @@
+defmodule MicrowavepropWeb.Admin.ContactEditLiveTest do
+ use MicrowavepropWeb.ConnCase, async: false
+
+ import Microwaveprop.AccountsFixtures
+ import Phoenix.LiveViewTest
+
+ alias Microwaveprop.Accounts
+ alias Microwaveprop.Radio.Contact
+ alias Microwaveprop.Repo
+
+ defp admin_fixture do
+ user = user_fixture()
+ {:ok, user} = Accounts.admin_update_user(user, %{is_admin: true})
+ user
+ end
+
+ defp create_contact(attrs \\ %{}) do
+ default = %{
+ station1: "W5XD",
+ station2: "K5TR",
+ qso_timestamp: ~U[2026-03-28 18:00:00Z],
+ mode: "CW",
+ band: Decimal.new("1296"),
+ grid1: "EM12",
+ grid2: "EM00",
+ pos1: %{"lat" => 32.9, "lon" => -97.0},
+ pos2: %{"lat" => 30.3, "lon" => -97.7},
+ distance_km: Decimal.new("295")
+ }
+
+ merged = Map.merge(default, attrs)
+ # `flagged_invalid` isn't a user-facing submission field, so the
+ # changeset's cast drops it. Set it directly via change/2.
+ {direct_attrs, castable} = Map.split(merged, [:flagged_invalid])
+
+ {:ok, contact} =
+ %Contact{}
+ |> Contact.changeset(castable)
+ |> Ecto.Changeset.change(direct_attrs)
+ |> Repo.insert()
+
+ contact
+ end
+
+ describe "flagged contacts section" do
+ test "hidden when no contacts are flagged", %{conn: conn} do
+ _ok = create_contact(%{station1: "W5OK"})
+ conn = log_in_user(conn, admin_fixture())
+
+ {:ok, _lv, html} = live(conn, ~p"/admin/contact-edits")
+ refute html =~ "Flagged contacts"
+ end
+
+ test "lists flagged contacts with station callsigns for admins", %{conn: conn} do
+ _ok = create_contact(%{station1: "W5OK"})
+ _flagged = create_contact(%{station1: "W5BAD", flagged_invalid: true})
+ conn = log_in_user(conn, admin_fixture())
+
+ {:ok, _lv, html} = live(conn, ~p"/admin/contact-edits")
+ assert html =~ "Flagged contacts"
+ assert html =~ "W5BAD"
+ end
+
+ test "does not leak flagged contacts into the pending-edits table", %{conn: conn} do
+ _flagged = create_contact(%{station1: "W5BAD", flagged_invalid: true})
+ conn = log_in_user(conn, admin_fixture())
+
+ {:ok, _lv, html} = live(conn, ~p"/admin/contact-edits")
+ # The flagged list mentions W5BAD, but only inside the flagged
+ # section — the pending-edits table above should stay empty.
+ assert html =~ "0 pending"
+ end
+ end
+end