// components/portal/UtilitySwitcher.tsx "use client"; import { useRouter, useSearchParams } from "next/navigation"; import { cn } from "@/lib/utils"; type Item = { label: string; note: string; icon: string; href: string; check?: string; /** present only for subdomain links */ target?: "_blank"; }; type Tab = "onsite" | "subdomains"; const TABS: { key: Tab; label: string }[] = [ { key: "onsite", label: "On-site" }, { key: "subdomains", label: "Subdomains" }, ]; /** Raw catalog (from your old dashboard) */ const RAW_ITEMS: Item[] = [ // --- on-site (same tab) { label: "Laser Toolkit", note: "convert laser settings, interval and more", icon: "toolkit.png", href: "https://makearmy.io/laser-toolkit", check: "https://makearmy.io/laser-toolkit", }, { label: "File Server", note: "download from our file explorer", icon: "fs.png", href: "https://makearmy.io/files", check: "https://makearmy.io/files", }, { label: "Buying Guide", note: "reviews and listings for relevant products", icon: "bg.png", href: "https://makearmy.io/buying-guide", check: "https://makearmy.io/buying-guide", }, { label: "SVGnest", note: "automatically nests parts and exports svg", icon: "nest.png", href: "https://makearmy.io/svgnest", check: "https://makearmy.io/svgnest", }, { label: "BG Remover", note: "advanced open source background remover featuring 10 AI models", icon: "bgrm.png", href: "https://makearmy.io/background-remover", check: "https://makearmy.io/background-remover", }, // --- subdomains (new tab) { label: "Picsur", note: "Simple Image Host", icon: "picsur.png", href: "https://images.makearmy.io", target: "_blank", check: "https://images.makearmy.io", }, { label: "PrivateBin", note: "Your encrypted internet clipboard.", icon: "privatebin.png", href: "https://paste.makearmy.io/", target: "_blank", check: "https://paste.makearmy.io/", }, { label: "Forgejo", note: "git for our community members", icon: "forgejo.png", href: "https://forge.makearmy.io", target: "_blank", check: "https://forge.makearmy.io", }, ]; function classify(items: Item[]) { const onsite: Item[] = []; const subdomains: Item[] = []; for (const it of items) { try { const u = new URL(it.href); if (u.hostname === "makearmy.io") onsite.push(it); else subdomains.push(it); } catch { // Treat malformed URLs as on-site paths onsite.push(it); } } return { onsite, subdomains }; } const { onsite: ONSITE, subdomains: SUBS } = classify(RAW_ITEMS); function Grid({ items, external }: { items: Item[]; external: boolean }) { return (