const getLatestJobs = (client = false) => {
    const clients = ["zonis", "multipago", "vakoSRL"];
    if (client) {
        const allData = {
            'zonis': {
                id: 1,
                images: getPublic(client),
                description: "Estudio contable."
            },
            'multipago': {
                id: 2,
                images: getPublic(client),
                description: "Pagina institucional de empresa de servicio de cobro."
            },
            'vakoSRL': {
                id: 3,
                images: getPublic(client),
                description: "Web Auto-Administrable para publicar viajes de cargas para transportistas."
            }
        }
        return allData[client]
    } else {
        return clients
    }
}

export {
    getLatestJobs,
}

const getPublic = (client) => {
    let readFiles;
    switch (client) {
        case "zonis":
            readFiles = import.meta.glob('@/assets/img/jobs/zonis/*.webp', { eager: true });
            break;
        case "multipago":
            readFiles = import.meta.glob('@/assets/img/jobs/multipago/*.webp', { eager: true });
            break;
        case "vakoSRL":
            readFiles = import.meta.glob('@/assets/img/jobs/vakoSRL/*.webp', { eager: true });
            break;
        default:
            console.error("Cliente no reconocido");
            return [];
    }

    if (readFiles) {
        return Object.keys(readFiles).map(file => file.split("/").at(-1).replace(".webp", ""));
    } else {
        console.error("Error al leer las imágenes");
        return [];
    }
};
