const fs = require('fs'); function patchFile(file) { let content = fs.readFileSync(file, 'utf8'); // Change destructuring to include isCar as isCarMeta, etc. content = content.replace( /const { logoSrc, typeLabel, numTrain } = getTrainLogoAndMeta\(horaire\);/g, "const { logoSrc, typeLabel, numTrain, isCar: metaIsCar, isSubstitution: metaIsSubstitution, brand: metaBrand } = getTrainLogoAndMeta(horaire);" ); // Patch the isCar definition content = content.replace( /const isCar = \([\s\S]*?\s*Boolean\(horaire\.is_substitution\) \|\|[\s\S]*?\s*isSubstitution\(horaire\)\n\t\);/, "const isCar = metaIsCar || Boolean(horaire.is_substitution) || isSubstitution(horaire);\n\tconst isSub = metaIsSubstitution || Boolean(horaire.is_substitution) || isSubstitution(horaire);" ); // If the type column is rendered, we can apply a class based on metaBrand // Example:
// We can add a data-brand={metaBrand} or just use style/class. Let's just modify the typeLabel styling slightly if needed. // Actually, we also need to append "CAR DE REMPLACEMENT" to status if isSub is true. // Let's replace `const status = horaire._status || computeStatusForHoraireAtStop(...)` // No, let's just append to `showStatus` or similar where the marquee displays the cause. // Let's find `
` or similar content = content.replace( /
/g, `
` ); content = content.replace( /
/g, `
` ); // To handle the marquee for "CAR DE REMPLACEMENT" // find: `let infoText = infoCause || cause;` content = content.replace( /let infoText = infoCause \|\| cause;/g, "let infoText = infoCause || cause;\n\t\tif (isSub) infoText = infoText ? 'CAR DE REMPLACEMENT - ' + infoText : 'CAR DE REMPLACEMENT';" ); fs.writeFileSync(file, content, 'utf8'); } patchFile('src/pages/afficheurs/classiques/ClassiquesDeparts.js'); patchFile('src/pages/afficheurs/classiques/ClassiquesArrivees.js');