All files / src/app/admin/components/_components TrendArrow.tsx

9.09% Statements 1/11
0% Branches 0/10
0% Functions 0/1
11.11% Lines 1/9

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 381x                                                                          
"use client";
 
import { useT } from "@/lib/i18n/translate";
 
export function TrendArrow({
  current,
  previous,
  hasPrevData,
}: {
  current: number;
  previous: number;
  hasPrevData: boolean;
}) {
  const t = useT("admin");
  if (!hasPrevData) return <span className="text-(--text-secondary)">—</span>;
  const delta = current - previous;
  const pct =
    previous > 0 ? Math.round((delta / previous) * 100) : delta > 0 ? 100 : 0;
  if (Math.abs(pct) < 3) return <span title={t("Stable vs yesterday")}>→</span>;
  if (delta > 0)
    return (
      <span
        className="text-(--danger-text)"
        title={t("{pct}% vs yesterday", { pct: `+${pct}` })}
      >
        ↑
      </span>
    );
  return (
    <span
      className="text-(--success-text)"
      title={t("{pct}% vs yesterday", { pct })}
    >
      ↓
    </span>
  );
}