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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | 4x 661x 661x 661x 399x 258x 141x 141x 727x 582x 309x 141x 427x 282x 141x 141x 62x 62x 62x 1322x 1322x 1x 1x 1x 1x 66x 1x 1x 1x 1x 1x | "use client";
import { ArrowRight, ArrowLeft } from "lucide-react";
export function statusBadge(status: string) {
const map: Record<string, string> = {
COMPLETED:
"bg-(--role-user-bg) text-(--role-user-text) border border-(--role-user-border)",
CONFIRMED:
"bg-(--role-holder-bg) text-(--role-holder-text) border border-(--role-holder-border)",
FINALIZED:
"bg-(--role-holder-bg) text-(--role-holder-text) border border-(--role-holder-border)",
IN_PROGRESS:
"bg-(--role-hdab-bg) text-(--role-hdab-text) border border-(--role-hdab-border)",
TERMINATED:
"bg-(--role-admin-bg) text-(--role-admin-text) border border-(--role-admin-border)",
ERROR:
"bg-(--role-admin-bg) text-(--role-admin-text) border border-(--role-admin-border)",
};
return (
<span
className={`inline-block px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase ${
map[status] ?? "bg-(--surface-2) text-(--text-secondary)"
}`}
>
{status}
</span>
);
}
export function ehdsArticle(policyId?: string) {
if (!policyId) return null;
if (policyId.includes("53c") || policyId.includes("research"))
return <span className="text-(--role-trust-text)">Art. 53(c)</span>;
Eif (policyId.includes("art7") || policyId.includes("cross-border"))
return <span className="text-(--role-hdab-text)">Art. 7</span>;
return <span className="text-(--text-secondary)">{policyId}</span>;
}
function shortHash(h?: string) {
if (!h) return "—";
return (
<span title={h} className="font-mono text-(--text-secondary)">
{h.slice(0, 8)}
</span>
);
}
export function formatBytes(b?: number) {
if (!b) return "—";
if (b >= 1_048_576) return `${(b / 1_048_576).toFixed(1)} MB`;
if (b >= 1024) return `${(b / 1024).toFixed(0)} KB`;
return `${b} B`;
}
export function directionBadge(direction?: string) {
if (!direction) return null;
if (direction === "OUTGOING")
return (
<span className="inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-sm text-[10px] font-semibold bg-(--role-patient-bg) text-(--role-patient-text) border border-(--role-patient-border)">
<ArrowRight size={9} /> OUT
</span>
);
return (
<span className="inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-sm text-[10px] font-semibold bg-(--role-user-bg) text-(--role-user-text) border border-(--role-user-border)">
<ArrowLeft size={9} /> IN
</span>
);
}
/** "Transfer" or "Query", in the picker's language when given a translator. */
export function accessTypeBadge(
kind?: string,
tr: (text: string) => string = (s) => s,
) {
Iif (!kind) return <span className="text-(--text-secondary)">—</span>;
const cls =
kind === "INITIAL_TRANSFER"
? "bg-(--role-holder-bg) text-(--role-holder-text) border border-(--role-holder-border)"
: "bg-(--role-trust-bg) text-(--role-trust-text) border border-(--role-trust-border)";
return (
<span
className={`inline-block px-1.5 py-0.5 rounded-sm text-[10px] font-semibold uppercase ${cls}`}
>
{kind === "INITIAL_TRANSFER" ? tr("Transfer") : tr("Query")}
</span>
);
}
export function displayName(name?: string, did?: string, country?: string) {
const label =
name || did?.replace("did:web:", "").replace(/%3A/g, ":") || "—";
return country ? `${label} (${country})` : label;
}
export function exportCSV(rows: Record<string, unknown>[], filename: string) {
Iif (!rows.length) return;
const keys = Object.keys(rows[0]);
const header = keys.join(",");
const body = rows
.map((r) => keys.map((k) => JSON.stringify(r[k] ?? "")).join(","))
.join("\n");
const blob = new Blob([`${header}\n${body}`], { type: "text/csv" });
const a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = filename;
a.click();
}
|