"use client"; import { ExternalLink, QrCode } from "lucide-react"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import QRCodeSvg from "react-qr-code"; import { CopyField, SettingsCard, SettingsSection, whiteButton, } from "@/components/settings/settings-parts"; import { Button } from "@/components/ui/button"; import { Dialog, DialogDescription, DialogHeader, DialogPanel, DialogPopup, DialogTitle, } from "@/components/ui/dialog"; import { authClient } from "@/lib/auth-client"; import { resolveBackendUrl } from "@/lib/backend-url"; import { cn } from "@/lib/utils"; // Patient Portal section (Settings → Signing): surfaces the clinic's public // portal link so patients can open it, copy it, or scan a QR. The portal lives // at /portal/; the QR also carries the backend base (`?api=`) so the // patient wallet app can reach the JSON API when it scans the same code. export function PatientPortalSection() { const { t } = useTranslation(); const { data: activeOrg } = authClient.useActiveOrganization(); const [qrOpen, setQrOpen] = useState(false); const slug = activeOrg?.slug; const origin = typeof window !== "undefined" ? window.location.origin : ""; const portalUrl = slug ? `${origin}/portal/${slug}` : ""; const qrUrl = slug ? `${portalUrl}?api=${encodeURIComponent(resolveBackendUrl())}` : ""; return (
{t("settings.portal.qrTitle")} {t("settings.portal.qrDescription")} {qrUrl ? (
) : null}

{portalUrl}

); }