"use client";

import { getResumeProfile } from "@/lib/services/resumeProfile.service";
import { resumeMapper } from "@/lib/resumeMapper";
import { useQuery } from "@tanstack/react-query";

// Reuse the application-wide profile cache when another dashboard view loaded it.
export const RESUME_PROFILE_QUERY_KEY = ["profile"] as const;

export function useResumeProfile() {
  return useQuery({
    queryKey: RESUME_PROFILE_QUERY_KEY,
    queryFn: getResumeProfile,
    staleTime: 5 * 60 * 1000,
    select: (response) => resumeMapper(response.data),
  });
}
