"use client"; import { isSafeUrlForLink } from "@app/lib/launcherResourceAccess"; import { useTranslations } from "next-intl"; import Link from "next/link"; import { LauncherCopyIcon } from "./LauncherCopyIcon"; type LauncherResourceAccessProps = { accessDisplay: string; accessCopyValue: string; accessUrl?: string | null; mode?: string; variant: "grid" | "list"; }; export function LauncherResourceAccess({ accessDisplay, accessCopyValue, accessUrl, mode, variant }: LauncherResourceAccessProps) { const t = useTranslations(); const isExitNode = mode === "gateway"; const display = isExitNode ? t("resourceLauncherAllInternetTraffic") : accessDisplay; if (!display) { return null; } const href = accessUrl ?? undefined; const canLink = !isExitNode && href && isSafeUrlForLink(href); const copyValue = canLink ? href : accessCopyValue; const showCopy = !isExitNode && Boolean(copyValue); if (variant === "list") { return (
{canLink ? ( {display} ) : ( {display} )} {showCopy ? : null}
); } return (
{canLink ? ( {display} ) : ( {display} )} {showCopy ? : null}
); }