import ApiService from "./ApiService";

// Attendance interfaces
export interface ClockInOutResponse {
  success: boolean;
  code: number;
  message: string;
  data?: {
    id: number;
    clock_in?: string;
    clock_out?: string;
    duration?: string;
    status: "ACTIVE" | "COMPLETED";
  };
}

export interface LastClockInfoResponse {
  success: boolean;
  code: number;
  message: string;
  data: {
    lastClockIn: {
      id: number;
      clock_in: string;
      clock_out: string | null;
      duration: string;
      status: "ACTIVE" | "COMPLETED";
    } | null;
    lastTimeTracking: {
      id: number;
      project_name: string;
      activity_type: string;
      start_time: string;
      end_time: string | null;
      total_minutes: number;
      description: string;
    } | null;
  };
}

// Clock In/Out API call
export async function clockInOut() {
  return ApiService.request<ClockInOutResponse>({
    url: "/time-tracking/clock-in-out",
    method: "post",
  });
}

// Get last clock info
export async function getLastClockInfo() {
  return ApiService.request<LastClockInfoResponse>({
    url: "/time-tracking/last-clock-info",
    method: "get",
  });
}
