"use server"

import { convertObjToURLSearchParams } from "@/app/utils/commonUtil";
import { serverFetchJson } from "@/app/utils/fetchUtil";
import { BASE_API_URL } from "@/config/api";
import { cache } from "react";
import { EscalationResult } from ".";


export const fetchEscalationLogsByStockInLines = cache(async(stockInLineIds: number[]) => {
    const searchParams = convertObjToURLSearchParams({stockInLineIds: stockInLineIds})
    return serverFetchJson<EscalationResult[]>(`${BASE_API_URL}/escalationLog/stockInLines?${searchParams}`, 
    {
        method: "GET",
        headers: { "Content-Type": "application/json" },
        next: {
            tags: ["escalationLogs"],
        },
    },
    );
});
