import { energizerForecast } from "./mappings/energizer.js";
import { lorealForecast } from "./mappings/loralForecast.js";
import { pNgForecast } from "./mappings/pNgForecast.js";
import { standardForecast } from "./mappings/standardForcast.js";

export const forecastIn = async (data: any, user: any) => {
    /**
     * Bulk orders in, and custom file parsing.
     */

    let success = true;
    let message = "";
    let orderData: any = [];

    // what type of order are we dealing with?
    if (data["fileType"] === "standard") {
        //run the standard forecast in
        const standard = await standardForecast(data["postForecast"], user);
        success = standard.success ?? false;
        message = standard.message ?? "Error posting standard forecast";
        orderData = standard.data;
    }

    if (data["fileType"] === "energizer") {
        // orders in
    }

    if (data["fileType"] === "loreal") {
        //run the standard forecast in
        const loreal = await lorealForecast(data["postForecast"], user);
        success = loreal.success ?? false;
        message = loreal.message ?? "Error posting standard forecast";
        orderData = loreal.data;
    }

    if (data["fileType"] === "pg") {
        //run the standard forecast in
        const pg = await pNgForecast(data["postForecast"], user);
        success = pg.success ?? false;
        message = pg.message ?? "Error posting standard forecast";
        orderData = pg.data;
    }

    if (data["fileType"] === "energizer") {
        //run the standard forecast in
        const eg = await energizerForecast(data["postForecast"], user);
        success = eg.success ?? false;
        message = eg.message ?? "Error posting standard forecast";
        orderData = eg.data;
    }

    return {
        success,
        message,
        data: orderData,
    };
};
