import { getRequest } from "@/lib/customFetch";

export const fetchUserToken = async ({
  options,
}: {
  options?: { signal?: AbortSignal; headers?: Record<string, string> };
}) => {
  const response = await getRequest(
    "https://api.v3.ycymedu.com/api/sysOnlineUser/hasitexpired",
    {},
    options
  );

  if (response.code === 200) {
    return { result: response.result };
  } else {
    return { result: [], message: response.message };
  }
};

export const fetchReport = async ({
  params,
  options,
}: {
  params: { Type: string; Id: string };
  options?: { signal?: AbortSignal; headers?: Record<string, string> };
}) => {
  const response = await getRequest(
    "https://api.v3.ycymedu.com/api/busScale/GetBusAIReportKeyWord",
    params,
    options
  );

  if (response.code === 200) {
    return { result: response.result };
  } else {
    return { result: [], message: response.message };
  }
};

export const fetchFile = async ({
  params,
  options,
}: {
  params: { id: string; location: string };
  options?: { signal?: AbortSignal; headers?: Record<string, string> };
}) => {
  const response = await getRequest(
    "https://api.v3.ycymedu.com/api/volunTb/downloadpdfUrl",
    params,
    options
  );

  if (response.code === 200) {
    return { result: response.result };
  } else {
    return { result: "", message: response.message };
  }
};


export const fetchWishList = async ({
  params,
  options,
}: {
  params: { locationCode: string; };
  options?: { signal?: AbortSignal; headers?: Record<string, string> };
}) => {
  const response = await getRequest("https://api.v3.ycymedu.com/api/volunTb/v2/list", params, options);

  if (response.code === 200) {
    return { result: response.result };
  } else {
    return { result: [], message: response.message };
  }
};

export const getCozeToken = async({
  options,
}: {

  options?: { signal?: AbortSignal; headers?: Record<string, string> };
}) => {
   const response = await getRequest("https:///api.v3.ycymedu.com/api/sysDictData/secrtToken", {Id:740405293269061}, options);

  if (response.code === 200) {
    return { result: response.result };
  } else {
    return { result: [], message: response.message };
  } 

}