import { createLog } from "../../../../logger/logger.js";

export const scacCheck = async (data: any) => {
    createLog(
        "info",
        "ti",
        "notify",
        `Checking if ${data[0].addressAlias} has remark: ${data[0].remark}`
    );

    const priceSheet = `
        <PriceSheets>
            <PriceSheet type="Carrier" isSelected="${
                data[0].remark.includes("SCAC") && // make sure we have the word scac
                data[0].remark.split(",")[0] && // and its valid as well
                !data[0].remark.includes("[") // if they funny and put [carrier] just ignore it.
                    ? "true"
                    : "false"
            }">
                <ContractId/>
                ${
                    data[0].remark.split(",")[0]
                        ? `<SCAC>${data[0].remark
                              .split(",")[0]
                              .split(":")[1]
                              ?.toUpperCase()
                              .slice(0, 4)}</SCAC>`
                        : `<SCAC/>`
                }
                <Mode/>
        </PriceSheet>
        </PriceSheets>
        `;

    return priceSheet;
};
