From 59853116a124545c453c00c4157730e2c0038640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Even=20=C3=98sterud?= Date: Mon, 6 Oct 2025 18:21:35 +0200 Subject: [PATCH] Add Norwegian labels for .ics-files Also moved event type labesl to util --- frontend/app/api/discord/route.ts | 18 +----------- frontend/app/components/LoginForm.tsx | 8 ------ frontend/lib/utils/calendarUtils.ts | 6 ++-- frontend/lib/utils/eventTypes.ts | 40 +++++++++++++++++++++++++++ frontend/public/file.svg | 1 + frontend/public/globe.svg | 1 + frontend/public/manifest-v2 2.json | 20 ++++++++++++++ frontend/public/next.svg | 1 + frontend/public/vercel.svg | 1 + frontend/public/window.svg | 1 + 10 files changed, 70 insertions(+), 27 deletions(-) create mode 100644 frontend/lib/utils/eventTypes.ts create mode 100644 frontend/public/file.svg create mode 100644 frontend/public/globe.svg create mode 100644 frontend/public/manifest-v2 2.json create mode 100644 frontend/public/next.svg create mode 100644 frontend/public/vercel.svg create mode 100644 frontend/public/window.svg diff --git a/frontend/app/api/discord/route.ts b/frontend/app/api/discord/route.ts index 30e93f4..eb476c3 100644 --- a/frontend/app/api/discord/route.ts +++ b/frontend/app/api/discord/route.ts @@ -1,23 +1,7 @@ // frontend/src/app/api/discord/route.ts import { NextRequest, NextResponse } from 'next/server'; - -// --- Helper Functions --- -const getEventTypeLabel = (type: string): string => { - const typeLabels: Record = { - // English variations - boulder: "Buldring", - toprope: "Tauklatring", - outdoor: "Utendørs", - other: "Annet", - // Norwegian variations (in case they're stored in Norwegian) - buldring: "Buldring", - tauklatring: "Tauklatring", - utendørs: "Utendørs", - annet: "Annet" - }; - return typeLabels[type.toLowerCase()] || type; -}; +import { getEventTypeLabel } from '@/lib/utils/eventTypes'; // --- Discord Notification API Route --- export async function POST(request: NextRequest) { diff --git a/frontend/app/components/LoginForm.tsx b/frontend/app/components/LoginForm.tsx index cd41ae1..b45b8ea 100644 --- a/frontend/app/components/LoginForm.tsx +++ b/frontend/app/components/LoginForm.tsx @@ -20,14 +20,6 @@ export default function LoginForm() { const [showInfoModal, setShowInfoModal] = useState(false); const router = useRouter(); - // Detect if we're on mobile or PWA - const isMobileOrPWA = () => { - const userAgent = navigator.userAgent.toLowerCase(); - const isMobile = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent); - const isPWA = window.matchMedia('(display-mode: standalone)').matches; - return isMobile || isPWA; - }; - // --- Google OAuth Login Handler --- const loginGoogle = async () => { if (!auth) { diff --git a/frontend/lib/utils/calendarUtils.ts b/frontend/lib/utils/calendarUtils.ts index 3b1007a..ad17547 100644 --- a/frontend/lib/utils/calendarUtils.ts +++ b/frontend/lib/utils/calendarUtils.ts @@ -1,5 +1,7 @@ // frontend/lib/utils/calendarUtils.ts +import { getEventTypeLabel } from './eventTypes'; + /** * Format a date for display in the calendar */ @@ -125,7 +127,7 @@ UID:${Date.now()}@cliffi.app DTSTAMP:${formatDate(new Date())} DTSTART:${formatDate(startDate)} DTEND:${formatDate(endDate)} -SUMMARY:${event.title} +SUMMARY:${getEventTypeLabel(event.title)} DESCRIPTION:${event.description} LOCATION:${event.locationName} END:VEVENT @@ -135,7 +137,7 @@ END:VCALENDAR`; const url = window.URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; - link.download = `${event.title}.ics`; + link.download = `${getEventTypeLabel(event.title)}.ics`; document.body.appendChild(link); link.click(); document.body.removeChild(link); diff --git a/frontend/lib/utils/eventTypes.ts b/frontend/lib/utils/eventTypes.ts new file mode 100644 index 0000000..2c6986f --- /dev/null +++ b/frontend/lib/utils/eventTypes.ts @@ -0,0 +1,40 @@ +// frontend/lib/utils/eventTypes.ts + +/** + * Convert event type codes to Norwegian display labels + */ +export function getEventTypeLabel(type: string): string { + const typeLabels: Record = { + // English variations + boulder: "Buldring", + toprope: "Tauklatring", + outdoor: "Utendørs", + other: "Annet", + // Norwegian variations (in case they're stored in Norwegian) + buldring: "Buldring", + tauklatring: "Tauklatring", + utendørs: "Utendørs", + annet: "Annet" + }; + return typeLabels[type.toLowerCase()] || type; +} + +/** + * Get all available event types with their labels + */ +export function getEventTypes(): Array<{ value: string; label: string }> { + return [ + { value: "boulder", label: "Buldring" }, + { value: "toprope", label: "Tauklatring" }, + { value: "outdoor", label: "Utendørs" }, + { value: "other", label: "Annet" } + ]; +} + +/** + * Check if an event type is valid + */ +export function isValidEventType(type: string): boolean { + const validTypes = ["boulder", "toprope", "outdoor", "other", "buldring", "tauklatring", "utendørs", "annet"]; + return validTypes.includes(type.toLowerCase()); +} \ No newline at end of file diff --git a/frontend/public/file.svg b/frontend/public/file.svg new file mode 100644 index 0000000..004145c --- /dev/null +++ b/frontend/public/file.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/public/globe.svg b/frontend/public/globe.svg new file mode 100644 index 0000000..567f17b --- /dev/null +++ b/frontend/public/globe.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/public/manifest-v2 2.json b/frontend/public/manifest-v2 2.json new file mode 100644 index 0000000..3472974 --- /dev/null +++ b/frontend/public/manifest-v2 2.json @@ -0,0 +1,20 @@ +{ + "name": "Cliffi", + "short_name": "Cliffi", + "start_url": "/", + "display": "standalone", + "background_color": "#0f172a", + "theme_color": "#0f172a", + "icons": [ + { + "src": "/cliffi_logo.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/cliffi_logo.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} diff --git a/frontend/public/next.svg b/frontend/public/next.svg new file mode 100644 index 0000000..5174b28 --- /dev/null +++ b/frontend/public/next.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/public/vercel.svg b/frontend/public/vercel.svg new file mode 100644 index 0000000..7705396 --- /dev/null +++ b/frontend/public/vercel.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/public/window.svg b/frontend/public/window.svg new file mode 100644 index 0000000..b2b2a44 --- /dev/null +++ b/frontend/public/window.svg @@ -0,0 +1 @@ + \ No newline at end of file