import api from "./api";

export interface AuditLog {
  id: string;
  action: string;
  entity: string;
  actorRole: string;
  patientName?: string | null;
  createdAt: string;
}

/* ============================
   ADMIN AUDITS (EXISTING)
============================ */

export const getRecentAuditLogs = async () => {
  const res = await api.get("/audit/recent");
  return res.data;
};

export const getAllAuditLogs = async () => {
  const res = await api.get("/audit");
  return res.data;
};

export const getMdtAuditLogs = async () => {
  const res = await api.get("/audit/mdt");
  return res.data;
};

/* ============================
   DOCTOR AUDITS (EXISTING + ADDED)
============================ */

// ✅ Recent (last 5) patient-related audits for doctor
export const getDoctorRecentPatientAuditLogs = async () => {
  const res = await api.get("/audit/doctor/patients/recent");
  return res.data;
};

// ✅ ALL patient-related audits for doctor
export const getDoctorPatientAuditLogs = async () => {
  const res = await api.get("/audit/doctor/patients");
  return res.data;
};

export const getDoctorAllPatientAuditLogs = async () => {
  const res = await api.get("/audit/doctor/patients");
  return res.data;
};

export const getDoctorRecentAuditLogs = async () => {
  const res = await api.get("/audit-logs/doctor/recent");
  return res.data;
};

/* ============================
   ✅ NEW ADDITION (ONLY CHANGE)
   DOCTOR → MDT SUBMITTED (DASHBOARD)
============================ */

export const getDoctorSubmittedMdtsForDashboard = async () => {
  const res = await api.get("/audit/doctor/mdt/submitted");
  return res.data;
};

