'use client';

import { useTrackEntityView } from '@/hooks/use-track-entity-view';

/**
 * Render-only client component that records "the user opened this
 * entity" via the global-search recently-viewed Redis log. Drop into a
 * server-rendered detail page as `<TrackEntityView type="client" id={…} />`
 * - the component renders nothing.
 *
 * Centralises the tracking call so future changes (debounce, schema,
 * batching) only need to touch one file rather than every detail page.
 */
export function TrackEntityView({
  type,
  id,
}: {
  type:
    | 'client'
    | 'residential-client'
    | 'yacht'
    | 'company'
    | 'interest'
    | 'residential-interest'
    | 'berth'
    | 'invoice'
    | 'expense'
    | 'document';
  id: string | null | undefined;
}) {
  useTrackEntityView(type, id);
  return null;
}
