'use server'

import { serverFetchBlob } from "@/app/utils/fetchUtil";
import { BASE_API_URL } from "@/config/api";


export interface FileResponse {
    filename: string;
    blobValue: Uint8Array;
}

export interface FinancialStatusReportRequest {
    teamLeadId: number;
    startMonth: string;
    endMonth: string;
}

export const fetchProjectsFinancialStatusReport = async (data: FinancialStatusReportRequest) => {
    const reportBlob = await serverFetchBlob<FileResponse>(
        `${BASE_API_URL}/reports/fetchProjectsFinancialStatusReport`,
        {
            method: "POST",
            body: JSON.stringify(data),
            headers: { "Content-Type": "application/json" },
        },
    );

    return reportBlob
};