From c630bfa66551eb2dc0cb3aebb72b2d8c861f39a5 Mon Sep 17 00:00:00 2001 From: makearmy Date: Wed, 1 Oct 2025 16:25:54 -0400 Subject: [PATCH] uv test owner --- app/settings/fiber/page.tsx | 11 +- app/settings/uv/page.tsx | 335 ++++++++++++++++--------------- components/common/OwnerBadge.tsx | 12 +- 3 files changed, 187 insertions(+), 171 deletions(-) diff --git a/app/settings/fiber/page.tsx b/app/settings/fiber/page.tsx index a1cae2c6..564ede2e 100644 --- a/app/settings/fiber/page.tsx +++ b/app/settings/fiber/page.tsx @@ -53,18 +53,13 @@ export default function FiberSettingsPage() { .catch(() => setLoading(false)); }, []); + // ── Owner display helper: prefer username ──────────────────────────────────── const ownerName = (row: any) => { const o = row?.owner || {}; - return o.username || "—"; - }; - return ( - o.display_name || - [o.first_name, o.last_name].filter(Boolean).join(" ") || - o.email || - "—" - ); + return o?.username || "—"; }; + // ── Highlight helper for search matches ───────────────────────────────────── const highlight = (text?: string) => { if (!debouncedQuery) return text || ""; const regex = new RegExp(`(${debouncedQuery})`, "gi"); diff --git a/app/settings/uv/page.tsx b/app/settings/uv/page.tsx index cd6e5ea9..bbe39f2d 100644 --- a/app/settings/uv/page.tsx +++ b/app/settings/uv/page.tsx @@ -6,11 +6,8 @@ import Link from "next/link"; import Image from "next/image"; type Owner = { - username?: string | null; id?: string | number; - first_name?: string | null; - last_name?: string | null; - email?: string | null; + username?: string | null; }; export default function UVSettingsPage() { @@ -37,11 +34,10 @@ export default function UVSettingsPage() { "submission_id", "setting_title", "uploader", - // owner (M2O) – minimal, safe fields - "owner.id", "owner.username", - "owner.first_name", - "owner.last_name", - "owner.email", + // owner (M2O) – ask for username explicitly + "owner.id", + "owner.username", + // assets / denorms "photo.id", "photo.title", "mat.name", @@ -64,10 +60,7 @@ export default function UVSettingsPage() { .finally(() => setLoading(false)); }, []); - const ownerLabel = (o?: Owner) => { - if (!o) return "—"; - return o.username || "—"; - }; + const ownerLabel = (o?: Owner) => (o?.username ?? "—"); const highlight = (text?: string) => { if (!debouncedQuery) return text || ""; @@ -94,7 +87,9 @@ export default function UVSettingsPage() { }, [settings, debouncedQuery]); const total = settings.length; - const uniqueMaterials = new Set(settings.map((s) => s.mat?.name).filter(Boolean)).size; + const uniqueMaterials = new Set( + settings.map((s) => s.mat?.name).filter(Boolean) + ).size; const lensCounts = settings.reduce((acc: Record, cur) => { const v = cur.lens?.field_size; @@ -103,161 +98,181 @@ export default function UVSettingsPage() { return acc; }, {}); const mostCommonLens = - Object.entries(lensCounts).sort((a, b) => (Number(b[1]) || 0) - (Number(a[1]) || 0))[0]?.[0] || - "—"; + Object.entries(lensCounts).sort( + (a, b) => (Number(b[1]) || 0) - (Number(a[1]) || 0) + )[0]?.[0] || "—"; -const srcCounts = settings.reduce((acc: Record, cur) => { - const v = cur.source?.model; - if (!v) return acc; - acc[v] = (acc[v] || 0) + 1; - return acc; -}, {}); -const mostCommonSource = -Object.entries(srcCounts).sort((a, b) => (Number(b[1]) || 0) - (Number(a[1]) || 0))[0]?.[0] || -"—"; + const srcCounts = settings.reduce((acc: Record, cur) => { + const v = cur.source?.model; + if (!v) return acc; + acc[v] = (acc[v] || 0) + 1; + return acc; + }, {}); + const mostCommonSource = + Object.entries(srcCounts).sort( + (a, b) => (Number(b[1]) || 0) - (Number(a[1]) || 0) + )[0]?.[0] || "—"; -const recent = [...settings] -.sort((a, b) => Number(b.submission_id) - Number(a.submission_id)) -.slice(0, 5); + const recent = [...settings] + .sort((a, b) => Number(b.submission_id) - Number(a.submission_id)) + .slice(0, 5); -return ( -
- + return ( +
+ - {/* Header / Search */} -
-
-

UV Laser Settings

- setQuery(e.target.value)} - placeholder="Search by material, owner, uploader, model, lens…" - className="w-full mb-4 dark:bg-background border border-border rounded-md p-2" - /> -

- View and explore detailed UV laser settings with context. -

-
+ {/* Header / Search */} +
+
+

UV Laser Settings

+ setQuery(e.target.value)} + placeholder="Search by material, owner, uploader, model, lens…" + className="w-full mb-4 dark:bg-background border border-border rounded-md p-2" + /> +

+ View and explore detailed UV laser settings with context. +

+
- {/* How to use */} -
-

How to Use

-

- Browse community UV settings. Use search to narrow results. Click a row to view full configuration, - notes, and photos. -

-
+ {/* How to use */} +
+

How to Use

+

+ Browse community UV settings. Use search to narrow results. Click a + row to view full configuration, notes, and photos. +

+
- {/* Stats */} -
-

Stats Summary

-
    -
  • Total Settings: {total}
  • -
  • Unique Materials: {uniqueMaterials}
  • -
  • Most Common Lens: {mostCommonLens}
  • -
  • Most Used Source: {mostCommonSource}
  • -
-
+ {/* Stats */} +
+

Stats Summary

+
    +
  • Total Settings: {total}
  • +
  • Unique Materials: {uniqueMaterials}
  • +
  • Most Common Lens: {mostCommonLens}
  • +
  • Most Used Source: {mostCommonSource}
  • +
+
- {/* Recently Added */} -
-

Recently Added

-
    - {recent.map((s) => ( -
  • - - {s.setting_title || "Untitled"} - {" "} - - by {ownerLabel(s.owner)}{s.uploader ? ` (uploader: ${s.uploader})` : ""} - -
  • - ))} -
-
-
- - {/* Table */} - {loading ? ( -

Loading settings...

- ) : filtered.length === 0 ? ( -

No UV settings found.

- ) : ( -
- - - - - - - - - - - - - - - {filtered.map((s) => ( - - - - + className="underline text-accent" + > + {s.setting_title || "Untitled"} + {" "} + + by {ownerLabel(s.owner)} + {s.uploader ? ` (uploader: ${s.uploader})` : ""} + + ))} - -
PhotoTitleOwnerUploaderMaterialCoatingSourceLens
- {s.photo?.id ? ( - {s.photo.title - ) : ( - "—" - )} - + {/* Recently Added */} +
+

Recently Added

+
    + {recent.map((s) => ( +
  • -
- - - - - -
+
- )} -
-); +
+ + {/* Table */} + {loading ? ( +

Loading settings...

+ ) : filtered.length === 0 ? ( +

No UV settings found.

+ ) : ( +
+ + + + + + + + + + + + + + + {filtered.map((s) => ( + + + + + ))} + +
PhotoTitleOwnerUploaderMaterialCoatingSourceLens
+ {s.photo?.id ? ( + {s.photo.title + ) : ( + "—" + )} + + + + + + + + +
+
+ )} +
+ ); } diff --git a/components/common/OwnerBadge.tsx b/components/common/OwnerBadge.tsx index 6fca2256..481b03db 100644 --- a/components/common/OwnerBadge.tsx +++ b/components/common/OwnerBadge.tsx @@ -5,18 +5,24 @@ export default function OwnerBadge({ uploader, className = '', }: { - owner?: { id?: string | number; username?: string } | null; + owner?: { id?: string | number; username?: string | null } | null; uploader?: string | null; className?: string; }) { const hasOwner = !!owner?.id; + + // Prefer owner's username; fall back to uploader; ensure clean text + const ownerName = (owner?.username ?? '').trim(); + const uploaderName = (uploader ?? '').trim(); + const name = ownerName || uploaderName || '—'; + const label = hasOwner ? 'Owner' : 'Uploader'; - const name = owner?.username ?? uploader ?? '—'; + const title = hasOwner ? 'Owner' : (uploaderName ? 'Original uploader' : ''); return ( {label}: {name}