"use client";

import { useTranslation } from "react-i18next";
import { MdVerified } from "react-icons/md";

/**
 * BE-127 — the «جهة حكومية موثّقة» mark beside an entity's name.
 *
 * Shown only when the API says `is_verified`, which on an **organization**
 * profile means the entity's type is Governmental. It is computed from that
 * type rather than toggled by an admin, so it cannot drift from the account.
 *
 * Read the note in `commonProfileTypes.ts` before reusing the field: two other
 * payloads carry an `is_verified` that means something else entirely.
 *
 * The glyph is `MdVerified` from `react-icons`, already a dependency and
 * already used across the app — no new asset, and no invented artwork. The
 * label is the accessible name rather than visible text, so the mark sits
 * inline beside a heading without re-flowing it; `title` gives the same words
 * on hover for a pointer.
 */
export default function VerifiedBadge({
  verified,
  className = "",
  size = 20,
}: {
  verified?: boolean | null;
  className?: string;
  size?: number;
}) {
  const { t } = useTranslation();
  if (verified !== true) return null;
  const label = t("COMMON.GOVERNMENT_VERIFIED");

  return (
    <MdVerified
      role="img"
      aria-label={label}
      title={label}
      // The client's blue (2026-10-10) — it was the orange `primary-504`.
      className={`inline-block shrink-0 text-[#3897F0] ${className}`}
      size={size}
    />
  );
}
