import recordAxiosInstance from "@/shared/services/recordAxiosInstance";
import { withHeaders } from "@/record-management/services/api/withHeaders";
import type {
  AllRecord,
  AllRecordsParams,
  AllRecordsResponse,
} from "@/user-management/all-records/types";

// Provisional paths: update here when the backend contract is finalized.
const ALL_RECORDS_PATH = "/records/all";

export const fetchAllRecords = async (
  params: AllRecordsParams,
): Promise<AllRecordsResponse> => {
  const { data } = await recordAxiosInstance.get<AllRecordsResponse>(
    ALL_RECORDS_PATH,
    { params, headers: withHeaders() },
  );
  return data;
};

export const fetchRecordDetails = async (id: string): Promise<AllRecord> => {
  const { data } = await recordAxiosInstance.get<AllRecord>(`/records/${id}`, {
    headers: withHeaders(),
  });
  return data;
};
