import { adminRequest } from "@/lib/admin-http";


import type {
  AdminReconcileItemsData,
  AdminReconcileJobCreateResponse,
  AdminReconcileJobListData,
} from "@/types/api/admin-reconcile";

const A = `/admin`;

export async function getAdminReconcileJobs(params?: {
  page?: number;
  per_page?: number;
  reconcile_type?: string;
}): Promise<AdminReconcileJobListData> {
  return adminRequest.get<AdminReconcileJobListData>(`${A}/reconcile-jobs`, {
    params,
  });
}

export async function postAdminReconcileJob(body: {
  reconcile_type: string;
  date_from?: string | null;
  date_to?: string | null;
  player_id?: number | null;
  items?: {
    side_a_ref?: string | null;
    side_b_ref?: string | null;
    difference_amount?: number | null;
    status?: string | null;
  }[];
}): Promise<AdminReconcileJobCreateResponse> {
  return adminRequest.post<AdminReconcileJobCreateResponse>(
    `${A}/reconcile-jobs`,
    body,
  );
}

export async function getAdminReconcileJobItems(
  jobId: number,
  params?: { page?: number; per_page?: number },
): Promise<AdminReconcileItemsData> {
  return adminRequest.get<AdminReconcileItemsData>(
    `${A}/reconcile-jobs/${jobId}/items`,
    { params },
  );
}
