From 2876806a3b92e4e721b4ba6acbfc08c7b20f7ecd Mon Sep 17 00:00:00 2001 From: alma Date: Mon, 12 Jan 2026 15:22:46 +0100 Subject: [PATCH] Centrale Refactor Big --- app/missions/[missionId]/page.tsx | 32 +++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/app/missions/[missionId]/page.tsx b/app/missions/[missionId]/page.tsx index cee35e3..55fcd77 100644 --- a/app/missions/[missionId]/page.tsx +++ b/app/missions/[missionId]/page.tsx @@ -191,6 +191,23 @@ export default function MissionDetailPage() { }; }; + // Function to sanitize mission name (same logic as N8N) + const sanitizeMissionName = (name: string): string => { + if (!name || typeof name !== "string") return "unnamed-mission"; + return name.toLowerCase() + .split("") + .map(c => { + if (c >= "a" && c <= "z") return c; + if (c >= "0" && c <= "9") return c; + if (c === " " || c === "-") return c; + return ""; + }) + .join("") + .split(" ") + .filter(Boolean) + .join("-"); + }; + // Handle delete mission const handleDeleteMission = async () => { @@ -629,10 +646,17 @@ export default function MissionDetailPage() { })()} {mission.giteaRepositoryUrl && (() => { - // Gitea URL should already be a full URL, but handle both cases - const giteaUrl = mission.giteaRepositoryUrl.startsWith('http') - ? mission.giteaRepositoryUrl - : `https://gite.slm-lab.net/${mission.giteaRepositoryUrl}`; + // Use mission name (sanitized) as repo name + const repoName = sanitizeMissionName(mission.name); + + // Get Gitea owner from environment variable (default: "alma") + // Note: In Next.js client components, we need NEXT_PUBLIC_ prefix + const giteaOwner = typeof window !== 'undefined' + ? (process.env.NEXT_PUBLIC_GITEA_OWNER || 'alma') + : 'alma'; + + // Build the correct Gitea URL: gite.slm-lab.net/owner/repo-name + const giteaUrl = `https://gite.slm-lab.net/${giteaOwner}/${repoName}`; return (