"use client";

import { useEffect } from "react";
import Cookies from "js-cookie";
import { trackExploreInteraction } from "@/api/trackExploreInteraction";

export default function ProfileVisitTracker({
  profileUserId,
}: {
  profileUserId: string;
}) {
  useEffect(() => {
    const token = Cookies.get("token") || "";
    if (!token || !profileUserId) return;

    trackExploreInteraction(
      {
        targetType: "profile",
        targetId: profileUserId,
        authorId: profileUserId,
        action: "profile_visit",
      },
      token
    );
  }, [profileUserId]);

  return null;
}
