From 825b2aa91a6d42cca8042bd05c19bfb409150f07 Mon Sep 17 00:00:00 2001 From: ic3w0lf22 Date: Sun, 29 Jun 2025 19:06:52 +0000 Subject: [PATCH] Clickable titles and show active mapfix (#211) Closes #144 Co-authored-by: ic3w0lf Reviewed-on: https://git.itzana.me/StrafesNET/maps-service/pulls/211 Reviewed-by: itzaname Co-authored-by: ic3w0lf22 Co-committed-by: ic3w0lf22 --- web/src/app/_components/review/ReviewItem.tsx | 1 + .../_components/review/ReviewItemHeader.tsx | 28 +++++++- web/src/app/maps/[mapId]/page.tsx | 65 ++++++++++++++++++- 3 files changed, 90 insertions(+), 4 deletions(-) diff --git a/web/src/app/_components/review/ReviewItem.tsx b/web/src/app/_components/review/ReviewItem.tsx index 1b531e7..1ce1940 100644 --- a/web/src/app/_components/review/ReviewItem.tsx +++ b/web/src/app/_components/review/ReviewItem.tsx @@ -49,6 +49,7 @@ export function ReviewItem({ { +export const ReviewItemHeader = ({ displayName, assetId, statusId, creator, submitterId }: ReviewItemHeaderProps) => { const isProcessing = StatusMatches(statusId, [Status.Validating, Status.Uploading, Status.Submitting]); const pulse = keyframes` 0%, 100% { opacity: 0.2; transform: scale(0.8); } @@ -57,9 +58,30 @@ export const ReviewItemHeader = ({ displayName, statusId, creator, submitterId } return ( <> - + {assetId != null ? ( + + + + {displayName} by {creator} + + + + + ) : ( + {displayName} by {creator} - + + )} {isProcessing && ( ([]); useTitle(map ? `${map.DisplayName}` : 'Loading Map...'); @@ -87,6 +90,33 @@ export default function MapDetails() { getRoles() }, [mapId]); + useEffect(() => { + if (!map) return; + const targetAssetId = map.ID; + async function fetchMapfixes() { + try { + const limit = 100; + let page = 1; + let allMapfixes: MapfixInfo[] = []; + let total = 0; + do { + const res = await fetch(`/api/mapfixes?Page=${page}&Limit=${limit}&TargetAssetID=${targetAssetId}`); + if (!res.ok) break; + const data = await res.json(); + if (page === 1) total = data.Total; + allMapfixes = allMapfixes.concat(data.Mapfixes); + page++; + } while (allMapfixes.length < total); + // Filter out rejected, uploading, uploaded (StatusID > 7) + const active = allMapfixes.filter((fix: MapfixInfo) => fix.StatusID <= MapfixStatus.Validated); + setMapfixes(active); + } catch { + setMapfixes([]); + } + } + fetchMapfixes(); + }, [map]); + const formatDate = (timestamp: number) => { return new Date(timestamp * 1000).toLocaleDateString('en-US', { year: 'numeric', @@ -361,13 +391,46 @@ export default function MapDetails() { handleCopyId(mapId as string)} - sx={{ ml: 1 }} + sx={{ ml: 1, p: 0 }} > + + {/* Active Mapfix in Map Details */} + {mapfixes.length > 0 && (() => { + const active = mapfixes.find(fix => fix.StatusID <= MapfixStatus.Validated); + const latest = mapfixes.reduce((a, b) => (a.CreatedAt > b.CreatedAt ? a : b)); + const showFix = active || latest; + return ( + + + Active Mapfix + + + + {showFix.Description} + + + + + ); + })()}