'use client';

/**
 * G8: the pieces of a pinned timeline card (beyond the 28 Oct design, the user's decision of
 * 18 Nov 2026, from HubSpot): a "Pin" / "Unpin" link in the card header, a pin badge on the top
 * edge of a pinned card, and the line shown when pins could not load. Styles: `details.css`,
 * "G8 timeline pins" (company cards included).
 */

export function TimelinePinToggle({
  pinned,
  busy = false,
  onToggle,
}: {
  pinned: boolean;
  busy?: boolean;
  onToggle: () => void;
}) {
  return (
    <button
      type="button"
      className="crm-pin-toggle"
      aria-pressed={pinned}
      disabled={busy}
      // The card header opens and closes the card on click and Enter: Pin doesn't.
      onClick={(e) => {
        e.stopPropagation();
        onToggle();
      }}
      onKeyDown={(e) => e.stopPropagation()}
    >
      {pinned ? 'Unpin' : 'Pin'}
    </button>
  );
}

/** The design's pin icon (list-page.js `pin`). */
export function PinnedBadge() {
  return (
    <span className="crm-pin-badge" title="Pinned" aria-label="Pinned" role="img">
      <svg viewBox="0 0 24 24" aria-hidden>
        <path d="M12 17v5M9 3h6l-1 6 4 4H6l4-4z" />
      </svg>
    </span>
  );
}

export function PinsLoadError() {
  return (
    <p className="crm-pins-error" role="status">
      Couldn&apos;t load pinned activity.
    </p>
  );
}
