"use server";

// import { serverFetchWithNoContent } from '@/app/utils/fetchUtil';
// import { BASE_API_URL } from "@/config/api";
import { serverFetchWithNoContent } from "../../../utils/fetchUtil";
import { BASE_API_URL } from "../../../../config/api";

export interface M18ImportPoForm {
  modifiedDateFrom: string;
  modifiedDateTo: string;
}

export interface M18ImportDoForm {
  modifiedDateFrom: string;
  modifiedDateTo: string;
}

export interface M18ImportPqForm {
  modifiedDateFrom: string;
  modifiedDateTo: string;
}

export interface M18ImportMasterDataForm {
  modifiedDateFrom: string;
  modifiedDateTo: string;
}

export interface M18ImportTestingForm {
  po: M18ImportPoForm;
  do: M18ImportDoForm;
  pq: M18ImportPqForm;
  masterData: M18ImportMasterDataForm;
}

export const testM18ImportPo = async (data: M18ImportPoForm) => {
  return serverFetchWithNoContent(`${BASE_API_URL}/m18/po`, {
    method: "POST",
    body: JSON.stringify(data),
    headers: { "Content-Type": "application/json" },
  });
};

export const testM18ImportDo = async (data: M18ImportDoForm) => {
  return serverFetchWithNoContent(`${BASE_API_URL}/m18/do`, {
    method: "POST",
    body: JSON.stringify(data),
    headers: { "Content-Type": "application/json" },
  });
};

export const testM18ImportPq = async (data: M18ImportPqForm) => {
  return serverFetchWithNoContent(`${BASE_API_URL}/m18/pq`, {
    method: "POST",
    body: JSON.stringify(data),
    headers: { "Content-Type": "application/json" },
  });
};

export const testM18ImportMasterData = async (
  data: M18ImportMasterDataForm,
) => {
  return serverFetchWithNoContent(`${BASE_API_URL}/m18/master-data`, {
    method: "POST",
    body: JSON.stringify(data),
    headers: { "Content-Type": "application/json" },
  });
};
