All files / src/components/wallet EudiQrPanel.tsx

100% Statements 4/4
100% Branches 6/6
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 636x                                         22x 22x 22x                                                                              
"use client";
 
import { CITIZEN_WALLET } from "@/lib/wallet-config";
import { useT } from "@/lib/i18n/translate";
 
/**
 * The QR code of a running EUDI Wallet presentation, what the wallet has
 * done so far, and the deep link for a person already on their phone. Used
 * by the sign-in page and the link page (ADR-067).
 */
export function EudiQrPanel({
  qr,
  walletLink,
  walletOpened,
  walletSilent,
}: {
  qr: string;
  walletLink: string | null;
  walletOpened: boolean;
  walletSilent: boolean;
}) {
  const wallet = CITIZEN_WALLET;
  const t = useT("patient");
  return (
    <>
      <div className="bg-white rounded-lg p-4 inline-block mb-4">
        {/* eslint-disable-next-line @next/next/no-img-element */}
        <img
          src={qr}
          alt={t("{wallet} OpenID4VP QR code", { wallet: wallet.name })}
          width={256}
          height={256}
          className="block"
        />
      </div>
      <div className="flex items-center justify-center gap-2 text-sm text-(--text-secondary) mb-3">
        <span className="inline-block w-2 h-2 rounded-full bg-green-500 animate-pulse" />
        {walletOpened
          ? t("Your wallet opened the request…")
          : t("Waiting for your wallet…")}
      </div>
      {walletSilent && (
        <p
          role="status"
          className="text-xs text-amber-600 dark:text-amber-400 mb-3"
        >
          {t(
            "Your wallet opened the request but has not answered. If it says this service may not verify your data, this hub is not registered with that wallet yet.",
          )}
        </p>
      )}
      {walletLink && (
        <a
          href={walletLink}
          className="text-xs text-(--accent) underline break-all"
        >
          {t("On this phone? Tap to open {wallet}", { wallet: wallet.name })}
        </a>
      )}
    </>
  );
}