From 73916f405614fad0c4cef629acf2fe3c7c23ff98 Mon Sep 17 00:00:00 2001 From: Erol Date: Sun, 12 Apr 2026 11:19:35 +0200 Subject: [PATCH] =?UTF-8?q?F=C3=B8r=20enda=20en=20endring=20av=20kort=20og?= =?UTF-8?q?=20scorekort=20(Codex)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/app/FacilitySearch.tsx | 129 ++++++++++++++++-- .../app/golfbaner/[slug]/CourseDisplay.tsx | 81 ++++++++++- .../golfbaner/[slug]/FacilityDetailView.tsx | 17 ++- 3 files changed, 208 insertions(+), 19 deletions(-) diff --git a/frontend/src/app/FacilitySearch.tsx b/frontend/src/app/FacilitySearch.tsx index 17ef5ad..3033e5c 100755 --- a/frontend/src/app/FacilitySearch.tsx +++ b/frontend/src/app/FacilitySearch.tsx @@ -22,6 +22,10 @@ type Facility = { banetype?: string | null; image_url?: string | null; phone?: string | null; + website_url?: string | null; + golfbox_booking_url?: string | null; + golfbox_tournament_url?: string | null; + weather_url?: string | null; lat?: number | null; lng?: number | null; golfamore?: boolean | null; @@ -203,6 +207,11 @@ const formatUpdatedDate = (value: string | null | undefined) => { const getStatusLabel = (status: string) => STATUS_MAP[status] || "Ukjent"; +const buildMapUrl = (lat?: number | null, lng?: number | null) => { + if (typeof lat !== "number" || typeof lng !== "number") return null; + return `https://www.google.com/maps/search/?api=1&query=${lat},${lng}`; +}; + const getAreaLabel = (value: string, countyOptions: Array<{ slug: string; label: string }>) => { if (!value) return "Hele Norge"; const builtIn = HIERARCHICAL_AREA_OPTIONS.find((option) => option.value === value); @@ -246,6 +255,12 @@ const noteClampStyle: CSSProperties = { overflow: "hidden", }; +const actionIconClassName = + "flex h-12 w-12 items-center justify-center rounded-[1.1rem] bg-white text-[#112015] shadow-sm transition hover:bg-[#FF5722] hover:text-white"; + +const cardActionShellClassName = + "flex flex-wrap gap-2 rounded-[1.35rem] bg-[#25312A] p-2 text-[#112015]"; + export default function FacilitySearch({ initialFacilities, variant = "catalog", @@ -553,11 +568,11 @@ export default function FacilitySearch({ ) : (
{processedFacilities.map((facility) => ( - +
+ +
@@ -613,11 +630,8 @@ export default function FacilitySearch({ {facility.footnote && (
-

- Viktig beskjed - - {formatUpdatedDate(facility.footnote_updated_at || facility.status_updated_at)} - +

+ {formatUpdatedDate(facility.footnote_updated_at || facility.status_updated_at)}

{facility.footnote} @@ -642,12 +656,42 @@ export default function FacilitySearch({

-
- {facility.phone ? facility.phone : "Se detaljer"} - Se anlegg → +
+ {facility.website_url && ( + + + + )} + {facility.golfbox_booking_url && ( + + + + )} + {facility.golfbox_tournament_url && ( + + + + )} + {buildMapUrl(facility.lat, facility.lng) && ( + + + + )} + {facility.weather_url && ( + + + + )} +
+ +
+ {facility.phone ? facility.phone : facility.city || "Se detaljer"} + + Se anlegg → +
- + ))}
)} @@ -655,6 +699,69 @@ export default function FacilitySearch({ ); } +function ActionIcon({ type }: { type: "web" | "booking" | "trophy" | "pin" | "weather" }) { + return ( + + ); +} + function FieldSelect({ label, value, diff --git a/frontend/src/app/golfbaner/[slug]/CourseDisplay.tsx b/frontend/src/app/golfbaner/[slug]/CourseDisplay.tsx index a3a6219..2eeb26a 100644 --- a/frontend/src/app/golfbaner/[slug]/CourseDisplay.tsx +++ b/frontend/src/app/golfbaner/[slug]/CourseDisplay.tsx @@ -69,12 +69,65 @@ export default function CourseDisplay({ course }: { course: any }) { const sumPar = (holes: any[]) => holes.reduce((acc, h) => acc + (h.par || 0), 0); const sumLen = (holes: any[], key: string) => holes.reduce((acc, h) => acc + (h.lengths?.[key] || 0), 0); + const selectedColumn = activeColumns[selectedTeeIndex] || activeColumns[0] || null; + const selectedTeeLabel = selectedColumn?.label || activeTee?.navn_utslag || activeTee?.navn_utslag_damer || 'Valgt utslag'; // Formater utløpsdato const slopeExpiry = course.slope_valid_until ? new Date(course.slope_valid_until).toLocaleDateString('nb-NO', { year: 'numeric', month: 'short', day: 'numeric' }) : 'Ukjent'; + const renderMobileHoleCard = (hole: any) => { + const extra = getExtraStrokes(hole.hcp_index); + const selectedLength = selectedColumn ? hole.lengths?.[selectedColumn.key] : null; + + return ( +
+
+
+

Hull {hole.hole_number}

+

Par {hole.par}

+
+
+

HCP

+

{hole.hcp_index || '--'}

+
+
+ +
+
+

Mottatt

+

{extra > 0 ? `+${extra}` : '-'}

+
+
+

Din Par

+

{hole.par + extra}

+
+
+

{selectedTeeLabel}

+

{selectedLength || '--'} meter

+
+
+
+ ); + }; + + const renderMobileSummaryCard = (label: string, holes: any[]) => ( +
+

{label}

+
+
+

Par

+

{sumPar(holes)}

+
+
+

{selectedTeeLabel}

+

{selectedColumn ? sumLen(holes, selectedColumn.key) : '--'}

+
+
+
+ ); + return (
@@ -111,8 +164,32 @@ export default function CourseDisplay({ course }: { course: any }) {
+ {/* MOBIL SCOREKORT */} +
+
+

Mobilscorekort

+

+ Viser valgte utslag for {gender}. Bytt utslag i kalkulatoren over for å oppdatere lengdene. +

+
+ +
+ {holesOut.map(renderMobileHoleCard)} + {renderMobileSummaryCard("Ut", holesOut)} +
+ + {hasInHoles && ( +
+ {holesIn.map(renderMobileHoleCard)} + {renderMobileSummaryCard("Inn", holesIn)} +
+ )} + + {renderMobileSummaryCard("Totalt", allHoles)} +
+ {/* SCOREKORT TABELL */} -
+
@@ -203,4 +280,4 @@ export default function CourseDisplay({ course }: { course: any }) { ); -} \ No newline at end of file +} diff --git a/frontend/src/app/golfbaner/[slug]/FacilityDetailView.tsx b/frontend/src/app/golfbaner/[slug]/FacilityDetailView.tsx index 96f1b2c..3340c96 100644 --- a/frontend/src/app/golfbaner/[slug]/FacilityDetailView.tsx +++ b/frontend/src/app/golfbaner/[slug]/FacilityDetailView.tsx @@ -156,7 +156,7 @@ export default function FacilityDetailView({ facility }: { facility: any }) { {facility.website_url && } {facility.golfbox_booking_url && } {facility.golfbox_tournament_url && } - + {facility.weather_url && } @@ -190,8 +190,13 @@ export default function FacilityDetailView({ facility }: { facility: any }) { {/* HOVEDINNHOLD (78%) */}
{facility.footnote && ( -
- {facility.footnote} +
+

+ {formatDate(facility.footnote_updated_at || facility.status_updated_at)} +

+
+ {facility.footnote} +
)}
@@ -209,7 +214,7 @@ export default function FacilityDetailView({ facility }: { facility: any }) { {facility.email || 'Ikke oppgitt'} @@ -344,7 +349,7 @@ export default function FacilityDetailView({ facility }: { facility: any }) {

Kart

-