spb/datacenterindex
Public
HTML 53.9%
TypeScript 44.5%
JavaScript 0.6%
SQL 0.5%
1"use client";23import { Check, Link2 } from "lucide-react";4import { useState } from "react";5import { Button } from "@/components/ui/button";6import { CoverageBar } from "@/components/intelligence/shared";7import { fmtInt } from "@/lib/format";89/** "47 infrastructure records match · MW coverage 12 %" + Save view (copies the URL — the URL is the saved view). */10export function ResultBar({ total, entity, mwCoverage }: { total: number | null; entity: "facilities" | "projects"; mwCoverage: number | null }) {11 const [copied, setCopied] = useState<"ok" | "fail" | null>(null);12 const save = async () => {13 const url = window.location.href;14 try {15 await navigator.clipboard.writeText(url);16 setCopied("ok");17 } catch {18 window.prompt("Copy this view's URL", url);19 setCopied("fail");20 }21 setTimeout(() => setCopied(null), 2000);22 };23 const word = entity === "projects" ? (total === 1 ? "project record" : "project records") : total === 1 ? "infrastructure record" : "infrastructure records";24 return (25 <div className="flex flex-wrap items-center gap-x-4 gap-y-2">26 <p className="text-[14px] text-ink" aria-live="polite">27 {total === null ? (28 <span className="text-ink-3">Results unavailable</span>29 ) : (30 <>31 <span className="figure font-semibold">{fmtInt(total)}</span> {word} match32 </>33 )}34 </p>35 {mwCoverage !== null && (36 <span className="inline-flex items-center gap-2 text-[12px] text-ink-3">37 MW coverage <CoverageBar value={mwCoverage} width="w-[110px]" label="MW coverage of the result set" />38 </span>39 )}40 <Button size="xs" variant="secondary" onClick={() => void save()} className="ml-auto" aria-label="Save view — copy the URL of this query">41 {copied === "ok" ? <Check className="size-3.5 text-ok" aria-hidden /> : <Link2 className="size-3.5" aria-hidden />}42 {copied === "ok" ? "URL copied" : copied === "fail" ? "Copy from prompt" : "Save view"}43 </Button>44 </div>45 );46}47